Java 类io.vertx.core.VertxOptions 实例源码

项目:okapi    文件:DropwizardHelper.java   
public static void config(String graphiteHost, int port, TimeUnit tu,
        int period, VertxOptions vopt, String hostName) {
  final String registryName = "okapi";
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(registryName);

  DropwizardMetricsOptions metricsOpt = new DropwizardMetricsOptions();
  metricsOpt.setEnabled(true).setRegistryName(registryName);
  vopt.setMetricsOptions(metricsOpt);
  Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, port));
  final String prefix = "folio.okapi." + hostName ;
  GraphiteReporter reporter = GraphiteReporter.forRegistry(registry)
          .prefixedWith(prefix)
          .build(graphite);
  reporter.start(period, tu);

  logger.info("Metrics remote:" + graphiteHost + ":"
          + port + " this:" + prefix);
}
项目:incubator-servicecomb-java-chassis    文件:VertxImplEx.java   
public VertxImplEx(String name, VertxOptions vertxOptions) {
  super(vertxOptions);

  if (StringUtils.isEmpty(name)) {
    return;
  }

  Field field = ReflectionUtils.findField(VertxImpl.class, "eventLoopThreadFactory");
  field.setAccessible(true);
  VertxThreadFactory eventLoopThreadFactory = (VertxThreadFactory) ReflectionUtils.getField(field, this);

  field = ReflectionUtils.findField(eventLoopThreadFactory.getClass(), "prefix");
  field.setAccessible(true);

  String prefix = (String) ReflectionUtils.getField(field, eventLoopThreadFactory);
  ReflectionUtils.setField(field, eventLoopThreadFactory, name + "-" + prefix);
}
项目:incubator-servicecomb-java-chassis    文件:TestVertxRestTransport.java   
@Test
public void testInit() {
  boolean status = false;
  try {
    new MockUp<VertxUtils>() {
      @Mock
      public Vertx init(VertxOptions vertxOptions) {
        return null;
      }

      @Mock
      public <VERTICLE extends AbstractVerticle> boolean blockDeploy(Vertx vertx, Class<VERTICLE> cls,
          DeploymentOptions options) throws InterruptedException {
        return true;
      }
    };
    instance.init();
  } catch (Exception e) {
    status = true;
  }
  Assert.assertFalse(status);
}
项目:grafana-vertx-datasource    文件:BitcoinAdjustedData.java   
public static void main(String... args) {

        //Note to self
        // run this demo in HA mode, deploy this verticle on a separate node and combine it with demo6

        final JsonObject config = Config.fromFile("config/demo7.json");

        VertxOptions opts = new VertxOptions().setClustered(true);
        Vertx.clusteredVertx(opts, result -> {
            if (result.succeeded()) {
                LOG.info("Cluster running");
                Vertx vertx = result.result();
                vertx.deployVerticle(BitcoinAdjustedData.class.getName(),
                                     new DeploymentOptions().setConfig(config).setWorker(false));
            } else {
                LOG.error("Clusterin failed");
                throw new RuntimeException(result.cause());
            }
        });
    }
项目:grafana-vertx-datasource    文件:JSPercentilesDatasource.java   
public static void main(String... args) {

        final JsonObject config = Config.fromFile("config/demo6.json");

        Vertx vertx = Vertx.vertx();
        vertx.deployVerticle(new JSPercentilesDatasource(), new DeploymentOptions().setConfig(config));

         /*
        Vertx vertx = Vertx.vertx();
        vertx.deployVerticle(new JSAggregateDatasource(), new DeploymentOptions().setConfig(config));
        */

        VertxOptions opts = new VertxOptions().setClustered(true);
        Vertx.clusteredVertx(opts, result -> {
            if(result.succeeded()){
                LOG.info("Cluster running");
                Vertx cvertx = result.result();
                cvertx.deployVerticle(new JSPercentilesDatasource(), new DeploymentOptions().setConfig(config));
            } else {
                LOG.error("Clustering failed");
                throw new RuntimeException(result.cause());
            }
        });
    }
