Package com.vmware.bdd.software.mgmt.plugin.monitor

Examples of com.vmware.bdd.software.mgmt.plugin.monitor.StatusPoller


         apiHostInstallArguments.setUserName(usernameForHosts);
         apiHostInstallArguments.setPrivateKey(privateKey);
         apiHostInstallArguments.setParallelInstallCount(20);

         // Install CM agents. TODO: show steps msg
         StatusPoller hostInstallPoller = null;
         try {

            final ApiCommand cmd =  apiResourceRootV6.getClouderaManagerResource().hostInstallCommand(apiHostInstallArguments);
            logger.info("install command id: " + cmd.getId());
View Full Code Here


         }
      }

      // validate this cluster has access to all Parcels it requires
      executeAndReport("Validating parcels availability", addedNodes, null, ProgressSplit.VALIDATE_PARCELS_AVAILABILITY.getProgress(),
            cluster.getCurrentReport(), reportQueue, new StatusPoller() {
         @Override
         public boolean poll() {
            for (ApiParcel parcel : apiResourceRootV6.getClustersResource().getParcelsResource(cluster.getName())
                  .readParcels(DataView.FULL).getParcels()) {
               try {
                  repositoriesRequired.remove(parcel.getProduct());
               } catch (IllegalArgumentException e) {
                  // ignore
               }
            }
            // TODO: if one required parcel is not available, will run forever, need timeout/validation
            return repositoriesRequired.isEmpty();
         }
      }, false);

      apiResourceRootV6.getClouderaManagerResource().updateConfig(
            new ApiConfigList(Arrays.asList(new ApiConfig[]{new ApiConfig("PARCEL_UPDATE_FREQ", "60")})));

      DefaultArtifactVersion expectVersion = null;
      if (cluster.getFullVersion() != null) {
         expectVersion = new DefaultArtifactVersion(cluster.getFullVersion());
      }

      for (String repository : repositoriesRequiredOrdered) {
         DefaultArtifactVersion parcelVersion = null;
         for (ApiParcel apiParcel : apiResourceRootV6.getClustersResource().getParcelsResource(cluster.getName())
               .readParcels(DataView.FULL).getParcels()) {
            DefaultArtifactVersion parcelVersionTmp = new DefaultArtifactVersion(apiParcel.getVersion());
            if (apiParcel.getProduct().equals(repository)) {
               if (apiParcel.getProduct().equals(Constants.CDH_REPO_PREFIX)) {
                  /*
                   * Policy for "CDH" parcel:
                   * 1) If specify fullVersion, try to find that parcel, if cannot, select the latest parcel(with highest version).
                   * 2) If fullVersion not specified, select the latest parcel
                   */
                  if (parcelVersion == null || parcelVersion.compareTo(parcelVersionTmp) < 0) {
                     parcelVersion = new DefaultArtifactVersion(apiParcel.getVersion());
                  }
                  if (expectVersion != null && parcelVersionTmp.getMajorVersion() == expectVersion.getMajorVersion()
                        && parcelVersionTmp.getMinorVersion() == expectVersion.getMinorVersion()
                        && parcelVersionTmp.getIncrementalVersion() == expectVersion.getIncrementalVersion()) {
                     parcelVersion = new DefaultArtifactVersion(apiParcel.getVersion());
                     break;
                  }
               }

               if (!apiParcel.getProduct().equals(Constants.CDH_REPO_PREFIX)) {
                  // For non-CDH parcel, just select the latest one
                  if (parcelVersion == null || parcelVersion.compareTo(parcelVersionTmp) < 0) {
                     parcelVersion = new DefaultArtifactVersion(apiParcel.getVersion());
                  }
               }
            }
         }

         final ParcelResource apiParcelResource = apiResourceRootV6.getClustersResource()
               .getParcelsResource(cluster.getName()).getParcelResource(repository, parcelVersion.toString());
         String refMsg = referCmfUrlMsg(domain + "/cmf/parcel/status");
         if (AvailableParcelStage.valueOf(apiParcelResource.readParcel().getStage()).ordinal() < AvailableParcelStage.DOWNLOADED.ordinal()) {
            String action = "Downloading parcel...";

            ParcelProvisionPoller poll = new ParcelProvisionPoller(apiParcelResource, AvailableParcelStage.DOWNLOADED, cluster.getCurrentReport(),
                  reportQueue, ProgressSplit.DOWNLOAD_PARCEL.getProgress());

            if (apiParcelResource.readParcel().getStage().equals(AvailableParcelStage.DOWNLOADING.toString())) {
               // Another thread is downloading this parcel, just wait for its completion
               executeAndReport(action, null, ProgressSplit.DOWNLOAD_PARCEL.getProgress(),
                     cluster.getCurrentReport(), reportQueue, poll, false);
            } else {
               // the ApiCommand instance for parcel is inaccessible, so do not check the return value
               executeAndReport(action, apiParcelResource.startDownloadCommand(),
                     ProgressSplit.DOWNLOAD_PARCEL.getProgress(),
                     cluster.getCurrentReport(), reportQueue, poll, false);
            }
            if (AvailableParcelStage.valueOf(apiParcelResource.readParcel().getStage()).ordinal() < AvailableParcelStage.DOWNLOADED.ordinal()) {
               throw ClouderaManagerException.DOWNLOAD_PARCEL_FAIL(apiParcelResource.readParcel().getProduct(),
                     apiParcelResource.readParcel().getVersion(), refMsg);
            }
         }

         if (AvailableParcelStage.valueOf(apiParcelResource.readParcel().getStage()).ordinal() < AvailableParcelStage.DISTRIBUTED.ordinal()) {
            String action = "Distributing parcel...";

            final StatusPoller poller = new ParcelProvisionPoller(apiParcelResource, AvailableParcelStage.DISTRIBUTED, cluster.getCurrentReport(),
                  reportQueue, ProgressSplit.DISTRIBUTE_PARCEL.getProgress());

            executeAndReport(action, apiParcelResource.startDistributionCommand(),
                  ProgressSplit.DISTRIBUTE_PARCEL.getProgress(),
                  cluster.getCurrentReport(), reportQueue, poller, false);

            if (AvailableParcelStage.valueOf(apiParcelResource.readParcel().getStage()).ordinal() < AvailableParcelStage.DISTRIBUTED.ordinal()) {
               throw ClouderaManagerException.DISTRIBUTE_PARCEL_FAIL(apiParcelResource.readParcel().getProduct(),
                     apiParcelResource.readParcel().getVersion(), refMsg);
            }
         }
         if (AvailableParcelStage.valueOf(apiParcelResource.readParcel().getStage()).ordinal() < AvailableParcelStage.ACTIVATED.ordinal()) {
            String action = "Activating parcel...";

            executeAndReport(action, apiParcelResource.activateCommand(), ProgressSplit.ACTIVATE_PARCEL.getProgress(),
                  cluster.getCurrentReport(), reportQueue, new StatusPoller() {
               @Override
               public boolean poll() {
                  // activate parcel is pretty fast, so suppose we are no need to do much error handling/progress monitoring
                  // TODO: set a timeout
                  return apiParcelResource.readParcel().getStage().equals(AvailableParcelStage.ACTIVATED.toString());
View Full Code Here

   }

   private ApiCommand executeAndReport(String action, final List<String> nodeNames, final ApiCommand command,
         int endProgress, ClusterReport currentReport, ClusterReportQueue reportQueue, boolean checkReturn) throws Exception {
      return executeAndReport(action, nodeNames, command, endProgress, currentReport, reportQueue,
            new StatusPoller() {
               @Override
               public boolean poll() {
                  return apiResourceRootV6.getCommandsResource().readCommand(command.getId()).getEndTime() != null;
               }
            }, checkReturn);
View Full Code Here

   }

   private ApiCommand executeAndReport(String action, final ApiCommand command, int endProgress,
         ClusterReport currentReport, ClusterReportQueue reportQueue, boolean checkReturn) throws Exception {
      return executeAndReport(action, command, endProgress, currentReport, reportQueue,
            new StatusPoller() {
               @Override
               public boolean poll() {
                  return apiResourceRootV6.getCommandsResource().readCommand(command.getId()).getEndTime() != null;
               }
            }, checkReturn);
View Full Code Here

TOP

Related Classes of com.vmware.bdd.software.mgmt.plugin.monitor.StatusPoller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.