use of io.vertx.core.Vertx in project chuidiang-ejemplos by chuidiang.
the class VertxMain method main.
public static void main(String[] args) {
Vertx vertx = Vertx.factory.vertx();
vertx.deployVerticle(new Verticle1());
vertx.deployVerticle(new Verticle2());
vertx.deployVerticle(new WebServerVerticle());
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class ComplexHATest method undeployRandomVerticles.
protected void undeployRandomVerticles(Runnable runner) {
int toUndeploy = 0;
AtomicInteger undeployCount = new AtomicInteger();
for (int pos : aliveNodes) {
Vertx v = vertices[pos];
int deployedNum = v.deploymentIDs().size();
int numToUnDeploy = random.nextInt(deployedNum + 1);
List<String> deployed = new ArrayList<>(v.deploymentIDs());
int ii = pos;
for (int j = 0; j < numToUnDeploy; j++) {
int depPos = random.nextInt(deployed.size());
String depID = deployed.remove(depPos);
toUndeploy++;
v.undeploy(depID, onSuccess(d -> {
undeployCount.incrementAndGet();
}));
}
}
int totUndeployed = toUndeploy;
eventLoopWaitUntil(() -> totUndeployed == undeployCount.get(), () -> {
totDeployed -= totUndeployed;
runner.run();
});
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class LauncherExtensibilityTest method testThatCustomLauncherCanUpdateConfigurationWhenNoneArePassed.
@Test
public void testThatCustomLauncherCanUpdateConfigurationWhenNoneArePassed() throws IOException {
long time = System.nanoTime();
Launcher myLauncher = new Launcher() {
@Override
protected String getMainVerticle() {
return HttpTestVerticle.class.getName();
}
@Override
public void afterStartingVertx(Vertx vertx) {
LauncherExtensibilityTest.this.vertx = vertx;
}
@Override
public void afterConfigParsed(JsonObject config) {
config.put("time", time);
}
};
myLauncher.dispatch(new String[0]);
waitUntil(() -> {
try {
return RunCommandTest.getHttpCode() == 200;
} catch (IOException e) {
return false;
}
});
assertThat(RunCommandTest.getContent().getJsonObject("conf").getLong("time")).isEqualTo(time);
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class LauncherExtensibilityTest method testThatCustomLauncherCanUpdateConfiguration.
@Test
public void testThatCustomLauncherCanUpdateConfiguration() throws IOException {
long time = System.nanoTime();
Launcher myLauncher = new Launcher() {
@Override
protected String getMainVerticle() {
return HttpTestVerticle.class.getName();
}
@Override
public void afterStartingVertx(Vertx vertx) {
LauncherExtensibilityTest.this.vertx = vertx;
}
@Override
public void afterConfigParsed(JsonObject config) {
config.put("time", time);
}
};
myLauncher.dispatch(new String[] { "-conf=\"{\"time\":345667}" });
waitUntil(() -> {
try {
return RunCommandTest.getHttpCode() == 200;
} catch (IOException e) {
return false;
}
});
assertThat(RunCommandTest.getContent().getJsonObject("conf").getLong("time")).isEqualTo(time);
}
use of io.vertx.core.Vertx in project vert.x by eclipse.
the class RedeployTest method tearDown.
@After
public void tearDown() throws InterruptedException {
super.tearDown();
final RunCommand run = (RunCommand) cli.getExistingCommandInstance("run");
if (run != null) {
Vertx vertx = run.vertx;
close(vertx);
run.stopBackgroundApplication(null);
run.shutdownRedeployment();
}
FakeClusterManager.reset();
waitForTermination();
}
Aggregations