项目:grafana-vertx-datasource    文件:JSAggregateDatasource.java   
public static void main(String... args) {

        final JsonObject config = Config.fromFile("config/demo6.json");

        /*
        Vertx vertx = Vertx.vertx();
        vertx.deployVerticle(new JSAggregateDatasource(), new DeploymentOptions().setConfig(config));
        */
        VertxOptions opts = new VertxOptions().setClustered(true);
        Vertx.clusteredVertx(opts, result -> {
            if(result.succeeded()){
                LOG.info("Cluster running");
                Vertx vertx = result.result();
                vertx.deployVerticle(new JSAggregateDatasource(), new DeploymentOptions().setConfig(config));
            } else {
                LOG.error("Clustering failed");
                throw new RuntimeException(result.cause());
            }
        });
    }
项目:grafana-vertx-datasource    文件:DistributedDatasource.java   
public static void main(String... args) {

        VertxOptions options = new VertxOptions().setClustered(true)
                                                 .setHAEnabled(true)
                                                 .setHAGroup("dev");
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                Vertx vertx = res.result();
                deployVerticles(vertx);

                LOG.info("Vertx Cluster running");
            } else {
                LOG.error("Creating Vertx cluster failed", res.cause());
            }
        });

    }
项目:dragoman    文件:DragomanModule.java   
@Provides
@Singleton
public Vertx provideVertx(ApplicationConfiguration applicationConfiguration) {
  VertxOptions vertxOptions =
      new VertxOptions()
          .setMaxEventLoopExecuteTime(applicationConfiguration.getMaxEventLoopExecutionTime())
          .setWarningExceptionTime(20L * 1000 * 1000000)
          .setMaxWorkerExecuteTime(applicationConfiguration.getMaxWorkerExecutionTime())
          .setWorkerPoolSize(applicationConfiguration.getWorkerPoolSize());

  // see
  // https://github.com/vert-x3/vertx-dropwizard-metrics/blob/master/src/main/asciidoc/java/index.adoc#jmx
  vertxOptions.setMetricsOptions(
      new DropwizardMetricsOptions()
          .setEnabled(applicationConfiguration.isMetricsEnabled())
          .setJmxEnabled(applicationConfiguration.isJmxEnabled())
          .setJmxDomain(applicationConfiguration.getJmxDomainName()));

  return Vertx.vertx(vertxOptions);
}
项目:redpipe    文件:Server.java   
public Single<Void> start(JsonObject defaultConfig, Class<?>... resourceOrProviderClasses){
    setupLogging();

    VertxOptions options = new VertxOptions();
    options.setWarningExceptionTime(Long.MAX_VALUE);
    vertx = Vertx.vertx(options);
    AppGlobals.init();
    AppGlobals.get().setVertx(vertx);

    // Propagate the Resteasy context on RxJava
    RxJavaHooks.setOnSingleCreate(new ResteasyContextPropagatingOnSingleCreateAction());

    return loadConfig(defaultConfig)
            .flatMap(config -> {
                return setupPlugins()
                        .flatMap(v -> setupTemplateRenderers())
                        .flatMap(v -> setupResteasy(resourceOrProviderClasses))
                        .flatMap(deployment -> {
                            setupSwagger(deployment);
                            return setupVertx(config, deployment);
                        });
            });
}
项目:vertx-zero    文件:VertxVisitor.java   
@Override
public ConcurrentMap<String, VertxOptions> visit(final String... keys)
        throws ZeroException {
    // 1. Must be the first line, fixed position.
    Ensurer.eqLength(getClass(), 0, (Object[]) keys);
    // 2. Visit the node for vertx
    final JsonObject data = this.NODE.read();
    // 3. Vertx node validation.
    final JsonObject vertxData = data.getJsonObject(KEY);
    LOGGER.info(Info.INF_B_VERIFY, KEY, getClass().getSimpleName(), vertxData);
    Fn.shuntZero(() -> Ruler.verify(KEY, vertxData), vertxData);
    // 4. Set cluster options
    this.clusterOptions = this.clusterTransformer.transform(data.getJsonObject(YKEY_CLUSTERED));
    // 5. Transfer Data
    return visit(vertxData.getJsonArray(YKEY_INSTANCE));
}
项目:vertx-zero    文件:VertxVisitor.java   
private ConcurrentMap<String, VertxOptions> visit(
        final JsonArray vertxData)
        throws ZeroException {
    final ConcurrentMap<String, VertxOptions> map =
            new ConcurrentHashMap<>();
    final boolean clustered = this.clusterOptions.isEnabled();
    Fn.etJArray(vertxData, JsonObject.class, (item, index) -> {
        // 1. Extract single
        final String name = item.getString(YKEY_NAME);
        // 2. Extract VertxOptions
        final VertxOptions options = this.transformer.transform(item);
        // 3. Check the configuration for cluster sync
        Fn.flingZero(clustered != options.isClustered(), LOGGER,
                ClusterConflictException.class,
                getClass(), name, options.toString());
        // 4. Put the options into map
        map.put(name, options);
    });
    return map;
}
项目:mbed-cloud-sdk-java    文件:TestServer.java   
public void start() {
    sdk = null;
    config = null;
    if (server == null) {
        Vertx vertx = Vertx
                .vertx(new VertxOptions().setWorkerPoolSize(40).setBlockedThreadCheckInterval(1000L * 60L * 10L)
                        .setMaxWorkerExecuteTime(1000L * 1000L * 1000L * 60L * 10L));
        HttpServerOptions options = new HttpServerOptions();
        options.setMaxInitialLineLength(HttpServerOptions.DEFAULT_MAX_INITIAL_LINE_LENGTH * 2);
        server = vertx.createHttpServer(options);
        router = Router.router(vertx);
    }
    retrieveConfig();
    if (config == null || config.isApiKeyEmpty()) {
        logError("Unable to find " + String.valueOf(ENVVAR_MBED_CLOUD_API_KEY) + " environment variable");
        System.exit(1);
    }
    defineInitialisationRoute();
    defineModuleMethodTestRoute();
    logInfo("Starting Java SDK test server on port " + String.valueOf(port) + "...");
    server.requestHandler(router::accept).listen(port);
}
项目:Elastic-Components    文件:Insert22.java   
static void main(String[] asdfasd) {
    JDBCClient jdbcClient = Test.jdbcClient("jpadb", Vertx.vertx(new VertxOptions()
        .setWorkerPoolSize(1)
        .setEventLoopPoolSize(1)
    ));

    BaseOrm baseOrm = Test.baseOrm();

    final JsonObject employee = new JsonObject(
        "{\"eid\":1201,\"ename\":\"Gopal\",\"salary\":40000.0,\"deg\":\"Technical Manager\",\"department\":{\"id\":98798079087,\"name\":\"ICT\",\"department\":{\"id\":98457984,\"name\":\"RGV\",\"department\":{\"id\":94504975049,\"name\":\"MCE\",\"department\":null,\"employee\":{\"eid\":5258,\"ename\":\"Russel\",\"salary\":52000.0,\"deg\":\"ENG\",\"department\":null,\"department2\":null,\"departments\":[{\"id\":6538921,\"name\":\"TTSK\",\"department\":{\"id\":267935328,\"name\":\"VTVG\",\"department\":null,\"employee\":null},\"employee\":null}]}},\"employee\":{\"eid\":5258,\"ename\":\"Russel\",\"salary\":52000.0,\"deg\":\"ENG\",\"department\":null,\"department2\":null,\"departments\":[{\"id\":6538921,\"name\":\"TTSK\",\"department\":{\"id\":267935328,\"name\":\"VTVG\",\"department\":null,\"employee\":null},\"employee\":null}]}},\"employee\":{\"eid\":5258,\"ename\":\"Russel\",\"salary\":52000.0,\"deg\":\"ENG\",\"department\":null,\"department2\":null,\"departments\":[{\"id\":6538921,\"name\":\"TTSK\",\"department\":{\"id\":267935328,\"name\":\"VTVG\",\"department\":null,\"employee\":null},\"employee\":null}]}},\"department2\":{\"id\":988286326887,\"name\":\"BGGV\",\"department\":{\"id\":8283175518,\"name\":\"MKLC\",\"department\":{\"id\":56165582,\"name\":\"VVKM\",\"department\":null,\"employee\":{\"eid\":2389,\"ename\":\"KOMOL\",\"salary\":8000.0,\"deg\":\"DOC\",\"department\":null,\"department2\":null,\"departments\":[]}},\"employee\":{\"eid\":5258,\"ename\":\"Russel\",\"salary\":52000.0,\"deg\":\"ENG\",\"department\":null,\"department2\":null,\"departments\":[{\"id\":6538921,\"name\":\"TTSK\",\"department\":{\"id\":267935328,\"name\":\"VTVG\",\"department\":null,\"employee\":null},\"employee\":null}]}},\"employee\":{\"eid\":5258,\"ename\":\"Russel\",\"salary\":52000.0,\"deg\":\"ENG\",\"department\":null,\"department2\":null,\"departments\":[{\"id\":6538921,\"name\":\"TTSK\",\"department\":{\"id\":267935328,\"name\":\"VTVG\",\"department\":null,\"employee\":null},\"employee\":null}]}},\"departments\":[{\"id\":98798079087,\"name\":\"ICT\",\"department\":{\"id\":98457984,\"name\":\"RGV\",\"department\":{\"id\":94504975049,\"name\":\"MCE\",\"department\":null,\"employee\":{\"eid\":5258,\"ename\":\"Russel\",\"salary\":52000.0,\"deg\":\"ENG\",\"department\":null,\"department2\":null,\"departments\":[{\"id\":6538921,\"name\":\"TTSK\",\"department\":{\"id\":267935328,\"name\":\"VTVG\",\"department\":null,\"employee\":null},\"employee\":null}]}},\"employee\":{\"eid\":5258,\"ename\":\"Russel\",\"salary\":52000.0,\"deg\":\"ENG\",\"department\":null,\"department2\":null,\"departments\":[{\"id\":6538921,\"name\":\"TTSK\",\"department\":{\"id\":267935328,\"name\":\"VTVG\",\"department\":null,\"employee\":null},\"employee\":null}]}},\"employee\":{\"eid\":5258,\"ename\":\"Russel\",\"salary\":52000.0,\"deg\":\"ENG\",\"department\":null,\"department2\":null,\"departments\":[{\"id\":6538921,\"name\":\"TTSK\",\"department\":{\"id\":267935328,\"name\":\"VTVG\",\"department\":null,\"employee\":null},\"employee\":null}]}}]}"
    );

    merge(employee);

    System.out.println(employee.encodePrettily());

    baseOrm.upsert(
        BaseOrm.UpsertParams.builder()
            .entity("employee")
            .jsonObject(employee)
            .build()
    ).mapP(Test.sqlDB()::update).then(jsonObject -> {
        System.out.println("ppp888888888888888888888888888888888888888888888888888888888888888888888");
    }).err(Throwable::printStackTrace);
}
项目:grafana-vertx-datasource    文件:BitcoinAdjustedData.java   
public static void main(String... args) {

        //Note to self
        // run this demo in HA mode, deploy this verticle on a separate node and combine it with demo6

        final JsonObject config = Config.fromFile("config/demo7.json");

        VertxOptions opts = new VertxOptions().setClustered(true);
        Vertx.clusteredVertx(opts, result -> {
            if (result.succeeded()) {
                LOG.info("Cluster running");
                Vertx vertx = result.result();
                vertx.deployVerticle(BitcoinAdjustedData.class.getName(),
                                     new DeploymentOptions().setConfig(config).setWorker(false));
            } else {
                LOG.error("Clusterin failed");
                throw new RuntimeException(result.cause());
            }
        });
    }
