JobConstants.TARGET_NAME_JOB_PARAM).split("-")[0];
}
String nodeName =
getJobParameters(chunkContext).getString(
JobConstants.SUB_JOB_NODE_NAME);
NodeEntity node = getClusterEntityMgr().findNodeByName(nodeName);
getClusterEntityMgr().syncUpNode(clusterName, nodeName);
Boolean success =
getFromJobExecutionContext(chunkContext,
JobConstants.NODE_OPERATION_SUCCESS, Boolean.class);
if (success != null && !success) {
throw ClusteringServiceException.CLUSTER_OPERATION_FAILED(clusterName);
}
NodeStatus expectedStatus =
getFromJobExecutionContext(chunkContext,
JobConstants.EXPECTED_NODE_STATUS, NodeStatus.class);
if (expectedStatus != null) {
logger.info("the node should be in status " + expectedStatus);
JobUtils.verifyNodeStatus(node, expectedStatus, true);
}
String cpuNumberStr =
getJobParameters(chunkContext).getString(
JobConstants.NODE_SCALE_CPU_NUMBER);
String memorySizeStr =
getJobParameters(chunkContext).getString(
JobConstants.NODE_SCALE_MEMORY_SIZE);
int cpuNumber = 0;
if (cpuNumberStr != null) {
cpuNumber = Integer.parseInt(cpuNumberStr);
}
boolean rollback =
getFromJobExecutionContext(chunkContext,
JobConstants.NODE_SCALE_ROLLBACK, Boolean.class);
long memory = 0;
if (memorySizeStr != null) {
memory = Long.parseLong(memorySizeStr);
}
if (cpuNumber > 0 && !rollback) {
node.setCpuNum(cpuNumber);
}
if (memory > 0) {
if (!rollback) {
node.setMemorySize(memory);
}
scaleService.updateSwapDisk(nodeName);
}
getClusterEntityMgr().update(node);