ClouderaManagerImpl extends AbstractSoftwareManager implements SoftwareManager { @Override public boolean createCluster(ClusterBlueprint blueprint, ClusterReportQueue reportQueue) throws SoftwareManagementPluginException { boolean success = false; CmClusterDef clusterDef = null; try { clusterDef = new CmClusterDef(blueprint); ReflectionUtils.getPreStartServicesHook().preStartServices(blueprint.getName()); 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; } ClouderaManagerImpl();  ClouderaManagerImpl(String cmServerHost, int port, String user,
         String password, String privateKey);  ClouderaManagerImpl(URL url, String user, String password,
         String privateKey); RootResourceV6 getApiResourceRootV6(); @Override boolean validateServerVersion(); @Override String getName(); @Override String getDescription(); @Override String getType(); @Override List<HadoopStack> getSupportedStacks(); @Override String getSupportedConfigs(HadoopStack hadoopStack); @Override boolean validateBlueprint(ClusterBlueprint blueprint); @Override boolean createCluster(ClusterBlueprint blueprint,
         ClusterReportQueue reportQueue); @Override /** * @TODO better use a event-listener mode to decouple the reportQueue. lixl */ boolean reconfigCluster(ClusterBlueprint blueprint,
         ClusterReportQueue reportQueue); @Override boolean scaleOutCluster(ClusterBlueprint blueprint, List<String> addedNodeNames,
         ClusterReportQueue reportQueue, boolean forceScaleOut); @Override boolean deleteCluster(ClusterBlueprint clusterBlueprint,
         ClusterReportQueue reports); @Override boolean onStopCluster(ClusterBlueprint clusterBlueprint,
         ClusterReportQueue reportQueue); @Override boolean onDeleteCluster(ClusterBlueprint clusterBlueprint,
         ClusterReportQueue reports); @Override boolean onDeleteNodes(ClusterBlueprint blueprint, List<String> nodeNames); @Override boolean decomissionNodes(String clusterName, List<NodeInfo> nodes,
         ClusterReportQueue reports); @Override void decommissionNode(ClusterBlueprint blueprint, String nodeGroupName, String nodeName, ClusterReportQueue reportQueue); @Override boolean recomissionNode(String clusterName, NodeInfo node, ClusterReportQueue reportQueue); @Override boolean comissionNodes(String clusterName, List<NodeInfo> nodes,
         ClusterReportQueue reports); @Override boolean startNodes(String clusterName, List<NodeInfo> nodes,
         ClusterReportQueue reports); @Override boolean stopNodes(String clusterName, List<NodeInfo> nodes,
         ClusterReportQueue reports); @Override String exportBlueprint(String clusterName); @Override ClusterReport queryClusterStatus(ClusterBlueprint blueprint); @Override boolean echo(); @Override HealthStatus getStatus(); boolean startCluster(ClusterBlueprint clusterBlueprint, ClusterReportQueue reportQueue); @Override boolean startCluster(ClusterBlueprint clusterBlueprint, ClusterReportQueue reportQueue, boolean forceStart); String getCmServerHostId(); @Override List<String> validateRolesForScaleOut(NodeGroupInfo group); void validateRolesForShrink(NodeGroupInfo groupInfo); @Override void updateInfrastructure(ClusterBlueprint blueprint); @Override boolean hasHbase(ClusterBlueprint blueprint); @Override boolean hasMgmtRole(List<String> roles); @Override boolean isComputeOnlyRoles(List<String> roles); @Override boolean twoDataDisksRequired(NodeGroupInfo group); @Override boolean hasComputeMasterGroup(ClusterBlueprint blueprint); @Override String getVersion(); @Override HadoopStack getDefaultStack(); @Override boolean hasMountPointStartwithDatax(String clusterName); @Override void restartClusterRequiredServices(ClusterBlueprint blueprint,
         ClusterReportQueue reports); final String MIN_SUPPORTED_VERSION; }
@Test( groups = { "TestClouderaManagerImpl" }) public void testCreateCluster() { blueprint.getHadoopStack().setDistro("CDH-5.0.1"); provider.createCluster(blueprint, reportQueue); provider.reconfigCluster(blueprint, reportQueue); provider.onDeleteCluster(blueprint, reportQueue); provider.deleteCluster(blueprint, reportQueue); List<ClusterReport> reports = reportQueue.pollClusterReport(); for (ClusterReport report : reports) { System.out.println("Action: " + report.getAction() + ", Progress: " + report.getProgress()); } }
@Test( groups = { "TestClouderaManagerImpl" }) public void testCreateNnHa() throws IOException { ClusterBlueprint haSpec = SerialUtils.getObjectByJsonString(ClusterBlueprint.class, CommonUtil.readJsonFile("namenode_ha.json")); provider.createCluster(haSpec, reportQueue); List<ClusterReport> reports = reportQueue.pollClusterReport(); for (ClusterReport report : reports) { System.out.println("Action: " + report.getAction() + ", Progress: " + report.getProgress()); } }