Examples of Vertx


Examples of io.vertx.core.Vertx

    checkDeploymentExists(1, "java:" + HAVerticle1.class.getName(), options);
  }

  @Test
  public void testQuorum() throws Exception {
    Vertx vertx1 = startVertx(2);
    DeploymentOptions options = new DeploymentOptions().setHa(true);
    JsonObject config = new JsonObject().put("foo", "bar");
    options.setConfig(config);
    vertx1.deployVerticle("java:" + HAVerticle1.class.getName(), options, ar -> {
      assertTrue(ar.succeeded());
      assertTrue(vertx1.deployments().contains(ar.result()));
      testComplete();
    });
    // Shouldn't deploy until a quorum is obtained
    Thread.sleep(500);
    assertTrue(vertx1.deployments().isEmpty());
    Vertx vertx2 = startVertx(2);
    // Now should be deployed
    await();
    closeVertices(vertx1, vertx2);
  }
View Full Code Here

Examples of io.vertx.core.Vertx

  }

  int pos;
  @Override
  protected Vertx getVertx() {
    Vertx vertx = vertices[pos];
    if (++pos == numNodes) {
      pos = 0;
    }
    return vertx;
  }
View Full Code Here

Examples of io.vertx.core.Vertx

  }

  int pos;
  @Override
  protected Vertx getVertx() {
    Vertx vertx = vertices[pos];
    if (++pos == getNumNodes()) {
      pos = 0;
    }
    return vertx;
  }
View Full Code Here

Examples of io.vertx.core.Vertx

  }

  int pos;
  @Override
  protected Vertx getVertx() {
    Vertx vertx = vertices[pos];
    if (++pos == numNodes) {
      pos = 0;
    }
    return vertx;
  }
View Full Code Here

Examples of io.vertx.core.Vertx

*/
public class CreateVertxTest extends AsyncTestBase {

  @Test
  public void testCreateSimpleVertx() {
    Vertx vertx = Vertx.vertx();
    assertNotNull(vertx);
  }
View Full Code Here

Examples of io.vertx.core.Vertx

  }

  @Test
  public void testCreateVertxWithOptions() {
    VertxOptions options = new VertxOptions();
    Vertx vertx = Vertx.vertx(options);
    assertNotNull(vertx);
  }
View Full Code Here

Examples of org.vertx.java.core.Vertx

        };
    }

    private void route(final YokeRequest request, final PatternBinding binding, final Handler<Object> next) {
        final Matcher m = binding.pattern.matcher(request.path());
        final Vertx vertx = vertx();
       
        if (m.matches()) {
            final MultiMap params = request.params();

            if (binding.paramNames != null) {
                // Named params
                new AsyncIterator<String>(binding.paramNames) {
                    @Override
                    public void handle(String param) {
                        if (hasNext()) {
                            params.set(param, m.group(param));
                            final Middleware paramMiddleware = paramProcessors.get(param);
                            if (paramMiddleware != null) {
                                // do not block main loop
                                vertx.runOnContext(new Handler<Void>() {
                                    @Override
                                    public void handle(Void event) {
                                        paramMiddleware.handle(request, new Handler<Object>() {
                                            @Override
                                            public void handle(Object err) {
                                                if (err == null) {
                                                    next();
                                                } else {
                                                    next.handle(err);
                                                }
                                            }
                                        });
                                    }
                                });
                            } else {
                                next();
                            }
                        } else {
                            // middlewares
                            new AsyncIterator<Middleware>(binding.middleware) {
                                @Override
                                public void handle(final Middleware middleware) {
                                    if (hasNext()) {
                                        // do not block main loop
                                        vertx.runOnContext(new Handler<Void>() {
                                            @Override
                                            public void handle(Void event) {
                                                middleware.handle(request, new Handler<Object>() {
                                                    @Override
                                                    public void handle(Object err) {
                                                        if (err == null) {
                                                            next();
                                                        } else {
                                                            next.handle(err);
                                                        }
                                                    }
                                                });
                                            }
                                        });
                                    } else {
                                        next.handle(null);
                                    }
                                }
                            };
                        }
                    }
                };
            } else {
                // Un-named params
                for (int i = 0; i < m.groupCount(); i++) {
                    params.set("param" + i, m.group(i + 1));
                }

                // middlewares
                new AsyncIterator<Middleware>(binding.middleware) {
                    @Override
                    public void handle(final Middleware middleware) {
                        if (hasNext()) {
                            // do not block main loop
                            vertx.runOnContext(new Handler<Void>() {
                                @Override
                                public void handle(Void event) {
                                    middleware.handle(request, new Handler<Object>() {
                                        @Override
                                        public void handle(Object err) {
View Full Code Here

Examples of org.vertx.java.core.Vertx

      }
    }
  }

  public static void main(String[] args) throws Exception {
    Vertx vertx = new DefaultVertx();
    UsingRooms app = new UsingRooms(vertx);
    app.start();
    Thread.sleep(Long.MAX_VALUE);
  }
View Full Code Here

Examples of org.vertx.java.core.Vertx

    server.listen(8080);
  }

  public static void main(String[] args) throws Exception {
    Vertx vertx = new DefaultVertx();
    TestWebServer webServer = new TestWebServer(vertx);
    webServer.start();
    Thread.sleep(Long.MAX_VALUE);
  }
View Full Code Here

Examples of org.vertx.java.core.Vertx

    server.listen(port);
  }

  public static void main(String[] args) throws Exception {
    Vertx vertx = new DefaultVertx();
    RestrictingYourselfToANamespace app = new RestrictingYourselfToANamespace(vertx);
    app.start();
    Thread.sleep(Long.MAX_VALUE);
  }
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.