@Override public void doSessionClosed(IoSessionEx session) throws Exception { AbstractNioAcceptor.LOG.debug("AbstractNioAcceptor.doSessionClosed for session " + session); NEXT_PROTOCOL_KEY.remove(session); LOCAL_ADDRESS.remove(session); REMOTE_ADDRESS.remove(session); IoSession tcpBridgeSession = getTcpBridgeSession(session); if (tcpBridgeSession != null) { tcpBridgeSession.getFilterChain().fireSessionClosed(); } }
protected void flushInboundEvents(NextFilter nextFilter, IoSession session) throws Exception { Queue<InboundEvent> inboundEvents = inboundEventsKey.remove(session); if (inboundEvents != null) { for (InboundEvent inboundEvent : inboundEvents) { inboundEvent.flush(nextFilter, session); } } }
public static void cleanup(IoSession session) { SESSION_IDLE_TIMEOUT_KEY.remove(session); deactivateSessionIdleTimeout(session); } }
@Override protected void doExceptionCaught(IoSessionEx session, Throwable cause) throws Exception { if (logger.isDebugEnabled()) { String message = format("Error on HTTP connection attempt: %s", cause); if (logger.isTraceEnabled()) { // note: still debug level, but with extra detail about the exception logger.debug(message, cause); } else { logger.debug(message); } } session.close(true); ConnectFuture httpConnectFuture = HTTP_CONNECT_FUTURE_KEY.remove(session); if (httpConnectFuture != null) { httpConnectFuture.setException(cause); } }
@Override protected void doSessionOpened(final HttpConnectSession createSession) throws Exception { Callable<WsebSession> sessionFactory = WSE_SESSION_FACTORY_KEY.remove(createSession); final WsebSession wsebSession = sessionFactory.call(); // clean up session idle tracker wsebSession.getCloseFuture().addListener(new IoFutureListener<CloseFuture>() { @Override public void operationComplete(CloseFuture future) { currentSessionIdleTracker.get().removeSession(wsebSession); // handle exception during create response createSession.close(false); } }); // store created session to process during session close, or exception WSE_SESSION_KEY.set(createSession, wsebSession); WSE_CONNECT_FUTURE_KEY.remove(createSession); }
@Override protected void doSessionOpened(IoSessionEx session) throws Exception { IoFilterChain filterChain = session.getFilterChain(); addBridgeFilters(filterChain); // defer creation of WsnSession until WebSocket handshake completed Callable<WsnSession> sessionFactory = WSN_SESSION_FACTORY_KEY.remove(session); WsnSession wsnSession = sessionFactory.call(); SESSION_KEY.set(session, wsnSession); }
@Override public void operationComplete(IoFuture future) { if (httpResponse.getStatus() != HttpStatus.CLIENT_UNAUTHORIZED) { DRAFT76_KEY3_BUFFER_KEY.remove(session); removeFilter(session.getFilterChain(), HttpMergeRequestFilter.this); if ( loggerEnabled()) { logger.trace(String.format("HttpMergeRequestFilter: response complete; removed merge request filter from session '%s'.", session)); } } else { if ( loggerEnabled()) { logger.trace(String.format("HttpMergeRequestFilter: 401 response written to session '%s'.", session)); } } } });
@Override protected void doSessionClosed(IoSessionEx session) throws Exception { WsnSession wsnSession = SESSION_KEY.remove(session); if (wsnSession != null && !wsnSession.isClosing()) { wsnSession.reset(new IOException(LoggingUtils.EARLY_TERMINATION_OF_IOSESSION_MESSAGE, wsnSession.getCloseException()) .fillInStackTrace()); } }
@Override protected void doSessionOpened(HttpSession session) throws Exception { // TODO session.get[Ready]Future().addListener(...) to check // response status / headers IoFilterChain filterChain = session.getFilterChain(); addBridgeFilters(filterChain); SseSession sseSession = SSE_SESSION_KEY.get(session); if (sseSession == null) { Callable<SseSession> sessionFactory = SSE_SESSION_FACTORY_KEY.remove(session); SseSession newSseSession = sessionFactory.call(); SSE_SESSION_KEY.set(session, newSseSession); } }
@Override protected void doSessionOpened(IoSessionEx session) throws Exception { IoFilterChain filterChain = session.getFilterChain(); addBridgeFilters(filterChain); HttpConnectSessionFactory sessionFactory = HTTP_SESSION_FACTORY_KEY.remove(session); DefaultHttpSession httpSession = sessionFactory.get(session); HTTP_SESSION_KEY.set(session, httpSession); DefaultConnectFuture connectFuture = (DefaultConnectFuture) HTTP_CONNECT_FUTURE_KEY.remove(session); if (!connectFuture.isDone()) { // needed for http redirect as there will be a new connect on the wire connectFuture.setValue(httpSession); } }
@Override protected void doSessionClosed(HttpAcceptSession session) throws Exception { SseSession sseSession = SSE_SESSION_KEY.remove(session); if (sseSession != null && !sseSession.isClosing()) { sseSession.reset(new IOException(LoggingUtils.EARLY_TERMINATION_OF_IOSESSION_MESSAGE).fillInStackTrace()); } IoFilterChain filterChain = session.getFilterChain(); removeBridgeFilters(filterChain); }
@Override protected void doSessionClosed(IoSessionEx session) throws Exception { SslSession sslSession = SESSION_KEY.remove(session); if (sslSession != null) { if (sslSession.isClosing()) { sslSession.getProcessor().remove(sslSession); } else { // behave similarly to connection reset by peer at NIO layer sslSession.reset(new IOException(LoggingUtils.EARLY_TERMINATION_OF_IOSESSION_MESSAGE).fillInStackTrace()); } } }
@Override protected void doSessionClosed(HttpAcceptSession session) throws Exception { WsebSession wsebSession = SESSION_KEY.remove(session); if (wsebSession != null && !wsebSession.isClosing()) { wsebSession.reset(new IOException(LoggingUtils.NETWORK_CONNECTIVITY_ERROR_MESSAGE).fillInStackTrace()); } IoFilterChain filterChain = session.getFilterChain(); removeBridgeFilters(filterChain); }
@Override protected void doSessionClosed(IoSessionEx session) throws Exception { // if iosession is not being closed then a higher level is asking to close out this http session, likely for upgrade if (!session.isClosing()) { IoFilterChain filterChain = session.getFilterChain(); removeBridgeFilters(filterChain); } DefaultHttpSession httpSession = SESSION_KEY.remove(session); if (httpSession != null && !httpSession.isClosing()) { httpSession.reset(new IOException(LoggingUtils.EARLY_TERMINATION_OF_IOSESSION_MESSAGE).fillInStackTrace()); } }
private DefaultConnectFuture retryConnect(DefaultHttpSession httpSession, IoSessionEx session, ResourceAddress newConnectAddress) { DefaultConnectFuture connectFuture = new DefaultConnectFuture(); HTTP_SESSION_KEY.remove(session); connectFuture.addListener(future -> session.close(false)); httpSession.setRemoteAddress(newConnectAddress); final HttpConnectSessionFactory httpSessionFactory = new HttpRetryConnectSessionFactory(httpSession); connectInternal0(connectFuture, newConnectAddress, httpSessionFactory); return connectFuture; }
@Override protected void doSessionClosed(IoSessionEx session) throws Exception { WsnSession wsnSession = SESSION_KEY.remove(session); if (wsnSession != null && !wsnSession.isClosing()) { boolean isWsx = !wsnSession.getLocalAddress().getOption(CODEC_REQUIRED); if (isWsx) { wsnSession.getProcessor().remove(wsnSession); } else { wsnSession.reset( new IOException(LoggingUtils.NETWORK_CONNECTIVITY_ERROR_MESSAGE, wsnSession.getCloseException()).fillInStackTrace()); } } IoFilterChain filterChain = session.getFilterChain(); removeBridgeFilters(filterChain); }
IoSession take(HttpResourceAddress serverAddress) { IoSession transportSession = removeThreadAligned(serverAddress); if (transportSession != null) { // Got a cached persistent connection // Remove session idle tracking for this session transportSession.getConfig().setBothIdleTime(0); IoFilterChain filterChain = transportSession.getFilterChain(); if (filterChain.contains(IDLE_FILTER)) { filterChain.remove(IDLE_FILTER); } // Remove our CloseFuture listener as it is out of pool CloseFuture closeFuture = transportSession.getCloseFuture(); closeFuture.removeListener(closeListener); SERVER_ADDRESS.remove(transportSession); } return transportSession; }
private ResourceAddress getSslSessionLocalAddress(IoSession session) { // note: bound address is unified in SSL options during bind to avoid conflicts like different cipher suites ResourceAddress boundAddress = SslAcceptor.SSL_RESOURCE_ADDRESS.remove(session); assert (boundAddress != null); // construct the candidate address with observed transport and next protocol String candidateURI = boundAddress.getExternalURI(); ResourceOptions candidateOptions = ResourceOptions.FACTORY.newResourceOptions(boundAddress); candidateOptions.setOption(NEXT_PROTOCOL, NEXT_PROTOCOL_KEY.get(session)); candidateOptions.setOption(TRANSPORT, LOCAL_ADDRESS.get(session)); ResourceAddress candidateAddress = resourceAddressFactory.newResourceAddress(candidateURI, candidateOptions); // lookup the binding for this candidate address Binding binding = bindings.getBinding(candidateAddress); return (binding != null) ? binding.bindAddress() : null; }