io.netty.util.AttributeMap Java Examples
The following examples show how to use
io.netty.util.AttributeMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpServerKeepAliveHandlerTest.java From armeria with Apache License 2.0 | 6 votes |
@BeforeEach void setUp() { counter = new AtomicInteger(); listener = new ConnectionPoolListener() { @Override public void connectionOpen(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { counter.incrementAndGet(); } @Override public void connectionClosed(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { counter.decrementAndGet(); } }; }
Example #2
Source File: ServerMaxConnectionAgeTest.java From armeria with Apache License 2.0 | 6 votes |
@BeforeEach void setUp() { opened = new AtomicInteger(); closed = new AtomicInteger(); connectionPoolListener = new ConnectionPoolListener() { @Override public void connectionOpen(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { opened.incrementAndGet(); } @Override public void connectionClosed(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { closed.incrementAndGet(); } }; }
Example #3
Source File: ConnectionPoolLoggingListener.java From armeria with Apache License 2.0 | 5 votes |
@Override public void connectionOpen(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { final int activeChannels = this.activeChannels.incrementAndGet(); if (logger.isInfoEnabled()) { attrs.attr(OPEN_NANOS).set(ticker.read()); logger.info("[L:{} - R:{}][{}] OPEN (active channels: {})", localAddr, remoteAddr, protocol.uriText(), activeChannels); } }
Example #4
Source File: ConnectionPoolLoggingListener.java From armeria with Apache License 2.0 | 5 votes |
@Override public void connectionClosed(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { final int activeChannels = this.activeChannels.decrementAndGet(); if (logger.isInfoEnabled() && attrs.hasAttr(OPEN_NANOS)) { final long closeNanos = ticker.read(); final long elapsedNanos = closeNanos - attrs.attr(OPEN_NANOS).get(); logger.info("[L:{} ! R:{}][{}] CLOSED (lasted for: {}, active channels: {})", localAddr, remoteAddr, protocol.uriText(), TextFormatter.elapsed(elapsedNanos), activeChannels); } }
Example #5
Source File: RequestProcessorAdaptor.java From mongowp with Apache License 2.0 | 5 votes |
@Override public void onChannelInactive(AttributeMap attMap) { C connection = attMap.attr(this.connection).getAndRemove(); if (connection != null) { connection.close(); } }
Example #6
Source File: RequestProcessorAdaptor.java From mongowp with Apache License 2.0 | 5 votes |
@Override public void onChannelActive(AttributeMap attMap) { C newConnection = safeRequestProcessor.openConnection(); Connection oldConnection = attMap.attr(connection).setIfAbsent( newConnection ); if (oldConnection != null) { throw new IllegalArgumentException("A connection with id " + oldConnection.getConnectionId() + " was stored before " + "channel became active!"); } }
Example #7
Source File: ConnectionPoolListenerWrapper.java From armeria with Apache License 2.0 | 5 votes |
@Override public void connectionOpen(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { delegate().connectionOpen(protocol, remoteAddr, localAddr, attrs); }
Example #8
Source File: ConnectionPoolListenerWrapper.java From armeria with Apache License 2.0 | 5 votes |
@Override public void connectionClosed(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { delegate().connectionClosed(protocol, remoteAddr, localAddr, attrs); }
Example #9
Source File: HttpClientMaxConcurrentStreamTest.java From armeria with Apache License 2.0 | 5 votes |
@Override public void connectionOpen(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { final ConnectionPoolListener connectionPoolListener = HttpClientMaxConcurrentStreamTest.this.connectionPoolListener; if (connectionPoolListener != null) { connectionPoolListener.connectionOpen(protocol, remoteAddr, localAddr, attrs); } }
Example #10
Source File: HttpClientMaxConcurrentStreamTest.java From armeria with Apache License 2.0 | 5 votes |
@Override public void connectionClosed(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception { final ConnectionPoolListener connectionPoolListener = HttpClientMaxConcurrentStreamTest.this.connectionPoolListener; if (connectionPoolListener != null) { connectionPoolListener.connectionClosed(protocol, remoteAddr, localAddr, attrs); } }
Example #11
Source File: ConnectionPoolListener.java From armeria with Apache License 2.0 | 4 votes |
/** * Invoked when a new connection is open and ready to send a request. */ void connectionOpen(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception;
Example #12
Source File: PojoMessageReplier.java From mongowp with Apache License 2.0 | 4 votes |
@Override public AttributeMap getAttributeMap() { return attributeMap; }
Example #13
Source File: PojoMessageReplier.java From mongowp with Apache License 2.0 | 4 votes |
public PojoMessageReplier(int requestId, AttributeMap attributeMap) { this.requestId = requestId; this.attributeMap = attributeMap; }
Example #14
Source File: RequestProcessorAdaptor.java From mongowp with Apache License 2.0 | 4 votes |
@Nonnull protected Connection getConnection(AttributeMap attMap) { return attMap.attr(connection).get(); }
Example #15
Source File: NettyMessageReplier.java From mongowp with Apache License 2.0 | 4 votes |
@Override public AttributeMap getAttributeMap() { return channelHandlerContext; }
Example #16
Source File: Handler.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override protected void channelRead0(final ChannelHandlerContext channelHandlerContext, final ResponseMessage response) throws Exception { // We are only interested in AUTHENTICATE responses here. Everything else can // get passed down the pipeline if (response.getStatus().getCode() == ResponseStatusCode.AUTHENTICATE) { final Attribute<SaslClient> saslClient = ((AttributeMap) channelHandlerContext).attr(saslClientKey); final Attribute<Subject> subject = ((AttributeMap) channelHandlerContext).attr(subjectKey); final RequestMessage.Builder messageBuilder = RequestMessage.build(Tokens.OPS_AUTHENTICATION); // First time through we don't have a sasl client if (saslClient.get() == null) { subject.set(login()); try { saslClient.set(saslClient(getHostName(channelHandlerContext))); } catch (SaslException saslException) { // push the sasl error into a failure response from the server. this ensures that standard // processing for the ResultQueue is kept. without this SaslException trap and subsequent // conversion to an authentication failure, the close() of the connection might not // succeed as it will appear as though pending messages remain present in the queue on the // connection and the shutdown won't proceed final ResponseMessage clientSideError = ResponseMessage.build(response.getRequestId()) .code(ResponseStatusCode.FORBIDDEN).statusMessage(saslException.getMessage()).create(); channelHandlerContext.fireChannelRead(clientSideError); return; } messageBuilder.addArg(Tokens.ARGS_SASL_MECHANISM, getMechanism()); messageBuilder.addArg(Tokens.ARGS_SASL, saslClient.get().hasInitialResponse() ? BASE64_ENCODER.encodeToString(evaluateChallenge(subject, saslClient, NULL_CHALLENGE)) : null); } else { // the server sends base64 encoded sasl as well as the byte array. the byte array will eventually be // phased out, but is present now for backward compatibility in 3.2.x final String base64sasl = response.getStatus().getAttributes().containsKey(Tokens.ARGS_SASL) ? response.getStatus().getAttributes().get(Tokens.ARGS_SASL).toString() : BASE64_ENCODER.encodeToString((byte[]) response.getResult().getData()); messageBuilder.addArg(Tokens.ARGS_SASL, BASE64_ENCODER.encodeToString( evaluateChallenge(subject, saslClient, BASE64_DECODER.decode(base64sasl)))); } channelHandlerContext.writeAndFlush(messageBuilder.create()); } else { channelHandlerContext.fireChannelRead(response); } }
Example #17
Source File: ConnectionPoolListenerAdapter.java From armeria with Apache License 2.0 | 4 votes |
@Override public void connectionClosed(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception {}
Example #18
Source File: ConnectionPoolListenerAdapter.java From armeria with Apache License 2.0 | 4 votes |
@Override public void connectionOpen(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception {}
Example #19
Source File: ConnectionPoolListener.java From armeria with Apache License 2.0 | 4 votes |
/** * Invoked when a connection in the connection pool has been closed. */ void connectionClosed(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception;
Example #20
Source File: Context.java From hxy-socket with GNU General Public License v3.0 | 4 votes |
public AttributeMap getAttribute() { return attribute; }
Example #21
Source File: MessageReplier.java From mongowp with Apache License 2.0 | votes |
public abstract AttributeMap getAttributeMap();
Example #22
Source File: RequestProcessor.java From mongowp with Apache License 2.0 | votes |
public void onChannelActive(@Nonnull AttributeMap attributeMap);
Example #23
Source File: RequestProcessor.java From mongowp with Apache License 2.0 | votes |
public void onChannelInactive(@Nonnull AttributeMap attributeMap);