本文整理匯總了Java中io.vertx.core.Vertx.deployVerticle方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertx.deployVerticle方法的具體用法?Java Vertx.deployVerticle怎麽用?Java Vertx.deployVerticle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.core.Vertx
的用法示例。
在下文中一共展示了Vertx.deployVerticle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureRestAssured
import io.vertx.core.Vertx; //導入方法依賴的package包/類
@BeforeClass
public static void configureRestAssured() {
Vertx vertx = Vertx.vertx();
JsonObject config = new JsonObject().put("server.port", getRandomPort());
LoginHandler loginHandler = new LoginHandler();
loginHandler.setInvocationHandler(new VertxInvocationHandler(vertx));
RestVerticle restVerticle = new RestVerticle();
restVerticle.setRequestHandlers(Arrays.asList(loginHandler));
ServiceVerticle serviceVerticle = new ServiceVerticle();
serviceVerticle.setServiceHandlers(Arrays.asList(loginHandler));
DeploymentOptions options = new DeploymentOptions().setConfig(config);
vertx.deployVerticle(restVerticle, options);
vertx.deployVerticle(serviceVerticle, options);
RestAssured.baseURI = "http://localhost";
RestAssured.port = config.getInteger("server.port");
}
示例2: blockDeploy
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static <VERTICLE extends AbstractVerticle> boolean blockDeploy(Vertx vertx,
Class<VERTICLE> cls,
DeploymentOptions options) throws InterruptedException {
Holder<Boolean> result = new Holder<>();
CountDownLatch latch = new CountDownLatch(1);
vertx.deployVerticle(cls.getName(), options, ar -> {
result.value = ar.succeeded();
if (ar.failed()) {
LOGGER.error("deploy vertx failed, cause ", ar.cause());
}
latch.countDown();
});
latch.await();
return result.value;
}
示例3: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
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());
}
});
}
示例4: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static void main(String [] args) throws IOException {
Properties properties = loadProperties("config.properties");
String messagingHost = properties.getProperty("service.hostname", "messaging.enmasse.svc");
int messagingPort = Integer.parseInt(properties.getProperty("service.port", "5672"));
String username = properties.getProperty("service.username", "test");
String password = properties.getProperty("service.password", "test");
String maxAddress = properties.getProperty("address.max", "max");
String controlPrefix = properties.getProperty("address.control.prefix", "control");
int minTemp = Integer.parseInt(properties.getProperty("control.temperature.min", "15"));
int maxTemp = Integer.parseInt(properties.getProperty("control.temperature.max", "25"));
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new Thermostat(messagingHost, messagingPort, username, password, maxAddress, controlPrefix, minTemp, maxTemp));
}
示例5: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
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));
}
示例6: start
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static void start(Vertx vertx) {
DfxConfig config = DfxConfig.load(MainVerticle.conf);
vertx.deployVerticle(new PluginManagerVerticle(config), result -> {
try {
vertx.deployVerticle(new WatcherVerticle(config.getWatchCycle())
, new DeploymentOptions().setWorker(true));
} catch (IOException e) {
logger.error("An error happened during start process: {}", e);
vertx.close();
System.exit(-1);
}
});
}
示例7: testServiceAccess
import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Test
public void testServiceAccess() {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(PortfolioVerticle.class.getName());
PortfolioService proxy = ProxyHelper.createProxy(PortfolioService.class, vertx, PortfolioService.ADDRESS);
assertThat(proxy).isNotNull();
AtomicReference<Portfolio> reference = new AtomicReference<>();
proxy.getPortfolio(ar -> reference.set(ar.result()));
await().untilAtomic(reference, not(nullValue()));
vertx.close();
}
示例8: deployVerticles
import io.vertx.core.Vertx; //導入方法依賴的package包/類
private static void deployVerticles(final Vertx vertx) {
final JsonObject mongoConfig = new JsonObject().put("host", "localhost")
.put("db_name", "rtm")
.put("col_name", "measurements");
int parallelism = Runtime.getRuntime().availableProcessors() / 4;
vertx.deployVerticle(SimpleTimeSeriesVerticle.class.getName(),
new DeploymentOptions().setInstances(parallelism)
.setConfig(new JsonObject().put(ADDRESS, "/queryChunks")
.put(MONGO, mongoConfig)));
}
示例9: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
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);
}
示例10: test
import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Test
public void test() throws IOException {
byte[] bytes = Files.readAllBytes(new File("src/test/resources/config/config.json").toPath());
JsonObject config = new JsonObject(new String(bytes, "UTF-8"));
Vertx vertx = Vertx.vertx();
List<JsonObject> mch = new ArrayList<>();
List<JsonObject> dvn = new ArrayList<>();
List<JsonObject> bct = new ArrayList<>();
vertx.eventBus().consumer(GeneratorConfigVerticle.ADDRESS, message -> {
JsonObject quote = (JsonObject) message.body();
System.out.println(quote.encodePrettily());
assertThat(quote.getDouble("bid")).isGreaterThan(0);
assertThat(quote.getDouble("ask")).isGreaterThan(0);
assertThat(quote.getInteger("volume")).isGreaterThan(0);
assertThat(quote.getInteger("shares")).isGreaterThan(0);
switch (quote.getString("symbol")) {
case "MCH":
mch.add(quote);
break;
case "DVN":
dvn.add(quote);
break;
case "BCT":
bct.add(quote);
break;
}
});
vertx.deployVerticle(GeneratorConfigVerticle.class.getName(), new DeploymentOptions().setConfig(config));
await().until(() -> mch.size() > 10);
await().until(() -> dvn.size() > 10);
await().until(() -> bct.size() > 10);
}
示例11: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
// deploying Chime
vertx.deployVerticle("ceylon:herd.schedule.chime/0.2.0", res -> {
if (res.succeeded()) {
// Chime has been successfully deployed - start scheduling
scheduling(vertx);
} else {
System.out.println("Deployment failed! " + res.cause());
vertx.close();
}
});
}
示例12: deployVerticle
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static <T extends AbstractVerticle> void deployVerticle(Vertx vertx, Class<T> cls, int instanceCount) {
DeploymentOptions options = new DeploymentOptions().setInstances(instanceCount);
vertx.deployVerticle(cls.getName(), options);
}
示例13: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(Exercise6HttpVerticle.class.getName());
// Keep using the once developed previously
vertx.deployVerticle(Exercise5ProcessorVerticle.class.getName());
}
示例14: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static void main(String... args) {
final Vertx vertx = Vertx.vertx();
final JsonObject config = Config.fromFile("config/demo4.json");
vertx.deployVerticle(new AggregatingGrafanaDatasource(), new DeploymentOptions().setConfig(config));
}
示例15: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(Exercise5HttpVerticle.class.getName());
vertx.deployVerticle(Exercise5ProcessorVerticle.class.getName());
}