Package io.vertx.core.net

Examples of io.vertx.core.net.NetServer


    Map<NetServer, Integer> connectCount = new ConcurrentHashMap<>();

    CountDownLatch latchListen = new CountDownLatch(numServers);
    CountDownLatch latchConns = new CountDownLatch(numConnections);
    for (int i = 0; i < numServers; i++) {
      NetServer theServer = vertx.createNetServer(new NetServerOptions().setHost("localhost").setPort(1234));
      servers.add(theServer);
      theServer.connectHandler(sock -> {
        connectedServers.add(theServer);
        Integer cnt = connectCount.get(theServer);
        int icnt = cnt == null ? 0 : cnt;
        icnt++;
        connectCount.put(theServer, icnt);
View Full Code Here


  @Test
  public void testServerOptionsCopiedBeforeUse() {
    server.close();
    NetServerOptions options = new NetServerOptions().setPort(1234);
    NetServer server = vertx.createNetServer(options);
    // Now change something - but server should still listen at previous port
    options.setPort(1235);
    server.connectHandler(sock -> {
      testComplete();
    });
    server.listen(ar -> {
      assertTrue(ar.succeeded());
      client.connect(1234, "localhost", ar2 -> {
        assertTrue(ar2.succeeded());
      });
    });
View Full Code Here

          }
        }
        clusterManager.<String, ServerID>getAsyncMultiMap("subs", null, ar2 -> {
          if (ar2.succeeded()) {
            AsyncMultiMap<String, ServerID> subs = ar2.result();
            NetServer server = createNetServer(new NetServerOptions().setPort(options.getClusterPort()).setHost(options.getClusterHost()));
            EventBusImpl.EventBusNetServer ebServer = new EventBusImpl.EventBusNetServer(server);
            server.listen(asyncResult -> {
              if (asyncResult.succeeded()) {
                // Obtain system configured public host/port
                int publicPort = Integer.getInteger("vertx.cluster.public.port", -1);
                String publicHost = System.getProperty("vertx.cluster.public.host", null);

                // If using a wilcard port (0) then we ask the server for the actual port:
                int serverPort = publicPort == -1 ? server.actualPort() : publicPort;
                String serverHost = publicHost == null ? options.getClusterHost() : publicHost;
                ServerID serverID = new ServerID(serverPort, serverHost);
                // Provide a memory barrier as we are setting from a different thread
                synchronized (VertxImpl.this) {
                  eventBus = new EventBusImpl(this, options.getClusterPingInterval(), options.getClusterPingReplyInterval(),
View Full Code Here

    assertTrue(vertx.metrics().isEmpty());
  }

  @Test
  public void testDummyNetServerMetrics() {
    NetServer server = vertx.createNetServer(new NetServerOptions());
    assertNull(server.metricBaseName());
    assertTrue(server.metrics().isEmpty());
  }
View Full Code Here

TOP

Related Classes of io.vertx.core.net.NetServer

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.