Esempio n. 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();
 }
Esempio n. 2
0
    @Override
    public void run() {
      log.info(
          context.getConfig().getProperty(QNodeProperties.PORT)
              + " Executing deploy for version ["
              + version
              + "]");
      CoordinationStructures.DEPLOY_IN_PROGRESS.incrementAndGet();
      try {
        long waitSeconds = 0;
        ICountDownLatch countDownLatchForDeploy =
            context.getCoordinationStructures().getCountDownLatchForDeploy(version);
        boolean finished;
        do {
          finished =
              countDownLatchForDeploy.await(secondsToCheckFailureOrTimeout, TimeUnit.SECONDS);
          waitSeconds += secondsToCheckFailureOrTimeout;
          if (!finished) {
            // If any of the DNodes failed, then we cancel the deployment.
            if (checkForFailure()) {
              explainErrors();
              abortDeploy(dnodes, version);
              return;
            }
            // Let's see if we reached the timeout.
            // Negative timeoutSeconds => waits forever
            if (waitSeconds > timeoutSeconds && timeoutSeconds >= 0) {
              log.warn(
                  "Deploy of version ["
                      + version
                      + "] timed out. Reached ["
                      + waitSeconds
                      + "] seconds.");
              abortDeploy(dnodes, version);
              return;
            }
          }
        } while (!finished);

        log.info(
            "All DNodes performed the deploy of version ["
                + version
                + "]. Publishing tablespaces...");

        // We finish by publishing the versions table with the new versions.
        try {
          switchVersions(switchActions());
        } catch (UnexistingVersion e) {
          throw new RuntimeException(
              "Unexisting version after deploying this version. Sounds like a bug.", e);
        }

        log.info("Deploy of version [" + version + "] Finished PROPERLY. :-)");

        // After a deploy we must synchronize tablespace versions to see if we have to remove some.
        context.synchronizeTablespaceVersions();

        CoordinationStructures.DEPLOY_IN_PROGRESS.decrementAndGet();
      } catch (MemberLeftException e) {
        log.error("Error while deploying version [" + version + "]", e);
        abortDeploy(dnodes, version);
      } catch (InstanceDestroyedException e) {
        log.error("Error while deploying version [" + version + "]", e);
        abortDeploy(dnodes, version);
      } catch (InterruptedException e) {
        log.error("Error while deploying version [" + version + "]", e);
        abortDeploy(dnodes, version);
      } catch (Throwable t) {
        t.printStackTrace();
        throw new RuntimeException(t);
      }
    }