ScaleManager { @ClusterManagerPointcut public long scaleNodeGroupResource(ResourceScale scale) throws Exception { String clusterName = scale.getClusterName(); opsBlocker.blockUnsupportedOpsByCluster("scale Up/Down", clusterName); ValidationUtils.validateVersion(clusterEntityMgr, clusterName); ClusterStatus originalStatus = clusterEntityMgr.findByName(clusterName).getStatus(); logger.info("before scaling, cluster status is:" + originalStatus); if (scale.getMemory() > 0) { long converted = VcVmUtil.makeVmMemoryDivisibleBy4(scale.getMemory()); logger.info("user's setting for memory: " + scale.getMemory() + " converted to : " + converted); scale.setMemory(converted); } List<JobParameters> jobParametersList = buildJobParameters(scale); if (jobParametersList.size() == 0) { throw ScaleServiceException.NOT_NEEDED(clusterName); } String nodeGroupName = scale.getNodeGroupName(); List<NodeEntity> nodes = clusterEntityMgr.findAllNodes(clusterName, nodeGroupName); if (nodes.size() > 0) { VcResourceUtils.checkVmMaxConfiguration(nodes.get(0).getMoId(), scale.getCpuNumber(), scale.getMemory()); if (scale.getCpuNumber() > 1) { for (NodeEntity nodeEntity : nodes) { VcResourceUtils.checkVmFTAndCpuNumber(nodeEntity.getMoId(), nodeEntity.getVmName(), scale.getCpuNumber()); if (!VcVmUtil.validateCPU(nodeEntity.getMoId(), scale.getCpuNumber())) { throw VcProviderException.CPU_NUM_NOT_MULTIPLE_OF_CORES_PER_SOCKET(scale.getNodeGroupName(), nodeEntity.getVmName()); } } } } updateNodeGroupResource(scale); try { logger.info("set cluster to maintenace"); clusterEntityMgr.updateClusterStatus(clusterName, ClusterStatus.MAINTENANCE); logger.info("current cluster status: " + clusterEntityMgr.findByName(clusterName).getStatus()); return jobManager.runSubJobForNodes(JobConstants.NODE_SCALE_JOB_NAME, jobParametersList, clusterName, originalStatus, ClusterStatus.ERROR); } catch (Throwable t) { logger.error("Failed to start cluster " + clusterName, t); clusterEntityMgr.updateClusterStatus(clusterName, originalStatus); throw ScaleServiceException.JOB_LAUNCH_FAILURE(clusterName, t, t.getMessage()); } }  @ClusterManagerPointcut long scaleNodeGroupResource(ResourceScale scale); @Transactional List<JobParameters> buildJobParameters(ResourceScale scale); void updateNodeGroupResource(ResourceScale scale); IClusterEntityManager getClusterEntityMgr(); void setClusterEntityMgr(IClusterEntityManager clusterEntityMgr); JobManager getJobManager(); void setJobManager(JobManager jobManager);  }
@Test public void scaleNodeGroupResource() { }