private void createAdditionalResources(ClusteringTaskState state, String descLink,
String groupResourcePlacementLink, int resourcesToAdd) {
RequestBrokerState requestBrokerState = new RequestBrokerState();
requestBrokerState.resourceCount = resourcesToAdd;
requestBrokerState.resourceDescriptionLink = descLink;
requestBrokerState.resourceType = state.resourceType;
requestBrokerState.operation = RequestBrokerState.PROVISION_RESOURCE_OPERATION;
requestBrokerState.groupResourcePlacementLink = groupResourcePlacementLink;
requestBrokerState.tenantLinks = state.tenantLinks;
requestBrokerState.requestTrackerLink = state.requestTrackerLink;
requestBrokerState.serviceTaskCallback = ServiceTaskCallback.create(getSelfLink(),
TaskState.TaskStage.STARTED, SubStage.COMPLETED, TaskState.TaskStage.FAILED,
SubStage.ERROR);
requestBrokerState.addCustomProperty(FIELD_NAME_CONTEXT_ID_KEY, state.contextId);
requestBrokerState.addCustomProperty(RequestUtils.CLUSTERING_OPERATION_CUSTOM_PROP,
Boolean.TRUE.toString());
String allocationRequest = state.getCustomProperty(FIELD_NAME_ALLOCATION_REQUEST);
if (allocationRequest != null) {
requestBrokerState.addCustomProperty(FIELD_NAME_ALLOCATION_REQUEST, allocationRequest);
}
sendRequest(Operation.createPost(this, RequestBrokerFactoryService.SELF_LINK)
.setBody(requestBrokerState).setCompletion((o, e) -> {
if (e != null) {
logSevere(e);
return;
}
proceedTo(SubStage.CLUSTERING);
}));
}