项目:grafana-vertx-datasource    文件:JSAggregateDatasource.java   
public static void main(String... args) {

        final JsonObject config = Config.fromFile("config/demo6.json");

        /*
        Vertx vertx = Vertx.vertx();
        vertx.deployVerticle(new JSAggregateDatasource(), new DeploymentOptions().setConfig(config));
        */
        VertxOptions opts = new VertxOptions().setClustered(true);
        Vertx.clusteredVertx(opts, result -> {
            if(result.succeeded()){
                LOG.info("Cluster running");
                Vertx vertx = result.result();
                vertx.deployVerticle(new JSAggregateDatasource(), new DeploymentOptions().setConfig(config));
            } else {
                LOG.error("Clustering failed");
                throw new RuntimeException(result.cause());
            }
        });
    }
项目:grafana-vertx-datasource    文件:DistributedDatasource.java   
public static void main(String... args) {

        VertxOptions options = new VertxOptions().setClustered(true)
                                                 .setHAEnabled(true)
                                                 .setHAGroup("dev");
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                Vertx vertx = res.result();
                deployVerticles(vertx);

                LOG.info("Vertx Cluster running");
            } else {
                LOG.error("Creating Vertx cluster failed", res.cause());
            }
        });

    }
项目:vertx-gremlin    文件:VertxGremlinServerTest.java   
@Test
    public void name() throws Exception {
        JsonObject config = new JsonObject()
            .put("gremlinServerConfigPath", "gremlin-server.yaml")
//            .put("gremlinServerConfigPath", "D:\\tg-metagraph-reposities\\vertx-gremlin\\vertx-gremlin-server\\src\\test\\resources\\gremlin-server.yaml")
            .put("eventBusAddress", "outMessage");
        DeploymentOptions options = new DeploymentOptions().setConfig(config);
        VertxOptions vertxOptions = new VertxOptions().setClustered(true);
        Vertx.clusteredVertx(vertxOptions, event -> {
            if (event.succeeded()) {
                Vertx vertx = event.result();
                vertx.deployVerticle(new VertxGremlinServer(), options);
            }
        });

        Thread.sleep(Long.MAX_VALUE);
    }
