Examples of ParcelResource


Examples of com.cloudera.api.v3.ParcelResource

                  }
               }
            }
         }

         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());
               }
            }, false);

            if (AvailableParcelStage.valueOf(apiParcelResource.readParcel().getStage()).ordinal() < AvailableParcelStage.ACTIVATED.ordinal()) {
               throw ClouderaManagerException.ACTIVATE_PARCEL_FAIL(apiParcelResource.readParcel().getProduct(),
                     apiParcelResource.readParcel().getVersion(), refMsg);
            }
         }
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.