Examples of ConnectFuture


Examples of org.apache.mina.core.future.ConnectFuture

                buf.append("Z");
            }
        });
       
        try {
            ConnectFuture future = connector.connect(new InetSocketAddress(
                    "localhost", port));
            future.awaitUninterruptibly();
            buf.append("1");
            try {
                future.getSession().close(true);
                fail();
            } catch (RuntimeIoException e) {
                // OK.
            }
            Assert.assertEquals("1", buf.toString());
View Full Code Here

Examples of org.apache.mina.core.future.ConnectFuture

                   assertions[sessionCreatedInvokedBeforeCallback] = !assertions[callbackInvoked];
                   latch.countDown();
            }
        });
       
        ConnectFuture future = connector.connect(new InetSocketAddress("127.0.0.1", port), new IoSessionInitializer<ConnectFuture>() {
            public void initializeSession(IoSession session, ConnectFuture future) {
                assertions[callbackInvoked] = true;
                callbackFuture[0] = future;
                latch.countDown();
            }
View Full Code Here

Examples of org.apache.mina.core.future.ConnectFuture

    protected abstract SocketAddress createServerSocketAddress(int port);
    protected abstract int getPort(SocketAddress address);

    @Test
    public void testSuspendResumeReadWrite() throws Exception {
        ConnectFuture future = connect(port, new ClientIoHandler());
        future.awaitUninterruptibly();
        IoSession session = future.getSession();

        // We wait for the sessionCreated() event is fired because we
        // cannot guarantee that it is invoked already.
        while (session.getAttribute("lock") == null) {
            Thread.yield();
View Full Code Here

Examples of org.apache.mina.transport.ConnectFuture

        // the socket is blocking, and either true or false if it's non blocking
        boolean connected;
        try {
            connected = clientSocket.connect(remoteAddress);
        } catch (IOException e) {
            ConnectFuture future = new ConnectFuture();
            future.cannotConnect(e);
            return future;
        }

        ConnectFuture connectFuture = new ConnectFuture();
        session.setConnectFuture(connectFuture);

        if (!connected) {
            // async connection, let's the connection complete in background, the selector loop will detect when the
            // connection is successful
View Full Code Here

Examples of org.apache.mina.transport.ConnectFuture

    @Override
    public IoFuture<IoSession> connect(SocketAddress remoteAddress) {
        BioUdpSession session = new BioUdpSession(remoteAddress, BioUdpServer.this, idleChecker);
        sessions.put(remoteAddress, session);
        ConnectFuture cf = new ConnectFuture();
        cf.complete(session);
        return cf;
    }
View Full Code Here

Examples of org.apache.sshd.client.future.ConnectFuture

        if (getConfiguration() == null) {
            throw new IllegalStateException("Configuration must be set");
        }

        ConnectFuture connectFuture = client.connect(null, getHost(), getPort());

        // Wait getTimeout milliseconds for connect operation to complete
        connectFuture.await(getTimeout());

        if (!connectFuture.isDone() || !connectFuture.isConnected()) {
            final String msg = "Failed to connect to " + getHost() + ":" + getPort() + " within timeout " + getTimeout() + "ms";
            log.debug(msg);
            throw new RuntimeCamelException(msg);
        }

        log.debug("Connected to {}:{}", getHost(), getPort());

        ClientChannel channel = null;
        ClientSession session = null;
       
        try {
            AuthFuture authResult;
            session = connectFuture.getSession();
   
            KeyPairProvider keyPairProvider;
            final String certResource = getCertResource();
            if (certResource != null) {
                log.debug("Attempting to authenticate using ResourceKey '{}'...", certResource);
View Full Code Here

Examples of org.apache.sshd.client.future.ConnectFuture

    try {
      SshClient client = sshContext.client;

      System.out.println("New SSH connection to " + connectionInfo.getHost());

      ConnectFuture connect = client.connect(connectionInfo.getSocketAddress());
      if (!connect.await(connectTimeout.getTotalMilliseconds())) {
        connect.cancel();
        throw new SshException("Timeout while waiting for SSH connection to " + connectionInfo.getHost());
      }

      this.sshClientSession = connect.getSession();

      if (this.sshClientSession == null) {
        throw new IllegalStateException();
      }
View Full Code Here

Examples of org.apache.sshd.client.future.ConnectFuture

    public ConnectFuture connect(SocketAddress address) {
        assert address != null;
        if (connector == null) {
            throw new IllegalStateException("SshClient not started. Please call start() method before connecting to a server");
        }
        final ConnectFuture connectFuture = new DefaultConnectFuture(null);
        connector.connect(address).addListener(new SshFutureListener<IoConnectFuture>() {
            public void operationComplete(IoConnectFuture future) {
                if (future.isCanceled()) {
                    connectFuture.cancel();
                } else if (future.getException() != null) {
                    connectFuture.setException(future.getException());
                } else {
                    ClientSessionImpl session = (ClientSessionImpl) AbstractSession.getSession(future.getSession());
                    connectFuture.setSession(session);
                }
            }
        });
        return connectFuture;
    }
View Full Code Here

Examples of org.apache.sshd.client.future.ConnectFuture

    public ConnectFuture connect(final String username, SocketAddress address) {
        assert address != null;
        if (connector == null) {
            throw new IllegalStateException("SshClient not started. Please call start() method before connecting to a server");
        }
        final ConnectFuture connectFuture = new DefaultConnectFuture(null);
        connector.connect(address).addListener(new SshFutureListener<IoConnectFuture>() {
            public void operationComplete(IoConnectFuture future) {
                if (future.isCanceled()) {
                    connectFuture.cancel();
                } else if (future.getException() != null) {
                    connectFuture.setException(future.getException());
                } else {
                    ClientSessionImpl session = (ClientSessionImpl) AbstractSession.getSession(future.getSession());
                    session.setUsername(username);
                    connectFuture.setSession(session);
                }
            }
        });
        return connectFuture;
    }
View Full Code Here

Examples of org.apache.sshd.client.future.ConnectFuture

        client = SshClient.setUpDefaultClient();
        client.getProperties().put(SshServer.WINDOW_SIZE, "2048");
        client.getProperties().put(SshServer.MAX_PACKET_SIZE, "256");
        client.setTcpipForwardingFilter(new BogusForwardingFilter());
        client.start();
        ConnectFuture sessionFuture = client.connect("localhost", sshPort);
        sessionFuture.await();
        ClientSession session = sessionFuture.getSession();

        AuthFuture authPassword = session.authPassword("sshd", "sshd");
        authPassword.await();

        return session;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.