Examples of CmClusterDef


Examples of com.vmware.bdd.plugin.clouderamgr.model.CmClusterDef

   @Override
   public boolean createCluster(ClusterBlueprint blueprint,
         ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
      boolean success = false;
      CmClusterDef clusterDef = null;
      try {
         clusterDef = new CmClusterDef(blueprint);
         validateBlueprint(blueprint);
         provisionCluster(clusterDef, null, reportQueue);
         provisionParcels(clusterDef, null, reportQueue);
         configureServices(clusterDef, reportQueue, true);
         startServices(clusterDef, reportQueue, true);
         success = true;
         clusterDef.getCurrentReport().setAction("");
         clusterDef.getCurrentReport().setProgress(100);
         clusterDef.getCurrentReport().setSuccess(true);
      } catch (SoftwareManagementPluginException ex) {
         clusterDef.getCurrentReport().setAction("Failed to Create Cluster");
         clusterDef.getCurrentReport().setSuccess(false);
         throw ex;
      } catch (Exception e) {
         clusterDef.getCurrentReport().setAction("Failed to Create Cluster");
         clusterDef.getCurrentReport().setSuccess(false);
         logger.error(e.getMessage());
         throw SoftwareManagementPluginException.CREATE_CLUSTER_EXCEPTION(e, Constants.CDH_PLUGIN_NAME, clusterDef.getName());
      } finally {
         clusterDef.getCurrentReport().setFinished(true);

         if(success) {
            clusterDef.getCurrentReport().setClusterAndNodesServiceStatus(ServiceStatus.STARTED);
         }

         reportQueue.addClusterReport(clusterDef.getCurrentReport().clone());
      }

      return success;
   }
View Full Code Here

Examples of com.vmware.bdd.plugin.clouderamgr.model.CmClusterDef

    * @TODO better use a event-listener mode to decouple the reportQueue. lixl
    */
   public boolean reconfigCluster(ClusterBlueprint blueprint,
         ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
      boolean success = false;
      CmClusterDef clusterDef = null;
      try {
         clusterDef = new CmClusterDef(blueprint);
         syncHostsId(clusterDef);
         configureServices(clusterDef, reportQueue, false);
         success = true;
         clusterDef.getCurrentReport().setAction("Successfully Reconfigure Cluster");
         clusterDef.getCurrentReport().setProgress(100);
         clusterDef.getCurrentReport().setSuccess(true);
      } catch (SoftwareManagementPluginException ex) {
         clusterDef.getCurrentReport().setAction("Failed to Reconfigure Cluster");
         clusterDef.getCurrentReport().setSuccess(false);
         throw ex;
      } catch (Exception e) {
         clusterDef.getCurrentReport().setAction("Failed to Reconfigure Cluster");
         clusterDef.getCurrentReport().setSuccess(false);
         logger.error(e.getMessage());
         throw SoftwareManagementPluginException.RECONFIGURE_CLUSTER_FAILED(e, Constants.CDH_PLUGIN_NAME, clusterDef.getName());
      } finally {
         clusterDef.getCurrentReport().setFinished(true);
         reportQueue.addClusterReport(clusterDef.getCurrentReport().clone());
      }
      return success;
   }
View Full Code Here

