List of usage examples for io.vertx.core VertxOptions setClusterHost
@Deprecated
public VertxOptions setClusterHost(String clusterHost)
From source file:com.consol.citrus.vertx.factory.AbstractVertxInstanceFactory.java
License:Apache License
/** * Creates new Vert.x instance with default factory. Subclasses may overwrite this * method in order to provide special Vert.x instance. * @return//w ww. j a v a 2 s.co m */ protected Vertx createVertx(VertxEndpointConfiguration endpointConfiguration) { final Vertx[] vertx = new Vertx[1]; final Future loading = new FutureFactoryImpl().future(); Handler<AsyncResult<Vertx>> asyncLoadingHandler = new Handler<AsyncResult<Vertx>>() { @Override public void handle(AsyncResult<Vertx> event) { vertx[0] = event.result(); loading.complete(); log.info("Vert.x instance started"); } }; if (endpointConfiguration.getPort() > 0) { if (log.isDebugEnabled()) { log.debug(String.format("Creating new Vert.x instance '%s:%s' ...", endpointConfiguration.getHost(), endpointConfiguration.getPort())); } VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setClusterPort(endpointConfiguration.getPort()); vertxOptions.setClusterHost(endpointConfiguration.getHost()); vertxFactory.clusteredVertx(vertxOptions, asyncLoadingHandler); } else { if (log.isDebugEnabled()) { log.debug(String.format("Creating new Vert.x instance '%s:%s' ...", endpointConfiguration.getHost(), 0L)); } VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setClusterPort(0); vertxOptions.setClusterHost(endpointConfiguration.getHost()); vertxFactory.clusteredVertx(vertxOptions, asyncLoadingHandler); } // Wait for full loading while (!loading.isComplete()) { try { log.debug("Waiting for Vert.x instance to startup"); Thread.sleep(250L); } catch (InterruptedException e) { log.warn("Interrupted while waiting for Vert.x instance startup", e); } } return vertx[0]; }
From source file:es.upv.grycap.opengateway.core.OgDaemon.java
License:Apache License
/** * Reads configuration properties and creates the options for the Vert.x server. * @param clustered - set to <tt>true</tt> to create a clustered server * @return Configuration options for the Vert.x server. *///from ww w . j a v a2s.c o m protected VertxOptions createVertxOptions(final boolean clustered) { requireNonNull(config); final VertxOptions vertxOptions = new VertxOptions().setClustered(clustered); if (clustered) { vertxOptions.setClusterHost(config.getString("opengateway.cluster.network")); } return vertxOptions; }
From source file:io.gravitee.am.gateway.handler.vertx.RxVertxTestBase.java
License:Apache License
protected void startNodes(int numNodes, VertxOptions options) { CountDownLatch latch = new CountDownLatch(numNodes); vertices = new Vertx[numNodes]; for (int i = 0; i < numNodes; i++) { int index = i; clusteredVertx(options.setClusterHost("localhost").setClusterPort(0).setClustered(true) .setClusterManager(getClusterManager()), ar -> { try { if (ar.failed()) { ar.cause().printStackTrace(); }//from www . j a v a2 s .c om assertTrue("Failed to start node", ar.succeeded()); vertices[index] = ar.result(); } finally { latch.countDown(); } }); } try { assertTrue(latch.await(2, TimeUnit.MINUTES)); } catch (InterruptedException e) { fail(e.getMessage()); } }
From source file:net.kuujo.copycat.vertx.VertxEventBusProtocol.java
License:Apache License
/** * Creates a Vert.x instance./*ww w. j av a 2 s.co m*/ */ private Vertx createVertx() { VertxOptions options = new VertxOptions(); options.setClusterPort(getPort()); options.setClusterHost(getHost()); Vertx vertx = Vertx.vertx(options); setVertx(vertx); return vertx; }
From source file:scp.targets.vertx.CommunicationManagerImpl.java
License:Open Source License
/** * Instantiates a new Communication manager impl based on clustered Vertx instance. * * @param port the port. If this argument is 0, then the system will pick the port. * @param hostname the hostname//from www .ja v a2s .com */ public CommunicationManagerImpl(int port, String hostname) { final Semaphore _sem = new Semaphore(0); final Handler<AsyncResult<Vertx>> _handler = event -> { try { if (event.succeeded()) { LOGGER.info("Vertx creation succeeded"); CommunicationManagerImpl.this.vertx = event.result(); } else { LOGGER.error("Vertx creation failed"); throw new RuntimeException("Could not initialize Communication manager", event.cause()); } } finally { _sem.release(); } }; final VertxOptions _opt = new VertxOptions(); _opt.setClustered(true); _opt.setClusterHost(hostname); _opt.setClusterPort(port); Vertx.clusteredVertx(_opt, _handler); try { _sem.acquire(); } catch (final InterruptedException _e) { final String _msg = "Why did the semaphore encountered InterruptedException?"; LOGGER.error(_msg, _e); throw new RuntimeException(_msg, _e); } assert this.vertx != null; }
From source file:ufo.remote.calls.benchmark.server.vertx.VertxServiceImpl.java
License:Apache License
@PostConstruct public void init() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); final VertxOptions options = new VertxOptions(); final Config conf = new Config(); Vertx.clusteredVertx(options.setClusterHost("localhost").setClusterPort(0).setClustered(true) .setClusterManager(new HazelcastClusterManager(conf)), ar -> { if (ar.failed()) { logger.error("Error starting Vertx cluster", ar.cause()); }/*from w ww.ja va2 s . c o m*/ logger.info("Vertx cluster node started [{}]"); vertx = ar.result(); logger.info("Initialising vertx verticles..."); vertx.deployVerticle(webServerVerticle); latch.countDown(); }); latch.await(); }