Пример #1
0
 // Undeploy any HA deploymentIDs now there is no quorum
 private void undeployHADeployments() {
   for (String deploymentID : deploymentManager.deployments()) {
     Deployment dep = deploymentManager.getDeployment(deploymentID);
     if (dep != null) {
       if (dep.deploymentOptions().isHa()) {
         ContextImpl ctx = vertx.getContext();
         try {
           ContextImpl.setContext(null);
           deploymentManager.undeployVerticle(
               deploymentID,
               result -> {
                 if (result.succeeded()) {
                   log.info(
                       "Successfully undeployed HA deployment "
                           + deploymentID
                           + "-"
                           + dep.verticleIdentifier()
                           + " as there is no quorum");
                   addToHADeployList(
                       dep.verticleIdentifier(),
                       dep.deploymentOptions(),
                       result1 -> {
                         if (result1.succeeded()) {
                           log.info(
                               "Successfully redeployed verticle "
                                   + dep.verticleIdentifier()
                                   + " after quorum was re-attained");
                         } else {
                           log.error(
                               "Failed to redeploy verticle "
                                   + dep.verticleIdentifier()
                                   + " after quorum was re-attained",
                               result1.cause());
                         }
                       });
                 } else {
                   log.error("Failed to undeploy deployment on lost quorum", result.cause());
                 }
               });
         } finally {
           ContextImpl.setContext(ctx);
         }
       }
     }
   }
 }
Пример #2
0
 private void doDeployVerticle(
     final String verticleName,
     DeploymentOptions deploymentOptions,
     final Handler<AsyncResult<String>> doneHandler) {
   final Handler<AsyncResult<String>> wrappedHandler =
       asyncResult -> {
         if (asyncResult.succeeded()) {
           // Tell the other nodes of the cluster about the verticle for HA purposes
           addToHA(asyncResult.result(), verticleName, deploymentOptions);
         }
         if (doneHandler != null) {
           doneHandler.handle(asyncResult);
         } else if (asyncResult.failed()) {
           log.error("Failed to deploy verticle", asyncResult.cause());
         }
       };
   deploymentManager.deployVerticle(verticleName, deploymentOptions, wrappedHandler);
 }
Пример #3
0
 // Remove the information on the deployment from the cluster - this is called when an HA module is
 // undeployed
 public void removeFromHA(String depID) {
   Deployment dep = deploymentManager.getDeployment(depID);
   if (dep == null || !dep.deploymentOptions().isHa()) {
     return;
   }
   synchronized (haInfo) {
     JsonArray haMods = haInfo.getJsonArray("verticles");
     Iterator<Object> iter = haMods.iterator();
     while (iter.hasNext()) {
       Object obj = iter.next();
       JsonObject mod = (JsonObject) obj;
       if (mod.getString("dep_id").equals(depID)) {
         iter.remove();
       }
     }
     clusterMap.put(nodeID, haInfo.encode());
   }
 }