项目:vertx-infinispan    文件:InfinispanHATest.java   
@Override
protected void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> ar) {
  CountDownLatch latch = new CountDownLatch(1);
  Future<Vertx> future = Future.future();
  future.setHandler(ar);
  super.clusteredVertx(options, asyncResult -> {
    if (asyncResult.succeeded()) {
      future.complete(asyncResult.result());
    } else {
      future.fail(asyncResult.cause());
    }
    latch.countDown();
  });
  try {
    assertTrue(latch.await(2, TimeUnit.MINUTES));
  } catch (InterruptedException e) {
    fail(e.getMessage());
  }
}
项目:vaadin-vertx-samples    文件:SessionStoreAdapterUT.java   
@Test(timeout = 15000L)
public void shouldFireSessionExpiredEventForHazelcastSessionStore(TestContext context) {
    Async async = context.async();
    Vertx.clusteredVertx(new VertxOptions().setClusterManager(new HazelcastClusterManager()), res -> {

        vertx = res.result();
        SessionStore adapted = SessionStoreAdapter.adapt(vertx, ClusteredSessionStore.create(vertx));
        Session session = adapted.createSession(2000);

        sessionExpiredConsumer = SessionStoreAdapter.sessionExpiredHandler(vertx, event -> {
            context.assertEquals(session.id(), event.body());
            async.countDown();
        });
        adapted.put(session, Future.<Boolean>future().completer());
        session.put("a", "b");

    });

}
项目:statful-client-vertx    文件:HttpSenderTest.java   
/**
 * not using @junit @Before since not all tests want to the same configuration for vertx metrics.
 * Don't forget to call this in your method
 */
