Skip to content

Instantly share code, notes, and snippets.

@Gsealy
Created June 21, 2018 08:44
Show Gist options
  • Save Gsealy/a11848c80df4e6ba9c436d9f0ea0f69a to your computer and use it in GitHub Desktop.
Save Gsealy/a11848c80df4e6ba9c436d9f0ea0f69a to your computer and use it in GitHub Desktop.
DeployMethod
package cn.com.infosec.vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.vertx.core.CompositeFuture;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Future;
import cn.com.infosec.vertx.common.RestfulApiVerticle;
import cn.com.infosec.vertx.http.SignServiceVerticle;
import cn.com.infosec.vertx.http.StaticServer;
import cn.com.infosec.vertx.http.ValidServiceVerticle;
import cn.com.infosec.vertx.worker.SignWorkerVerticle;
import cn.com.infosec.vertx.worker.ValidWorkerVerticle;
public class XMLVerticle extends RestfulApiVerticle {
private static final Logger LOGGER = LoggerFactory.getLogger(XMLVerticle.class);
public void start(Future<Void> startFuture) throws Exception {
DeploymentOptions serverOpts = new DeploymentOptions();
DeploymentOptions SignworkerOpts =
new DeploymentOptions().setWorker(true).setInstances(Constants.Concurrent)
.setWorkerPoolName("Sign-worker").setWorkerPoolSize(500);
DeploymentOptions StaticworkerOpts =
new DeploymentOptions().setWorker(true).setInstances(Constants.Concurrent)
.setWorkerPoolName("Static-worker").setWorkerPoolSize(500);
DeploymentOptions ValidworkerOpts =
new DeploymentOptions().setWorker(true).setInstances(Constants.Concurrent)
.setWorkerPoolName("Valid-worker").setWorkerPoolSize(500);
CompositeFuture.all(deploy(SignServiceVerticle.class.getName(), serverOpts),
deploy(ValidServiceVerticle.class.getName(), serverOpts),
deploy(StaticServer.class.getName(), StaticworkerOpts),
deploy(SignWorkerVerticle.class.getName(), SignworkerOpts),
deploy(ValidWorkerVerticle.class.getName(), ValidworkerOpts)).setHandler(res -> {
if (res.succeeded()) {
startFuture.complete();
} else {
startFuture.fail(res.cause());
}
});
}
private Future<Void> deploy(String name, DeploymentOptions opts) {
Future<Void> future = Future.future();
vertx.deployVerticle(name, opts, res -> {
if (res.succeeded()) {
LOGGER.debug("Deployed verticle {}", name);
future.complete();
} else {
LOGGER.error("Failed to deploy verticle " + name);
future.fail(res.cause());
}
});
return future;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment