Package com.vmware.bdd.plugin.ambari.api.model.cluster

Examples of com.vmware.bdd.plugin.ambari.api.model.cluster.ApiRequest


      if (componentNames.isEmpty()) {
         logger.debug("Client only roles installed.");
         return true;
      }
      logger.debug("Starting roles: " + componentNames);
      ApiRequest apiRequestSummary =
            apiManager.startComponents(clusterDef.getName(), targetHostNames,
                  componentNames);
      ClusterOperationPoller poller =
            new ClusterOperationPoller(apiManager, apiRequestSummary,
                  clusterDef.getName(), clusterDef.getCurrentReport(), reports,
                  ProgressSplit.PROVISION_SUCCESS.getProgress());
      poller.waitForComplete();

      boolean success = false;
      ApiRequest apiRequest =
            apiManager.getRequest(clusterDef.getName(), apiRequestSummary
                  .getApiRequestInfo().getRequestId());
      ClusterRequestStatus clusterRequestStatus =
            ClusterRequestStatus.valueOf(apiRequest.getApiRequestInfo()
                  .getRequestStatus());
      if (!clusterRequestStatus.isFailedState()) {
         success = true;
      }
      if (!success) {
View Full Code Here


   private boolean installComponents(AmClusterDef clusterDef,
         ClusterReportQueue reports, ApiHostComponents apiHostComponents,
         List<String> targetHostNames) throws Exception {
      // add components to target hosts concurrently
      apiManager.addComponents(clusterDef.getName(), targetHostNames, apiHostComponents);
      ApiRequest request = apiManager.installComponents(clusterDef.getName());
      ClusterOperationPoller poller =
            new ClusterOperationPoller(apiManager, request,
                  clusterDef.getName(), clusterDef.getCurrentReport(), reports,
                  ProgressSplit.PROVISION_CLUSTER.getProgress());
      poller.waitForComplete();

      boolean success = false;
      ApiRequest apiRequest =
            apiManager.getRequest(clusterDef.getName(), request
                  .getApiRequestInfo().getRequestId());
      ClusterRequestStatus clusterRequestStatus =
            ClusterRequestStatus.valueOf(apiRequest.getApiRequestInfo()
                  .getRequestStatus());
      if (!clusterRequestStatus.isFailedState()) {
         success = true;
      }
      if (!success) {
View Full Code Here

      //TODO(qjin): find out the root cause of failure in startting services
      Exception resultException = null;
      try {
         ReflectionUtils.getPreStartServicesHook().preStartServices(clusterName, 120);
         for (int i = 0; i < getRequestMaxRetryTimes(); i++) {
            ApiRequest apiRequestSummary;
            try {
               apiRequestSummary = apiManager.startAllServicesInCluster(clusterName);
               //when reach here, command is succeed. If ApiRequestInfo is null, it means the command has been
               //finished successfully, otherwise we need to wait for it using doSoftwareOperation
               if (apiRequestSummary == null || apiRequestSummary.getApiRequestInfo() == null) {
                  success = true;
                  return true;
               }
               success = doSoftwareOperation(clusterBlueprint.getName(), apiRequestSummary, clusterReport, reports);
            } catch (Exception e) {
View Full Code Here

                  clusterName, "Cannot stop a cluster that is not provisioned by Big Data Extension");
         }
         clusterReport.setAction("Ambari is stopping services");
         clusterReport.setProgress(ProgressSplit.OPERATION_BEGIN.getProgress());
         reportStatus(clusterReport, reports);
         ApiRequest apiRequestSummary = apiManager.stopAllServicesInCluster(clusterName);
         if (apiRequestSummary == null || apiRequestSummary.getApiRequestInfo() == null) {
            logger.info("Services is already stopped in cluster " + clusterName);
            return true;
         }
         doSoftwareOperation(clusterName, apiRequestSummary, clusterReport, reports);
         clusterReport.setClusterAndNodesAction("");
View Full Code Here

                  clusterName, clusterReport, reports,
                  ProgressSplit.OPERATION_FINISHED.getProgress());
      poller.waitForComplete();

      boolean success = false;
      ApiRequest apiRequest =
            apiManager.getRequestWithTasks(clusterName, apiRequestSummary
                  .getApiRequestInfo().getRequestId());
      ClusterRequestStatus clusterRequestStatus =
            ClusterRequestStatus.valueOf(apiRequest.getApiRequestInfo()
                  .getRequestStatus());
      if (!clusterRequestStatus.isFailedState()) {
         success = true;
      } else {
         logger.error("Failed to do request: " + ApiUtils.objectToJson(apiRequest.getApiRequestInfo()));
         List<ApiTask> apiTasks = apiRequest.getApiTasks();
         Map<String, NodeReport> nodeReports = clusterReport.getNodeReports();
         HashMap<String, List<String>> errMsg = new HashMap<>();
         for (ApiTask apiTask : apiTasks) {
            ApiTaskInfo taskInfo = apiTask.getApiTaskInfo();
            if (TaskStatus.valueOf(taskInfo.getStatus()).isFailedState()) {
               if (!errMsg.containsKey(taskInfo.getHostName())) {
                  List<String> errs = new ArrayList<>();
                  errMsg.put(taskInfo.getHostName(), errs);
               }
               String taskErrMsg = taskInfo.getCommandDetail() + " " + taskInfo.getStatus();
               errMsg.get(taskInfo.getHostName()).add(taskErrMsg);
               logger.error("command: " + taskInfo.getCommandDetail() +
                     "role: " + taskInfo.getRole() +
                     "stderr: " + taskInfo.getStderr() +
                     "status: " + taskInfo.getStatus());
            }
         }
         for (NodeReport nodeReport: nodeReports.values()) {
            if (errMsg.containsKey(nodeReport.getHostname())) {
               nodeReport.setErrMsg(errMsg.get(nodeReport.getHostname()).toString());
            }
         }
         String requestErrorMsg = "Failed to execute request: " +
                  apiRequest.getApiRequestInfo().getRequestStatus() + ". Refer to each node for details.";
         clusterReport.setErrMsg(requestErrorMsg);
         reportStatus(clusterReport.clone(), reports);
         throw new RuntimeException(requestErrorMsg);
      }
      return success;
View Full Code Here

   public boolean poll() {
      if (apiRequestSummary == null) {
         return true;
      }
      Long requestId = apiRequestSummary.getApiRequestInfo().getRequestId();
      ApiRequest apiRequest = apiManager.getRequestWithTasks(clusterName, requestId);

      ClusterRequestStatus clusterRequestStatus =
            ClusterRequestStatus.valueOf(apiRequest.getApiRequestInfo()
                  .getRequestStatus());

      Map<String, NodeReport> nodeReports = currentReport.getNodeReports();
      for (String nodeReportKey : nodeReports.keySet()) {
         for (ApiTask apiTask : apiRequest.getApiTasks()) {
            NodeReport nodeReport = nodeReports.get(nodeReportKey);
            nodeReport.setUseClusterMsg(false);
            ApiTaskInfo apiTaskInfo = apiTask.getApiTaskInfo();
            if (nodeReport.getHostname().equals(apiTaskInfo.getHostName())) {
               TaskStatus taskStatus =
                     TaskStatus.valueOf(apiTask.getApiTaskInfo().getStatus());
               if (taskStatus.isRunningState()) {
                  if (clusterRequestStatus.isFailedState() &&
                        apiTaskInfo.getStderr() != null &&
                        !apiTaskInfo.getStderr().isEmpty()) {
                     nodeReport.setAction(apiTaskInfo.getCommandDetail() + ": "
                           + apiTaskInfo.getStderr());
                  } else {
                     nodeReport.setAction(apiTaskInfo.getCommandDetail());
                  }
                  nodeReports.put(nodeReportKey, nodeReport);
               }
            }
         }
      }
      currentReport.setNodeReports(nodeReports);

      int provisionPercent =
            (int) apiRequest.getApiRequestInfo().getProgressPercent();
      if (provisionPercent != 0) {
         int currentProgress = currentReport.getProgress();
         int toProgress = beginProgress + provisionPercent / 2;
         if (toProgress >= endProgress) {
            toProgress = endProgress;
View Full Code Here

         throw AmbariApiException.CANNOT_CONNECT_AMBARI_SERVER(e);
      }
      String requestJson = handleAmbariResponse(response);
      logger.debug("Response of provision cluster with blueprint from ambari server:");
      logger.debug(requestJson);
      ApiRequest apiRequest =
            ApiUtils.jsonToObject(ApiRequest.class, requestJson);
      return apiRequest;
   }
View Full Code Here

         throw AmbariApiException.CANNOT_CONNECT_AMBARI_SERVER(e);
      }
      String requestJson = handleAmbariResponse(response);
      logger.debug("Response of request from ambari server:");
      logger.debug(requestJson);
      ApiRequest apiRequest =
            ApiUtils.jsonToObject(ApiRequest.class, requestJson);
      return apiRequest;
   }
View Full Code Here

         throw AmbariApiException.CANNOT_CONNECT_AMBARI_SERVER(e);
      }
      String requestWithTasksJson = handleAmbariResponse(response);
      logger.debug("Response of request with tasks from ambari server:");
      logger.debug(requestWithTasksJson);
      ApiRequest apiRequest =
            ApiUtils.jsonToObject(ApiRequest.class, requestWithTasksJson);
      return apiRequest;
   }
View Full Code Here

TOP

Related Classes of com.vmware.bdd.plugin.ambari.api.model.cluster.ApiRequest

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.