Examples of com.vmware.bdd.plugin.clouderamgr.model.CmClusterDef

   @Override
   public boolean scaleOutCluster(ClusterBlueprint blueprint, List<String> addedNodeNames,
         ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
      boolean success = false;
      CmClusterDef clusterDef = null;
      try {
         clusterDef = new CmClusterDef(blueprint);
         provisionCluster(clusterDef, addedNodeNames, reportQueue, true);
         provisionParcels(clusterDef, addedNodeNames, reportQueue);
         Map<String, List<ApiRole>> roles = configureNodeServices(
               clusterDef, reportQueue, addedNodeNames);
         startNodeServices(clusterDef, addedNodeNames, roles, reportQueue);
         success = true;
         clusterDef.getCurrentReport().setProgress(100);
         clusterDef.getCurrentReport().setAction("");
         clusterDef.getCurrentReport().setClusterAndNodesServiceStatus(ServiceStatus.STARTED);
      } catch (SoftwareManagementPluginException ex) {
         if (ex instanceof CommandExecFailException) {
            String hostId = ((CommandExecFailException)ex).getRefHostId();
            CmNodeDef nodeDef = clusterDef.idToHosts().get(hostId);
            String errMsg = null;
            if (nodeDef != null) {
               errMsg = "Failed to start role for node "  + nodeDef.getName() + " for "
                     + ((ex.getMessage() == null) ? "" : (", " + ex.getMessage()));
               // reset all node actions.
               clusterDef.getCurrentReport().setNodesAction("", addedNodeNames);
               clusterDef.getCurrentReport().setNodesStatus(ServiceStatus.STOPPED, addedNodeNames);

               // set error message for specified node
               clusterDef.getCurrentReport().getNodeReports()
                     .get(nodeDef.getName()).setErrMsg(errMsg);
               throw  SoftwareManagementPluginException.START_SERVICE_FAILED(ex, Constants.CDH_PLUGIN_NAME, clusterDef.getName());
            }
         }
         clusterDef.getCurrentReport().setNodesError(ex.getMessage(), addedNodeNames);
         clusterDef.getCurrentReport().setNodesStatus(ServiceStatus.FAILED, addedNodeNames);
         throw ex;
      } catch (Exception e) {
         clusterDef.getCurrentReport().setNodesError(
               "Failed to bootstrap nodes for " + e.getMessage(), addedNodeNames);
         clusterDef.getCurrentReport().setNodesStatus(ServiceStatus.FAILED, addedNodeNames);
         logger.error(e.getMessage());
         throw SoftwareManagementPluginException.SCALE_OUT_CLUSTER_FAILED(e, Constants.CDH_PLUGIN_NAME, clusterDef.getName());
      } finally {
         clusterDef.getCurrentReport().setSuccess(success);
         clusterDef.getCurrentReport().setFinished(true);
         reportQueue.addClusterReport(clusterDef.getCurrentReport().clone());
      }
      return success;
   }
View Full Code Here

Examples of com.vmware.bdd.plugin.clouderamgr.model.CmClusterDef

      return onStopCluster(clusterBlueprint, reports);
   }

   @Override
   public boolean onDeleteNodes(ClusterBlueprint blueprint, List<String> nodeNames) throws SoftwareManagementPluginException {
      CmClusterDef clusterDef = null;
      try {
         clusterDef = new CmClusterDef(blueprint);
         syncHostsId(clusterDef);
         List<ApiHost> hosts = new ArrayList<>();
         for (CmNodeDef nodeDef : clusterDef.getNodes()) {
            if (nodeNames.contains(nodeDef.getName())
                  && !nodeDef.getName().equals(nodeDef.getNodeId())) {
               try {
                  ApiHost host = apiResourceRootV6.getHostsResource().readHost(nodeDef.getNodeId());
                  if (host != null) {
                     hosts.add(host);
                  }
               } catch (NotFoundException e) {
                  logger.debug("Host " + nodeDef.getNodeId() + " is not found from Cloudera Manager.");
                  continue;
               }
            }
         }
         removeHosts(clusterDef, hosts);
         clusterDef.getCurrentReport().setProgress(100);
         clusterDef.getCurrentReport().setAction("");
      } catch (Exception e) {
         logger.error("Failed to remove hosts " + nodeNames, e);
      }
      return true;
   }
View Full Code Here

