Beispiel #1
0
 /** DNodes are informed to stop the deployment, as something failed. */
 public void abortDeploy(List<String> dnodes, long version) {
   for (String dnode : dnodes) {
     DNodeService.Client client = null;
     try {
       client = context.getDNodeClient(dnode, false);
       client.abortDeploy(version);
     } catch (Exception e) {
       log.error("Error sending abort deploy flag to DNode [" + dnode + "]", e);
     } finally {
       if (client != null) {
         client.getOutputProtocol().getTransport().close();
       }
     }
   }
   CoordinationStructures.DEPLOY_IN_PROGRESS.decrementAndGet();
 }
Beispiel #2
0
  /**
   * Call this method for starting an asynchronous deployment given a proper deploy request - proxy
   * method for {@link QNodeHandler}. Returns a {@link QueryStatus} with the status of the request.
   */
  public DeployInfo deploy(List<DeployRequest> deployRequests) {

    // A new unique version number is generated.
    long version = context.getCoordinationStructures().uniqueVersionId();

    // Generate the list of actions per DNode
    Map<String, List<DeployAction>> actionsPerDNode =
        generateDeployActionsPerDNode(deployRequests, version);

    // Starting the countdown latch.
    ICountDownLatch countDownLatchForDeploy =
        context.getCoordinationStructures().getCountDownLatchForDeploy(version);
    Set<String> dnodesInvolved = actionsPerDNode.keySet();
    countDownLatchForDeploy.setCount(dnodesInvolved.size());

    // Sending deploy signals to each DNode
    for (Map.Entry<String, List<DeployAction>> actionPerDNode : actionsPerDNode.entrySet()) {
      DNodeService.Client client = null;
      try {
        client = context.getDNodeClient(actionPerDNode.getKey(), false);
        client.deploy(actionPerDNode.getValue(), version);
      } catch (Exception e) {
        log.error("Error sending deploy actions to DNode [" + actionPerDNode.getKey() + "]", e);
        abortDeploy(new ArrayList<String>(actionsPerDNode.keySet()), version);
        DeployInfo errDeployInfo = new DeployInfo();
        errDeployInfo.setError("Error connecting to DNode " + actionPerDNode.getKey());
        return errDeployInfo;
      } finally {
        client.getOutputProtocol().getTransport().close();
      }
    }

    // Initiating an asynchronous process to manage the deployment
    deployThread.execute(
        new ManageDeploy(
            new ArrayList(actionsPerDNode.keySet()),
            deployRequests,
            version,
            context.getConfig().getLong(QNodeProperties.DEPLOY_TIMEOUT, -1),
            context.getConfig().getLong(QNodeProperties.DEPLOY_SECONDS_TO_CHECK_ERROR)));

    DeployInfo deployInfo = new DeployInfo();
    deployInfo.setVersion(version);
    deployInfo.setStartedAt(SimpleDateFormat.getInstance().format(new Date()));
    return deployInfo;
  }