Package org.apache.sshd.common.future

Examples of org.apache.sshd.common.future.CloseFuture


            notifyStateChanged();
        }
    }

    protected CloseFuture preClose(boolean immediately) {
        CloseFuture future = new DefaultCloseFuture(lock);
        future.setClosed();
        return future;
    }
View Full Code Here


    public void open() throws IOException {
        start();
    }

    public CloseFuture close(boolean immediately) {
        CloseFuture future;
        if (connector != null) {
            future = CloseableUtils.sequential(connector, ioServiceFactory).close(immediately);
        } else if (ioServiceFactory != null) {
            future = ioServiceFactory.close(immediately);
        } else {
            future = CloseableUtils.closed();
        }
        future.addListener(new SshFutureListener<CloseFuture>() {
            public void operationComplete(CloseFuture future) {
                connector = null;
                ioServiceFactory = null;
                if (shutdownExecutor && executor != null) {
                    executor.shutdown();
View Full Code Here

    }

    @Override
    protected CloseFuture doCloseGracefully() {
        stopSessionTimeoutListener();
        CloseFuture future;
        if (acceptor != null) {
            future = CloseableUtils.sequential(acceptor, ioServiceFactory).close(false);
        } else if (ioServiceFactory != null) {
            future = ioServiceFactory.close(false);
        } else {
View Full Code Here

* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class CloseableUtils {

    public static CloseFuture closed() {
        CloseFuture future = new DefaultCloseFuture(null);
        future.setClosed();
        return future;
    }
View Full Code Here

                        SshFutureListener<CloseFuture> listener = new SshFutureListener<CloseFuture>() {
                            public void operationComplete(CloseFuture previousFuture) {
                                while (iterator.hasNext()) {
                                    Closeable c = iterator.next();
                                    if (c != null) {
                                        CloseFuture nextFuture = c.close(immediately);
                                        nextFuture.addListener(this);
                                        return;
                                    }
                                }
                                if (!iterator.hasNext()) {
                                    future.setClosed();
View Full Code Here

    public static <T extends SshFuture> CloseFuture parallel(final SshFuture<T>... futures) {
        return parallel(null, futures);
    }

    public static <T extends SshFuture> CloseFuture parallel(Object lock, final SshFuture<T>... futures) {
        final CloseFuture future = new DefaultCloseFuture(lock);
        if (futures.length > 0) {
            final AtomicInteger count = new AtomicInteger(futures.length);
            SshFutureListener<T> listener = new SshFutureListener<T>() {
                public void operationComplete(T f) {
                    if (count.decrementAndGet() == 0) {
                        future.setClosed();
                    }
                }
            };
            for (SshFuture<T> f : futures) {
                if (f != null) {
                    f.addListener(listener);
                } else {
                    listener.operationComplete(null);
                }
            }
        } else {
            future.setClosed();
        }
        return future;
    }
View Full Code Here

        authLatch = new CountDownLatch(1);
        SshClient client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession session = client.connect("localhost", port).await().getSession();
        AuthFuture authFuture = session.authPassword("smx", "smx");
        CloseFuture closeFuture = session.close(false);
        authLatch.countDown();
        authFuture.await();
        closeFuture.await();
        assertNotNull(authFuture.getException());
        assertTrue(closeFuture.isClosed());
    }
View Full Code Here

        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
        channel.setIn(new ByteArrayInputStream(new byte[0]));
        channel.setOut(new ByteArrayOutputStream());
        channel.setErr(new ByteArrayOutputStream());
        OpenFuture openFuture = channel.open();
        CloseFuture closeFuture = session.close(false);
        openFuture.await();
        closeFuture.await();
        assertTrue(openFuture.isOpened());
        assertTrue(closeFuture.isClosed());
    }
View Full Code Here

        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
        channel.setIn(new ByteArrayInputStream(new byte[0]));
        channel.setOut(new ByteArrayOutputStream());
        channel.setErr(new ByteArrayOutputStream());
        OpenFuture openFuture = channel.open();
        CloseFuture closeFuture = session.close(true);
        channelLatch.countDown();
        openFuture.await();
        closeFuture.await();
        assertNotNull(openFuture.getException());
        assertTrue(closeFuture.isClosed());
    }
View Full Code Here

    public void testCloseBeforeAuthSucceed() throws Exception {
        SshClient client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession session = client.connect("localhost", port).await().getSession();
        AuthFuture authFuture = session.authPassword("smx", "smx");
        CloseFuture closeFuture = session.close(false);
        authFuture.await();
        closeFuture.await();
        assertNotNull(authFuture.getException());
        assertTrue(closeFuture.isClosed());
    }
View Full Code Here

TOP

Related Classes of org.apache.sshd.common.future.CloseFuture

Copyright © 2018 www.massapicom. 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.