-
Notifications
You must be signed in to change notification settings - Fork 5
/
VerticleDeployer.java
43 lines (35 loc) · 1.43 KB
/
VerticleDeployer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.genericsystem.watch;
import java.nio.file.Paths;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Future;
import io.vertx.core.Verticle;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager;
public class VerticleDeployer extends AbstractVerticle {
public static final String PDF_WATCHER_ADDRESS = "app.pdfchanges";
public static final String PNG_WATCHER_ADDRESS = "app.pngchanges";
public static final String IMAGE_ADDED_TO_CLASS_ADDRESS = "app.class.newimage";
public static void deployVerticle(Verticle verticle) {
ClusterManager mgr = new HazelcastClusterManager();
VertxOptions vertxOptions = new VertxOptions().setClustered(true).setClusterManager(mgr);
Vertx.clusteredVertx(vertxOptions, res -> {
if (res.succeeded()) {
Vertx vertx = res.result();
vertx.deployVerticle(verticle, new DeploymentOptions());
} else {
throw new IllegalStateException(res.cause());
}
});
}
@Override
public void start(Future<Void> startFuture) throws Exception {
vertx.deployVerticle(new DirectoryWatcherVerticle(Paths.get("..", "gs-cv", "pdf"), PDF_WATCHER_ADDRESS));
vertx.deployVerticle(new PdfsConverterVerticle());
vertx.deployVerticle(new ClassifierVerticle());
vertx.deployVerticle(new RunScriptVerticle());
startFuture.complete();
}
}