Example usage for io.netty.channel.group ChannelGroupFuture cause

List of usage examples for io.netty.channel.group ChannelGroupFuture cause

Introduction

In this page you can find the example usage for io.netty.channel.group ChannelGroupFuture cause.

Prototype

@Override
    ChannelGroupException cause();

Source Link

Usage

From source file:io.advantageous.conekt.http.impl.HttpServerImpl.java

License:Open Source License

private void actualClose(final ContextImpl closeContext, final Handler<AsyncResult<Void>> done) {
    if (id != null) {
        vertx.sharedHttpServers().remove(id);
    }/* w ww  .j  av a  2 s .  c  om*/

    ContextImpl currCon = vertx.getContext();

    for (ServerConnection conn : connectionMap.values()) {
        conn.close();
    }

    // Sanity check
    if (vertx.getContext() != currCon) {
        throw new IllegalStateException("Context was changed");
    }

    if (metrics != null) {
        metrics.close();
    }

    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(cgf -> executeCloseDone(closeContext, done, fut.cause()));
}

From source file:io.advantageous.conekt.net.impl.NetServerImpl.java

License:Open Source License

private void actualClose(ContextImpl closeContext, Handler<AsyncResult<Void>> done) {
    if (id != null) {
        vertx.sharedNetServers().remove(id);
    }//ww w.  j ava  2s.  c  om

    ContextImpl currCon = vertx.getContext();

    for (NetSocketImpl sock : socketMap.values()) {
        sock.close();
    }

    // Sanity check
    if (vertx.getContext() != currCon) {
        throw new IllegalStateException("Context was changed");
    }

    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(cg -> {
        if (metrics != null) {
            metrics.close();
        }
        executeCloseDone(closeContext, done, fut.cause());
    });

}

From source file:io.jsync.http.impl.DefaultHttpServer.java

License:Open Source License

private void actualClose(final DefaultContext closeContext, final Handler<AsyncResult<Void>> done) {
    if (id != null) {
        async.sharedHttpServers().remove(id);
    }//from w  w w. j  a  va 2  s. co m

    for (ServerConnection conn : connectionMap.values()) {
        conn.close();
    }

    // We need to reset it since sock.internalClose() above can call into the close handlers of sockets on the same thread
    // which can cause context id for the thread to change!

    async.setContext(closeContext);

    final CountDownLatch latch = new CountDownLatch(1);

    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(new ChannelGroupFutureListener() {
        public void operationComplete(ChannelGroupFuture channelGroupFuture) throws Exception {
            latch.countDown();
        }
    });

    // Always sync
    try {
        latch.await(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
    }

    executeCloseDone(closeContext, done, fut.cause());
}

From source file:io.jsync.net.impl.DefaultNetServer.java

License:Open Source License

private void actualClose(final DefaultContext closeContext, final Handler<AsyncResult<Void>> done) {
    if (id != null) {
        async.sharedNetServers().remove(id);
    }/*www . j  a va2s  . c om*/

    for (DefaultNetSocket sock : socketMap.values()) {
        sock.close();
    }

    // We need to reset it since sock.internalClose() above can call into the close handlers of sockets on the same thread
    // which can cause context id for the thread to change!

    async.setContext(closeContext);

    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(new ChannelGroupFutureListener() {
        public void operationComplete(ChannelGroupFuture fut) throws Exception {
            executeCloseDone(closeContext, done, fut.cause());
        }
    });

}

From source file:io.vertx.core.http.impl.HttpServerImpl.java

License:Open Source License

private void actualClose(final ContextImpl closeContext, final Handler<AsyncResult<Void>> done) {
    if (id != null) {
        vertx.sharedHttpServers().remove(id);
    }//from   www .  jav a2  s .  c o  m

    ContextImpl currCon = vertx.getContext();

    for (ServerConnection conn : connectionMap.values()) {
        conn.close();
    }
    for (Http2ServerConnection conn : connectionMap2.values()) {
        conn.close();
    }

    // Sanity check
    if (vertx.getContext() != currCon) {
        throw new IllegalStateException("Context was changed");
    }

    if (metrics != null) {
        metrics.close();
    }

    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(cgf -> executeCloseDone(closeContext, done, fut.cause()));
}

From source file:io.vertx.core.net.impl.NetServerBase.java

License:Open Source License

private void actualClose(ContextImpl closeContext, Handler<AsyncResult<Void>> done) {
    if (id != null) {
        vertx.sharedNetServers().remove(id);
    }// w w  w  .j  a  v a 2  s  . com

    ContextImpl currCon = vertx.getContext();

    for (C sock : socketMap.values()) {
        sock.close();
    }

    // Sanity check
    if (vertx.getContext() != currCon) {
        throw new IllegalStateException("Context was changed");
    }

    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(cg -> {
        if (metrics != null) {
            metrics.close();
        }
        executeCloseDone(closeContext, done, fut.cause());
    });

}

From source file:org.robotninjas.protobuf.netty.server.RpcServer.java

License:Open Source License

@Override
protected void doStop() {
    try {/*  www.j ava2 s .  co m*/
        ChannelGroupFuture f = allChannels.close();
        f.addListener(new ChannelGroupFutureListener() {
            @Override
            public void operationComplete(ChannelGroupFuture future) throws Exception {
                if (future.isSuccess()) {
                    notifyStopped();
                } else {
                    notifyFailed(future.cause());
                }
            }
        });
    } catch (Throwable t) {
        notifyFailed(t);
        Throwables.propagate(t);
    }
}

From source file:org.vertx.java.core.http.impl.DefaultHttpServer.java

License:Open Source License

private void actualClose(final DefaultContext closeContext, final Handler<AsyncResult<Void>> done) {
    if (id != null) {
        vertx.sharedHttpServers().remove(id);
    }/*from www. j  a v  a2  s .  co m*/

    for (ServerConnection conn : connectionMap.values()) {
        conn.close();
    }

    // We need to reset it since sock.internalClose() above can call into the close handlers of sockets on the same thread
    // which can cause context id for the thread to change!

    vertx.setContext(closeContext);

    final CountDownLatch latch = new CountDownLatch(1);

    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(new ChannelGroupFutureListener() {
        public void operationComplete(ChannelGroupFuture channelGroupFuture) throws Exception {
            latch.countDown();
        }
    });

    // Always sync
    try {
        latch.await(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
    }

    executeCloseDone(closeContext, done, fut.cause());
}

From source file:org.vertx.java.core.net.impl.DefaultNetServer.java

License:Open Source License

private void actualClose(final DefaultContext closeContext, final Handler<AsyncResult<Void>> done) {
    if (id != null) {
        vertx.sharedNetServers().remove(id);
    }//from   w ww .  ja va  2  s.c om

    for (DefaultNetSocket sock : socketMap.values()) {
        sock.close();
    }

    // We need to reset it since sock.internalClose() above can call into the close handlers of sockets on the same thread
    // which can cause context id for the thread to change!

    vertx.setContext(closeContext);

    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(new ChannelGroupFutureListener() {
        public void operationComplete(ChannelGroupFuture fut) throws Exception {
            executeCloseDone(closeContext, done, fut.cause());
        }
    });

}