private void actualClose(ContextInternal closeContext, Handler<AsyncResult<Void>> done) { if (id != null) { vertx.sharedNetServers().remove(id); } ContextInternal 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()); }); }
synchronized (vertx.sharedNetServers()) {
registeredHandler = handler; synchronized (vertx.sharedNetServers()) { this.actualPort = socketAddress.port(); // Will be updated on bind for a wildcard port String hostOrPath = socketAddress.host() != null ? socketAddress.host() : socketAddress.path(); id = new ServerID(actualPort, hostOrPath); NetServerImpl shared = vertx.sharedNetServers().get(id); if (shared == null || actualPort == 0) { // Wildcard port will imply a new actual server each time serverChannelGroup = new DefaultChannelGroup("vertx-acceptor-channels", GlobalEventExecutor.INSTANCE); vertx.sharedNetServers().put(id, NetServerImpl.this); VertxMetrics metrics = vertx.metricsSPI(); if (metrics != null) { vertx.sharedNetServers().remove(id); vertx.sharedNetServers().put(id, this);
private void actualClose(ContextInternal closeContext, Handler<AsyncResult<Void>> done) { if (id != null) { vertx.sharedNetServers().remove(id); } ContextInternal 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()); }); }
synchronized (vertx.sharedNetServers()) {
registeredHandler = handler; synchronized (vertx.sharedNetServers()) { this.actualPort = socketAddress.port(); // Will be updated on bind for a wildcard port String hostOrPath = socketAddress.host() != null ? socketAddress.host() : socketAddress.path(); id = new ServerID(actualPort, hostOrPath); NetServerImpl shared = vertx.sharedNetServers().get(id); if (shared == null || actualPort == 0) { // Wildcard port will imply a new actual server each time serverChannelGroup = new DefaultChannelGroup("vertx-acceptor-channels", GlobalEventExecutor.INSTANCE); vertx.sharedNetServers().put(id, NetServerImpl.this); VertxMetrics metrics = vertx.metricsSPI(); if (metrics != null) { vertx.sharedNetServers().remove(id); vertx.sharedNetServers().put(id, this);
@Override public void process(CommandProcess process) { VertxInternal vertx = (VertxInternal) process.vertx(); process.write("\nNet Servers:\n"); for (Map.Entry<ServerID, NetServerImpl> server : vertx.sharedNetServers().entrySet()) { process.write(server.getKey().host + ":" + server.getKey().port + "\n"); } process.write("\nHTTP Servers:\n"); for (Map.Entry<ServerID, HttpServerImpl> server : vertx.sharedHttpServers().entrySet()) { process.write(server.getKey().host + ":" + server.getKey().port + "\n"); } process.end(); } }