private Set<String> buildResourceLinks(ContainerAllocationTaskState state) { logInfo("Generate provisioned resourceLinks"); Set<String> resourceLinks = new HashSet<>(state.resourceNames.size()); for (String resourceName : state.resourceNames) { String containerLink = buildResourceLink(resourceName); resourceLinks.add(containerLink); } return resourceLinks; }
logInfo("Host selections are empty."); callback.run(); return;
private void completeTask(ContainerAllocationTaskState state) { if (state.hostSelections != null) { try { ContainerHostDataCollectionState body = new ContainerHostDataCollectionState(); body.noHostOperation = true; body.computeContainerHostLinks = new HashSet<String>( state.resourceNameToHostSelection.values() .stream().map((r) -> r.hostLink) .collect(Collectors.toList())); logInfo("Container Host collection started for: [%s]", body.computeContainerHostLinks); sendRequest(Operation.createPatch(this, ContainerHostDataCollectionService.HOST_INFO_DATA_COLLECTION_LINK) .setBody(body) .setCompletion((o, e) -> { if (e != null) { logWarning("Container Host [%s] can't be updated. Error: [%s]", body.computeContainerHostLinks, Utils.toString(e)); } })); } catch (Throwable e) { logSevere(e); } } complete(); }
logInfo("Scheduling health check for: %s", containerState.documentSelfLink); getHost().schedule(() -> { doHealthCheck(state, containerState,
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); }
logInfo("Created ContainerState: %s", body.documentSelfLink);
private void createContainerInstanceRequests(ContainerAllocationTaskState state, ServiceTaskCallback taskCallback, String containerSelfLink) { AdapterRequest adapterRequest = new AdapterRequest(); adapterRequest.resourceReference = UriUtils.buildUri(getHost(), containerSelfLink); adapterRequest.serviceTaskCallback = taskCallback; adapterRequest.operationTypeId = ContainerOperationType.CREATE.id; adapterRequest.customProperties = state.customProperties; sendRequest(Operation.createPatch(getHost(), state.instanceAdapterReference.toString()) .setBody(adapterRequest) .setContextId(getSelfId()) .setCompletion((o, e) -> { if (e != null) { failTask("AdapterRequest failed for container: " + containerSelfLink, e); return; } logInfo("Container provisioning started for: %s", containerSelfLink); })); }