ClouderaManagerImpl extends AbstractSoftwareManager implements SoftwareManager { @Override public boolean scaleOutCluster(ClusterBlueprint blueprint, List<String> addedNodeNames, ClusterReportQueue reportQueue, boolean forceScaleOut) throws SoftwareManagementPluginException { boolean success = false; CmClusterDef clusterDef = null; try { clusterDef = new CmClusterDef(blueprint); ReflectionUtils.getPreStartServicesHook().preStartServices(blueprint.getName(), addedNodeNames, forceScaleOut); provisionCluster(clusterDef, addedNodeNames, reportQueue, true, forceScaleOut); 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, addedNodeNames); } 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())); clusterDef.getCurrentReport().setNodesAction("", addedNodeNames); clusterDef.getCurrentReport().setNodesStatus(ServiceStatus.STOPPED, addedNodeNames); 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; } 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" }, dependsOnMethods = { "testQueryClusterStatus" }) public void testScaleOutCluster() { blueprint.getHadoopStack().setDistro("CDH-5.0.1"); List<String> addedNodeNames = new ArrayList<>(); for (NodeGroupInfo groupInfo : blueprint.getNodeGroups()) { int instanceNum = groupInfo.getNodes().size(); if (instanceNum > 1) { addedNodeNames.add(groupInfo.getNodes().get(instanceNum - 1).getName()); } } provider.scaleOutCluster(blueprint, addedNodeNames, reportQueue, false); List<ClusterReport> reports = reportQueue.pollClusterReport(); for (ClusterReport report : reports) { System.out.println("Action: " + report.getAction() + ", Progress: " + report.getProgress()); if (report.isFinished()) { Assert.assertTrue(report.isSuccess(), "Should get success result."); } } }