Examples of com.vmware.bdd.plugin.clouderamgr.model.CmClusterDef

      if (blueprint == null) {
         logger.info("Empty blueprint is passed to query cluster status. Return null.");
         return null;
      }
      try {
         CmClusterDef cluster = new CmClusterDef(blueprint);
         syncHostsId(cluster);
         boolean allStarted = true;
         boolean allStopped = true;
         for (ApiService apiService : apiResourceRootV6.getClustersResource()
               .getServicesResource(cluster.getName()).readServices(DataView.SUMMARY)) {
            ApiServiceState serviceState = apiService.getServiceState();
            if (!ApiServiceState.STARTED.equals(serviceState)) {
               allStarted = false;
            } else {
               allStopped = false;
            }
         }
         if (allStopped) {
            logger.debug("Cluster " + blueprint.getName() + " services are stopped.");
            cluster.getCurrentReport().setStatus(ServiceStatus.STOPPED);
         } else if (allStarted) {
            ApiHealthSummary summary = getExistingServiceHealthStatus(cluster.getName());
            switch (summary) {
            case GOOD:
               cluster.getCurrentReport().setStatus(ServiceStatus.STARTED);
               logger.debug("Cluster " + blueprint.getName() + " is healthy.");
               break;
            case BAD:
            case CONCERNING:
               cluster.getCurrentReport().setStatus(ServiceStatus.ALERT);
               logger.debug("Cluster " + blueprint.getName() + " is concerning.");
               break;
            default:
               cluster.getCurrentReport().setStatus(ServiceStatus.STARTED);
               logger.debug("Cluster " + blueprint.getName() + " healthy is unavailable.");
               break;
            }
         } else {
            cluster.getCurrentReport().setStatus(ServiceStatus.ALERT);
            logger.debug("Cluster " + blueprint.getName() + " services are not all started yet.");
         }
         queryNodesStatus(cluster);
         return cluster.getCurrentReport().clone();
      } catch (Exception e) {
         throw SoftwareManagementPluginException.QUERY_CLUSTER_STATUS_FAILED(
               blueprint.getName(), e);
      }
   }
View Full Code Here

Examples of com.vmware.bdd.plugin.clouderamgr.model.CmClusterDef

   // When stop command failed to execute, we should not ignore it, because that will
   // make the cloudera manager in inconsistent state with bde. So when we fail, we throw exception
   private boolean stopServices(ClusterBlueprint clusterBlueprint, ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
      assert(clusterBlueprint != null && clusterBlueprint.getName() != null && !clusterBlueprint.getName().isEmpty());
      String clusterName = clusterBlueprint.getName();
      CmClusterDef clusterDef = null;
      ClusterReport report = null;
      boolean succeed = false;
      try {
         if (!isProvisioned(clusterName)) {
            return true;
         }
         clusterDef = new CmClusterDef(clusterBlueprint);
         report = clusterDef.getCurrentReport();
         if (isStopped(clusterName) || !needStop(clusterName)) {
            succeed = true;
            return true;
         }
         executeAndReport("Stopping Services",
View Full Code Here

Examples of com.vmware.bdd.plugin.clouderamgr.model.CmClusterDef

   @Override
   public boolean startCluster(ClusterBlueprint clusterBlueprint, ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
      assert(clusterBlueprint != null && clusterBlueprint.getName() != null && !clusterBlueprint.getName().isEmpty());
      String clusterName = clusterBlueprint.getName();
      CmClusterDef clusterDef = null;
      ClusterReport report = null;
      boolean succeed = false;
      try {
         if (!isProvisioned(clusterName)) {
            return true;
         }
         clusterDef = new CmClusterDef(clusterBlueprint);
         report = clusterDef.getCurrentReport();
         if (isExistingServiceStarted(clusterName)) {
            succeed = true;
            return true;
         }
         ReflectionUtils.getPreStartServicesHook().preStartServices(clusterDef.getName(), 120);
         executeAndReport("Starting Services",
                           apiResourceRootV6.getClustersResource().startCommand(clusterName),
                           ProgressSplit.START_SERVICES.getProgress(),
                           report,
                           reportQueue,
                           true);
         succeed = true;
         return true;
      } catch (Exception e) {
         report.setClusterAndNodesServiceStatus(ServiceStatus.STARTUP_FAILED);
         logger.error("Got an exception when cloudera manager starting cluster", e);
         HashMap<String, Set<String>> unstartedRoles = getFailedRoles(clusterName, ApiRoleState.STARTED);
         setRolesErrorMsg(report, unstartedRoles, "starting");
         throw SoftwareManagementPluginException.START_CLUSTER_FAILED(e, Constants.CDH_PLUGIN_NAME, clusterDef.getName());
      } finally {
         if (clusterDef != null) {
            report.setFinished(true);
            if (succeed) {
               report.setProgress(ProgressSplit.START_SERVICES.getProgress());
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.