use of alien4cloud.paas.model.NodeOperationExecRequest in project alien4cloud by alien4cloud.
the class DeploymentRuntimeService method triggerClusterManagerScaleOperation.
private void triggerClusterManagerScaleOperation(final String nodeTemplateId, final int instances, final IPaaSCallback<Object> callback, final Deployment deployment, final DeploymentTopology topology, Capability clusterControllerCapability, SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials) {
IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
NodeOperationExecRequest scaleOperationRequest = new NodeOperationExecRequest();
// Instance id is not specified for cluster control nodes
scaleOperationRequest.setNodeTemplateName(nodeTemplateId);
scaleOperationRequest.setInterfaceName(AlienInterfaceTypes.CLUSTER_CONTROL);
scaleOperationRequest.setOperationName(AlienInterfaceTypes.CLUSTER_CONTROL_OP_SCALE);
int currentInstances = TopologyUtils.getScalingProperty(NormativeComputeConstants.SCALABLE_DEFAULT_INSTANCES, clusterControllerCapability);
int expectedInstances = currentInstances + instances;
log.info("Scaling [ {} ] node from [ {} ] to [ {} ]. Updating runtime topology...", nodeTemplateId, currentInstances, expectedInstances);
TopologyUtils.setScalingProperty(NormativeComputeConstants.SCALABLE_DEFAULT_INSTANCES, expectedInstances, clusterControllerCapability);
alienMonitorDao.save(topology);
scaleOperationRequest.setParameters(Maps.newHashMap());
scaleOperationRequest.getParameters().put(AlienInterfaceTypes.CLUSTER_CONTROL_OP_SCALE_PARAMS_INSTANCES_DELTA, String.valueOf(instances));
scaleOperationRequest.getParameters().put(AlienInterfaceTypes.CLUSTER_CONTROL_OP_SCALE_PARAMS_EXPECTED_INSTANCES, String.valueOf(expectedInstances));
orchestratorPlugin.executeOperation(deploymentContextService.buildTopologyDeploymentContext(secretProviderConfigurationAndCredentials, deployment, deploymentTopologyService.getLocations(topology), topology), scaleOperationRequest, new IPaaSCallback<Map<String, String>>() {
@Override
public void onSuccess(Map<String, String> data) {
callback.onSuccess(data);
}
@Override
public void onFailure(Throwable throwable) {
log.info("Failed to scale [ {} ] node from [ {} ] to [ {} ]. rolling back to {}...", nodeTemplateId, currentInstances, expectedInstances, currentInstances);
TopologyUtils.setScalingProperty(NormativeComputeConstants.SCALABLE_DEFAULT_INSTANCES, currentInstances, clusterControllerCapability);
alienMonitorDao.save(topology);
callback.onFailure(throwable);
}
});
}
Aggregations