public void setup(boolean isDryRun, Long flushInterval, Integer flushSize) {
    StatfulMetricsOptions options = new StatfulMetricsOptions()
            .setPort(PORT)
            .setHost(HOST)
            .setDryrun(isDryRun)
            .setEnablePoolMetrics(false)
            .setMaxBufferSize(5000)
            .setToken("a token")
            .setSecure(false);

    Optional.ofNullable(flushInterval).ifPresent(options::setFlushInterval);
    Optional.ofNullable(flushSize).ifPresent(options::setFlushSize);

    this.vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(options));

    this.victim = new HttpSender(vertx, vertx.getOrCreateContext(), options);
    this.server = vertx.createHttpServer();
}
项目:vertx-infinispan    文件:InfinispanClusteredSharedCounterTest.java   
@Override
protected void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> ar) {
  CountDownLatch latch = new CountDownLatch(1);
  Future<Vertx> future = Future.future();
  future.setHandler(ar);
  super.clusteredVertx(options, asyncResult -> {
    if (asyncResult.succeeded()) {
      future.complete(asyncResult.result());
    } else {
      future.fail(asyncResult.cause());
    }
    latch.countDown();
  });
  try {
    assertTrue(latch.await(2, TimeUnit.MINUTES));
  } catch (InterruptedException e) {
    fail(e.getMessage());
  }
}
项目:statful-client-vertx    文件:StatfulMetricsFactoryImplTest.java   
@Test
public void testCreationFromFile(TestContext context) {

    Async async = context.async();
    StatfulMetricsOptions options = new StatfulMetricsOptions();
    options.setConfigPath("config/statful.json")
            // setting enabled to false, to check that the configuration available on file is used
            .setEnabled(false);

    VertxOptions vertxOptions = new VertxOptions().setMetricsOptions(options);
    Vertx vertx = Vertx.vertx(vertxOptions);

    StatfulMetricsFactoryImpl victim = new StatfulMetricsFactoryImpl();

    assertTrue(victim.metrics(vertx, vertxOptions).isEnabled());

    vertx.close(close -> async.complete());
}
项目:statful-client-vertx    文件:StatfulMetricsFactoryImplTest.java   
@Test
public void testCreationFromNonExistentFile(TestContext context) {

    Async async = context.async();
    StatfulMetricsOptions options = new StatfulMetricsOptions();
    options.setConfigPath("config/statful-not-existent.json")
            // setting enabled to false, to check that the configuration available on file is used
            .setEnabled(false);

    VertxOptions vertxOptions = new VertxOptions().setMetricsOptions(options);
    Vertx vertx = Vertx.vertx(vertxOptions);

    StatfulMetricsFactoryImpl victim = new StatfulMetricsFactoryImpl();

    try {
        victim.metrics(vertx, vertxOptions);
        context.assertTrue(false, "should never run, an exception should've been thrown");
    } catch (RuntimeException e) {
        vertx.close(close -> async.complete());
    }
}
项目:okapi    文件:DockerTest.java   
@Before
public void setUp(TestContext context) {
  Async async = context.async();
  VertxOptions options = new VertxOptions();
  options.setBlockedThreadCheckInterval(60000); // in ms
  options.setWarningExceptionTime(60000); // in ms
  vertx = Vertx.vertx(options);
  RestAssured.port = port;
  client = vertx.createHttpClient();

  checkDocker(res2 -> {
    haveDocker = res2.succeeded();
    logger.info("haveDocker = " + haveDocker);

    DeploymentOptions opt = new DeploymentOptions()
      .setConfig(new JsonObject().put("port", Integer.toString(port)));

    vertx.deployVerticle(MainVerticle.class.getName(),
      opt, res -> async.complete());
  });
}
项目:vertx-infinispan    文件:InfinispanClusteredAsyncMapTest.java   
@Override
protected void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> ar) {
  CountDownLatch latch = new CountDownLatch(1);
  Future<Vertx> future = Future.future();
  future.setHandler(ar);
  super.clusteredVertx(options, asyncResult -> {
    if (asyncResult.succeeded()) {
      future.complete(asyncResult.result());
    } else {
      future.fail(asyncResult.cause());
    }
    latch.countDown();
  });
  try {
    assertTrue(latch.await(2, TimeUnit.MINUTES));
  } catch (InterruptedException e) {
    fail(e.getMessage());
  }
}
项目:vertx-infinispan    文件:InfinispanComplexHATest.java   
@Override
protected void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> ar) {
  CountDownLatch latch = new CountDownLatch(1);
  Future<Vertx> future = Future.future();
  future.setHandler(ar);
  super.clusteredVertx(options, asyncResult -> {
    if (asyncResult.succeeded()) {
      future.complete(asyncResult.result());
    } else {
      future.fail(asyncResult.cause());
    }
    latch.countDown();
  });
  try {
    assertTrue(latch.await(2, TimeUnit.MINUTES));
  } catch (InterruptedException e) {
    fail(e.getMessage());
  }
}
项目:vertx-infinispan    文件:InfinispanFaultToleranceTest.java   
@Override
protected void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> ar) {
  CountDownLatch latch = new CountDownLatch(1);
  Future<Vertx> future = Future.future();
  future.setHandler(ar);
  super.clusteredVertx(options, asyncResult -> {
    if (asyncResult.succeeded()) {
      future.complete(asyncResult.result());
    } else {
      future.fail(asyncResult.cause());
    }
    latch.countDown();
  });
  try {
    assertTrue(latch.await(2, TimeUnit.MINUTES));
  } catch (InterruptedException e) {
    fail(e.getMessage());
  }
}
项目:vertx-infinispan    文件:InfinispanAsyncMultiMapTest.java   
@Override
protected void clusteredVertx(VertxOptions options, Handler<AsyncResult<Vertx>> ar) {
  CountDownLatch latch = new CountDownLatch(1);
  Future<Vertx> future = Future.future();
  future.setHandler(ar);
  super.clusteredVertx(options, asyncResult -> {
    if (asyncResult.succeeded()) {
      future.complete(asyncResult.result());
    } else {
      future.fail(asyncResult.cause());
    }
    latch.countDown();
  });
  try {
    assertTrue(latch.await(2, TimeUnit.MINUTES));
  } catch (InterruptedException e) {
    fail(e.getMessage());
  }
}
项目:puppy-io    文件:PuppyAppLauncher.java   
private void initVerticle(Handler<Object> handler){
    //start vert.x
    ClusterManager mgr = new HazelcastClusterManager();

    VertxOptions options = new VertxOptions().setClusterManager(mgr);
    options.setWorkerPoolSize(1000);

    Vertx.clusteredVertx(options, res -> {
      if (res.succeeded()) {

          vertx = res.result();
          vertx.eventBus().registerDefaultCodec(MessageBody.class, new MessageBodyCodec());

          AppConfig appConfig = context.getBean(AppConfig.class);
          appConfig.setVertx(vertx);
          appConfig.setAppClass(appClass);
          appConfig.setAppName(appName);

          handler.handle(1);
      } else {
          logger.error("fail clusteredVertx");
      }
    });
}
项目:vertx-spring-mongo-blog    文件:ApplicationStarter.java   
public static void main(String[] args) {
    VertxOptions options = new VertxOptions(); 
    options.setMaxEventLoopExecuteTime(Long.MAX_VALUE);
    final Vertx vertx = Vertx.factory.vertx(options);
    ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfiguration.class);

    Verticle serverVerticle =  (Verticle) context.getBean("serverVerticle");
    Verticle userDatabaseVerticle =  (Verticle) context.getBean("userDatabaseVerticle");
    Verticle blogServiceVerticle = (Verticle) context.getBean("blogServiceVerticle");

    vertx.deployVerticle(serverVerticle);
    vertx.deployVerticle(userDatabaseVerticle, new DeploymentOptions().setWorker(true));
    vertx.deployVerticle(blogServiceVerticle, new DeploymentOptions().setWorker(true));

}
项目:incubator-servicecomb-java-chassis    文件:VertxUtils.java   
public static Vertx getOrCreateVertxByName(String name, VertxOptions vertxOptions) {
  Vertx vertx = getVertxByName(name);
  if (vertx == null) {
    synchronized (VertxUtils.class) {
      vertx = getVertxByName(name);
      if (vertx == null) {
        vertx = init(name, vertxOptions);
        vertxMap.put(name, vertx);
      }
    }
  }

  return vertx;
}
项目:incubator-servicecomb-java-chassis    文件:TestVertxUtils.java   
@Test
public void testVertxUtilsInitWithOptions() {
  VertxOptions oOptions = new VertxOptions();
  oOptions.setClustered(false);

  Vertx vertx = VertxUtils.init(oOptions);
  Assert.assertNotEquals(null, vertx);
  vertx.close();
}
项目:grafana-vertx-datasource    文件:WorkerNode.java   
public static void main(String... args) {
    VertxOptions options = new VertxOptions().setClustered(true)
                                             .setHAEnabled(true)
                                             .setHAGroup("dev");
    Vertx.clusteredVertx(options, res -> {
        if (res.succeeded()) {
            Vertx vertx = res.result();
            deployVerticles(vertx);

            LOG.info("Vertx Cluster running");
        } else {
            LOG.error("Creating Vertx cluster failed", res.cause());
        }
    });
}
项目:vertx-spring    文件:SpringVertx.java   
public SpringVertx(VertxFactory factory, VertxOptions options,
                   Collection<VerticleRegistration> verticleRegistrations,
                   List<VertxListener> listeners, String verticleFactoryPrefix,
                   int startupPhase, boolean autoStartup) {
    this.factory = factory;
    this.options = new VertxOptions(options);
    this.verticleRegistrations = new ArrayList<>(verticleRegistrations);
    this.verticleFactoryPrefix = verticleFactoryPrefix;
    this.startupPhase = startupPhase;
    this.autoStartup = autoStartup;
}
项目:vertx-spring    文件:SpringVertx.java   
public Builder options(Consumer<VertxOptions> optionsSpec) {
    if (this.options == null) {
        this.options = new VertxOptions();
    }
    optionsSpec.accept(options);
    return this;
}
项目:vertx-spring    文件:VertxProperties.java   
public VertxOptions toVertxOptions() {
    VertxOptions newOptions = new VertxOptions(this.vertxOptions);

    if (addressResolver != null) {
        newOptions.setAddressResolverOptions(addressResolver.toAddressResolverOptions());
    }
    if (eventBus != null) {
        newOptions.setEventBusOptions(eventBus);
    }
    return newOptions;
}
项目:erp-frontend    文件:VertxNetworkBackend.java   
public VertxNetworkBackend () {
    this.options = new VertxOptions();

    //create new vertx.io instance
    this.vertx = Vertx.vertx(this.options);

    //set connection timeout of 1 seconds
    this.netClientOptions.setConnectTimeout(5000);

    //if connection fails, try 1x
    /*this.netClientOptions.setReconnectAttempts(5)
            .setReconnectInterval(500);*/
}
项目:app-ms    文件:ConfigurationProvider.java   
@Bean
public VertxOptions vertxOptions() {

    return new VertxOptions()
        .setWarningExceptionTime(vertxWarningExceptionTime)
        .setWorkerPoolSize(vertxWorkerPoolSize);
}
项目:app-ms    文件:EngineSampleMain.java   
public static void main(final String[] args) throws Exception {

        final VertxOptions vertOptions = new VertxOptions();
        vertOptions.setWarningExceptionTime(1);
        vertOptions.setWorkerPoolSize(50);

        final Vertx vertx = Vertx.vertx(vertOptions);
        final DeploymentOptions options = new DeploymentOptions();
        vertx.deployVerticle(new EngineSampleMain(), options);
    }
项目:app-ms    文件:VertxConfig.java   
@Bean
public VertxOptions vertxOptions(final AddressResolverOptions addressResolverOptions) {

    return new VertxOptions()
        .setAddressResolverOptions(addressResolverOptions)
        .setWarningExceptionTime(vertxWarningExceptionTime)
        .setWorkerPoolSize(vertxWorkerPoolSize);
}