/** * Creates a new instance of a Connection Failure, with the associated cause. * * @param exception The exception that caused the failure * @return a new {@link ConnectFuture} which is already marked as 'failed to connect'. */ public static ConnectFuture newFailedFuture(Throwable exception) { DefaultConnectFuture failedFuture = new DefaultConnectFuture(); failedFuture.setException(exception); return failedFuture; }
/** * {@inheritDoc} */ @Override public boolean cancel() { return setValue(CANCELED); }
/** * Cancels the real connection when reconnection is in use. */ public void cancelConnectFuture() { future.cancel(); }
return newFailedFuture(new NamedPipeException("NamedPipeAcceptor not available")); DefaultConnectFuture future = new DefaultConnectFuture(); return newFailedFuture(new NamedPipeException("Local NamedPipeAddress pipe name must match remote pipe name")); return newFailedFuture(new NamedPipeException("Local NamedPipeAddress must be ephemeral")); future.setException(t); return future;
final IoSessionInitializer<T> initializer) { final ConnectFuture connectFuture = new DefaultConnectFuture();
handle = newHandle(localAddress); if (connect(handle, remoteAddress)) { ConnectFuture future = new DefaultConnectFuture(); S session = newSession(processor, handle); initSession(session, future, sessionInitializer); return DefaultConnectFuture.newFailedFuture(e); } finally { if (!success && handle != null) {
@Override public void operationComplete(ConnectFuture future) { // fail bridge connect future if parent connect fails if (!future.isConnected()) { bridgeConnectFuture.setException(future.getException()); } } }
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; }
/** * {@inheritDoc} */ @Override public Throwable getException() { Object v = getValue(); if (v instanceof Throwable) { return (Throwable) v; } else { return null; } }
return DefaultConnectFuture.newFailedFuture(new IllegalArgumentException("localAddress is not null").fillInStackTrace()); return DefaultConnectFuture.newFailedFuture(e);
@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); } }
/** * Fires the connection event on the real future to notify the client. * * @param session the current session * @return the future holding the connected session */ protected ConnectFuture fireConnected(final IoSession session) { future.setSession(session); return future; }
VmPipe entry = VmPipeAcceptor.boundHandlers.get(remoteAddress); if (entry == null) { return DefaultConnectFuture.newFailedFuture(new IOException( "Endpoint unavailable: " + remoteAddress)); DefaultConnectFuture future = new DefaultConnectFuture(); actualLocalAddress = nextLocalAddress(); } catch (IOException e) { return DefaultConnectFuture.newFailedFuture(e); idleChecker.addSession(localSession); } catch (Throwable t) { future.setException(t); return future;
@Override protected <T extends ConnectFuture> ConnectFuture connectInternal(final ResourceAddress address, final IoHandler handler, final IoSessionInitializer<T> initializer) { final ConnectFuture connectFuture = new DefaultConnectFuture(); final ResourceAddress transportAddress = address.getTransport(); // initializer for bridge session to specify bridge handler, // and call user-defined bridge session initializer if present final IoSessionInitializer<T> httpSessionInitializer = createHttpSessionInitializer(handler, initializer); // factory to create a new bridge session HttpConnectSessionFactory httpSessionFactory = new DefaultHttpConnectSessionFactory(this, address, httpSessionInitializer, connectFuture); if (transportAddress != null) { Executor ioExecutor = org.kaazing.mina.core.session.AbstractIoSessionEx.CURRENT_WORKER.get(); if (ioExecutor == null) { connectInternal0(connectFuture, address, httpSessionFactory); } else { ioExecutor.execute(() -> connectInternal0(connectFuture, address, httpSessionFactory)); } } return connectFuture; }
handle = newHandle(localAddress); if (connect(handle, remoteAddress)) { ConnectFuture future = new DefaultConnectFuture(); S session = newSession(processor, handle); initSession(session, future, sessionInitializer); return DefaultConnectFuture.newFailedFuture(e); } finally { if (!success && handle != null) {
@Override public void operationComplete(ConnectFuture future) { // fail bridge connect future if parent connect fails if ( !future.isConnected() ) { wsnConnectFuture.setException(future.getException()); } }
/** * {@inheritDoc} */ @Override public boolean isCanceled() { return getValue() == CANCELED; }
return DefaultConnectFuture.newFailedFuture(new IllegalStateException("Connector is being shut down"));
/** * Fires the connection event on the real future to notify the client. * * @param session the current session * @return the future holding the connected session */ protected ConnectFuture fireConnected(final IoSession session) { future.setSession(session); return future; }
VmPipe entry = VmPipeAcceptor.boundHandlers.get(remoteAddress); if (entry == null) { return DefaultConnectFuture.newFailedFuture(new IOException("Endpoint unavailable: " + remoteAddress)); DefaultConnectFuture future = new DefaultConnectFuture(); actualLocalAddress = nextLocalAddress(); } catch (IOException e) { return DefaultConnectFuture.newFailedFuture(e); idleChecker.addSession(localSession); } catch (Exception e) { future.setException(e); return future;