本文整理匯總了Java中io.vertx.core.DeploymentOptions類的典型用法代碼示例。如果您正苦於以下問題:Java DeploymentOptions類的具體用法?Java DeploymentOptions怎麽用?Java DeploymentOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DeploymentOptions類屬於io.vertx.core包,在下文中一共展示了DeploymentOptions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepare
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
@Before
public void prepare(TestContext context) {
vertx = Vertx.vertx();
JsonObject dbConf = new JsonObject()
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:mem:testdb;shutdown=true")
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 4);
vertx.deployVerticle(new WikiDatabaseVerticle(),
new DeploymentOptions().setConfig(dbConf), context.asyncAssertSuccess());
vertx.deployVerticle(new HttpServerVerticle(), context.asyncAssertSuccess());
webClient = WebClient.create(vertx, new WebClientOptions()
.setDefaultHost("localhost")
.setDefaultPort(8080)
.setSsl(true)
.setTrustOptions(new JksOptions().setPath("server-keystore.jks").setPassword("secret")));
}
示例2: prepare
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
@Before
public void prepare(TestContext context) {
vertx = Vertx.vertx();
JsonObject dbConf = new JsonObject()
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:mem:testdb;shutdown=true")
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 4);
vertx.deployVerticle(new WikiDatabaseVerticle(),
new DeploymentOptions().setConfig(dbConf), context.asyncAssertSuccess());
vertx.deployVerticle(new HttpServerVerticle(), context.asyncAssertSuccess());
// tag::test-https[]
webClient = WebClient.create(vertx, new WebClientOptions()
.setDefaultHost("localhost")
.setDefaultPort(8080)
.setSsl(true) // <1>
.setTrustOptions(new JksOptions().setPath("server-keystore.jks").setPassword("secret"))); // <2>
// end::test-https[]
}
示例3: testInit
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
@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);
}
示例4: start
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
@Override
public void start(Future<Void> startFuture) throws Exception {
Future<String> dbVerticleDeployment = Future.future();
vertx.deployVerticle(new WikiDatabaseVerticle(), dbVerticleDeployment.completer());
dbVerticleDeployment.compose(id -> {
Future<String> httpVerticleDeployment = Future.future();
vertx.deployVerticle(
"io.vertx.guides.wiki.http.HttpServerVerticle",
new DeploymentOptions().setInstances(2),
httpVerticleDeployment.completer());
return httpVerticleDeployment;
}).setHandler(ar -> {
if (ar.succeeded()) {
startFuture.complete();
} else {
startFuture.fail(ar.cause());
}
});
}
示例5: main
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
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());
}
});
}
示例6: main
import io.vertx.core.DeploymentOptions; //導入依賴的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());
}
});
}
示例7: main
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
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());
}
});
}
示例8: start
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
@Override
public void start() throws Exception {
JsonObject config = Vertx.currentContext().config();
DeploymentOptions opts = new DeploymentOptions().setConfig(config);
DeploymentOptions chunkOpts = new DeploymentOptions().setConfig(config.copy().put(ADDRESS, "/queryChunk"))
//.setInstances(config.getInteger(PARALLELISM))
//.setWorker(true)
;
vertx.deployVerticle("js:io/devcon5/metrics/demo6/AggregateTimeSeriesVerticle.js",chunkOpts, result -> {
if (result.succeeded()) {
LOG.info("JS Verticle successfully deployed {}", result.result());
} else {
LOG.error("Failed to deploy JS Verticle", result.cause());
}
});
vertx.deployVerticle(SplitMergeTimeSeriesVerticle.class.getName(), opts);
vertx.deployVerticle(AnnotationVerticle.class.getName(), opts);
vertx.deployVerticle(LabelVerticle.class.getName(), opts);
vertx.deployVerticle(HttpServerVerticle.class.getName(), opts);
}
示例9: start
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
@Override
public void start() throws Exception {
JsonObject config = Vertx.currentContext().config();
DeploymentOptions opts = new DeploymentOptions().setConfig(config);
DeploymentOptions chunkOpts = new DeploymentOptions().setInstances(config.getInteger(PARALLELISM))
.setWorker(true)
.setConfig(config.copy().put(ADDRESS, "/queryChunk"));
//this verticle is doing the "post-processing"
vertx.deployVerticle(PercentilesVerticle.class.getName(),chunkOpts);
//the other verticles
vertx.deployVerticle(SplitMergeTimeSeriesVerticle.class.getName(), opts);
vertx.deployVerticle(AnnotationVerticle.class.getName(), opts);
vertx.deployVerticle(LabelVerticle.class.getName(), opts);
vertx.deployVerticle(HttpServerVerticle.class.getName(), opts);
}
示例10: provideDeploymentOptions
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
@Provides
@Singleton
public DeploymentOptions provideDeploymentOptions(
ApplicationConfiguration applicationConfiguration) {
// Vert.x is a non-blocking event-loop based framework; it does not follow the approach of 1
// connection -> 1
// thread instead since each request is handled in a request-calback-response fashion the event
// loop is (or
// should be) ~immediately available to handle the next request so want to accept the default
// since this
// indicates conformance with the Vert.x approach or to put it another way we want non
// conformance to be made
// obvious so that we can fix it rather than for it to be hidden behind tweaked thread pools
// Note: since Guice is creating the verticles for us we cannot set instances > 1, this _may_ be
// reconsidered later ...
return new DeploymentOptions().setWorkerPoolName("vertx-worker").setInstances(1);
}
示例11: start
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
@BeforeAll
public static void start() {
port = getFreePort();
httpDataProvider = mock(HttpDataProvider.class);
logger.info("Starting embedded HTTP server on port: {}", port);
vertx = Vertx.vertx();
DeploymentOptions options =
new DeploymentOptions().setConfig(new JsonObject().put("http.port", port)).setInstances(1);
CountDownLatch latch = new CountDownLatch(1);
vertx.deployVerticle(
new HttpServerSimulatorVerticle(httpDataProvider),
options,
result -> {
logger.info("Started embedded HTTP server with result: {}", result);
latch.countDown();
});
try {
latch.await();
} catch (InterruptedException e) {
logger.warn("Failed to wait for the embedded HTTP server to start!");
}
}
示例12: redeployVerticles
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
private void redeployVerticles(DeploymentOptions options){
Future<String> future1 = undeployVerticles();
future1.compose(s1 -> {
Future<String> future2 = deployVerticles(options);
future2.setHandler(handler -> {
if (handler.succeeded()) {
System.out.println("Redployment successful!");
} else {
System.err.println("Redeployment failed: " + handler.cause().getMessage());
}
});
}, Future.future().setHandler(handler -> {
System.err.println("Redeployment failed: " + handler.cause().getMessage());
}));
}
示例13: deployVerticles
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
private Future<String> deployVerticles(DeploymentOptions options){
Future<String> future = Future.future();
Future<String> future1 = deployOrderBookVerticle(options);
future1.compose(s1 -> {
Future<String> future2 = deployPriceVerticle(options);
// Define future2 composition
future2.compose(s2 -> {
// Because the future3 is the last, we define here a handler
Future<String> future3 = deployWebSocketVerticle(options);
future3.setHandler(handler -> {
if (handler.succeeded()) {
System.out.println("Deployment successful!");
future.complete("Deployment successful!");
} else {
System.err.println("Deployment failed: " + handler.cause().getMessage());
future.fail(handler.cause().getMessage());
}
});
} , Future.future().setHandler(handler -> {
System.err.println("Deployment failed: " + handler.cause().getMessage());
future.fail(handler.cause().getMessage());
}));
}, Future.future().setHandler(handler -> {
System.err.println("Deployment failed: " + handler.cause().getMessage());
future.fail(handler.cause().getMessage());
}));
return future;
}
示例14: deployPriceVerticle
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
private Future<String> deployPriceVerticle(DeploymentOptions options) {
Future<String> future = Future.future();
vertx.deployVerticle(new BittrexPriceVerticle(service), options, res -> {
if (res.succeeded()) {
p_id = res.result();
System.out.println("PriceVerticle Deployment id is: " + res.result());
future.complete();
} else {
System.err.println("PriceVerticle Deployment failed: " + res.cause().getMessage());
future.fail(res.cause());
}
});
return future;
}
示例15: fromJson
import io.vertx.core.DeploymentOptions; //導入依賴的package包/類
/**
* Populates this object with the information from the supplied JsonObject
* @param json The JSON Object
*/
public void fromJson(JsonObject json) {
Objects.requireNonNull(json, "json is required");
if (json.getValue("name") instanceof String)
setName((String) json.getValue("name"));
if (json.getValue("deploymentOptions") instanceof JsonObject) {
setDeploymentOptions(new DeploymentOptions());
DeploymentOptionsConverter.fromJson((JsonObject) json.getValue("deploymentOptions"), this.getDeploymentOptions());
}
if (json.getValue("dependents") instanceof JsonArray) {
json.getJsonArray("dependents").forEach(item -> {
if (item instanceof JsonObject) {
DependentsDeployment deps = new DependentsDeployment();
deps.fromJson((JsonObject) item);
getDependents().add(deps);
}
});
}
}