private void proceedAfterHostSelection(ContainerAllocationTaskState state) { if (!state.postAllocation && state.hostSelections == null && state.resourceNames == null) { failTask(null, new LocalizableValidationException( "computeHostLink and resourceNames can't be null at this state", "request.container.allocation.host.missing")); } else if (state.postAllocation || (state.hostSelections != null && state.resourceNames != null)) { final Map<String, HostSelection> resourceNameToHostSelection = !state.postAllocation ? selectHostPerResourceName(state.resourceNames, state.hostSelections) : null; if (state.instanceAdapterReference == null) { // reload container description if null getContainerDescription(state, (contDesc) -> { proceedTo(SubStage.HOST_ALLOCATED, s -> { s.instanceAdapterReference = contDesc.instanceAdapterReference; s.resourceNameToHostSelection = resourceNameToHostSelection; s.customProperties = mergeCustomProperties(state.customProperties, contDesc.customProperties); }); }); } else { proceedTo(SubStage.HOST_ALLOCATED, s -> { s.resourceNameToHostSelection = resourceNameToHostSelection; }); } } }
proceedTo(SubStage.ERROR, (s) -> { s.taskInfo.failure = Utils.toServiceErrorResponse( new Exception(String.format("Health check failed for %s", && Boolean.TRUE.equals(containerStats.healthCheckSuccess)) { if (expectedSuccessfulHealthCheckCount.decrementAndGet() == 0) { proceedTo(SubStage.COMPLETED); return;
private void prepareContext(ContainerAllocationTaskState state, ContainerDescription containerDesc) { if (state.postAllocation) { proceedTo(SubStage.PLACEMENT_HOST_SELECTED); return; } if (containerDesc == null) { getContainerDescription(state, (contDesc) -> this.prepareContext(state, contDesc)); return; } proceedTo(SubStage.CONTEXT_PREPARED, s -> { // merge request/allocation properties over the container description properties s.customProperties = mergeCustomProperties(containerDesc.customProperties, state.customProperties); if (s.getCustomProperty(FIELD_NAME_CONTEXT_ID_KEY) == null) { s.addCustomProperty(FIELD_NAME_CONTEXT_ID_KEY, getSelfId()); } s.descName = containerDesc.name; }); }
createResourcePrefixNameSelectionTask(state, null); } else { proceedTo(SubStage.RESOURCES_NAMED); proceedTo(SubStage.BUILD_RESOURCES_LINKS); proceedTo(SubStage.PLACEMENT_HOST_SELECTED, s -> { if (!state.postAllocation) { s.resourceLinks = buildResourceLinks(state); proceedTo(SubStage.START_PROVISIONING); } else { createContainerStates(state, null, null);
private void provisionAllocatedContainers(ContainerAllocationTaskState state, ServiceTaskCallback taskCallback) { final boolean allocationRequest = isAllocationRequest(state); if (taskCallback == null) { // create a counter subtask link first createCounterSubTaskCallback(state, state.resourceCount, !allocationRequest, !allocationRequest || state.postAllocation ? SubStage.WAITING_FOR_HEALTH_CHECK : SubStage.COMPLETED, (serviceTask) -> provisionAllocatedContainers(state, serviceTask)); return; } logInfo("Provision request for %s containers", state.resourceCount); for (String resourceLink : state.resourceLinks) { createContainerInstanceRequests(state, taskCallback, resourceLink); } proceedTo(SubStage.PROVISIONING); }