Interesting, I can't seem to find a PlatformManager in the latest Vert.x 4 codebase. That looks like old Vert.x 3 documentation. I have found Vert.x deployed many different ways to be very scalable:
DeploymentOptions deploymentOptions = new DeploymentOptions();
deploymentOptions.setInstances(siteInstances);
vertx.deployVerticle(MainVerticle.class, deploymentOptions).onSuccess(a -> {
LOG.info("Started main verticle. ");
I always integrate a Zookeeper Cluster Manager as well, so that I can scale the number of container pods up, and the requests are load balanced between the pods, and background tasks can also share the load of a long running task by sending events on the event bus to be processed by multiple pods:
if(enableZookeeperCluster) {
Vertx.clusteredVertx(vertxOptions).onSuccess(vertx -> {
runner.accept(vertx);
promise.complete();
}).onFailure(ex -> {
LOG.error("Creating clustered Vertx failed. ", ex);
promise.fail(ex);
});
} else {
Vertx vertx = Vertx.vertx(vertxOptions);
runner.accept(vertx);
promise.complete();
}
source:
git:
uri: '{{ SITE_REPO_HTTPS }}'
type: Git
strategy:
sourceStrategy:
from:
kind: ImageStreamTag
name: 'java:latest'
namespace: openshift
type: Source
Then my DeploymentConfig references the ImageStreamTag
triggers:
- imageChangeParams:
automatic: true
containerNames:
- {{ SITE_NAME }}
from:
kind: ImageStreamTag
name: '{{ SITE_NAME }}:latest'
namespace: "{{ SITE_NAMESPACE }}"
type: ImageChange
- type: ConfigChange
I specify the zookeeper cluster configuration as environment variables, especially the CLUSTER_HOST_NAME and CLUSTER_PUBLIC_HOST_NAME I get automatically from a fieldRef provided by OpenShift so that the pods can cluster together properly. I provide the JAVA_MAIN_CLASS which tells the java:latest image what to run, and I can specify the number of SITE_INSTANCES and WORKER_POOL_SIZE as well for when I create the verticle. Then I can scale both the number of pods in the cluster, and the number of instances per pod:
- name: OPENSHIFT_SERVICE
value: smart-village-view
- name: CLUSTER_PORT
value: '8081'
- name: ZOOKEEPER_HOST_NAME
value: zookeeper.smart-village-view.svc
- name: ZOOKEEPER_PORT
value: '2181'
- name: CLUSTER_HOST_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: CLUSTER_PUBLIC_HOST_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: JAVA_MAIN_CLASS
value: org.curriki.api.enus.vertx.MainVerticle
- name: SITE_INSTANCES
value: '2'
- name: WORKER_POOL_SIZE
value: '2'
Hope that helps!
Christopher Tate