Exemplo n.º 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);
         }
       }
     }
   }
 }
Exemplo n.º 2
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());
   }
 }