@Override public Service createServiceInstance() throws Throwable { return new ContainerAllocationTaskService(); }
switch (state.taskSubStage) { case CREATED: prepareContext(state, null); break; case CONTEXT_PREPARED: if (state.resourceNames == null || state.resourceNames.isEmpty()) { createResourcePrefixNameSelectionTask(state, null); } else { proceedTo(SubStage.RESOURCES_NAMED); selectPlacementComputeHost(state, null); } else { proceedTo(SubStage.BUILD_RESOURCES_LINKS); proceedTo(SubStage.PLACEMENT_HOST_SELECTED, s -> { if (!state.postAllocation) { s.resourceLinks = buildResourceLinks(state); proceedAfterHostSelection(state); break; case HOST_ALLOCATED: proceedTo(SubStage.START_PROVISIONING); } else { createContainerStates(state, null, null); allocatePorts(state); break;
private String buildResourceLink(String resourceName) { return UriUtils.buildUriPath(ContainerFactoryService.SELF_LINK, buildResourceId(resourceName)); }
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; }
getResourcePlacementState( state, (resourcePlacementState) -> createContainerState(state, containerDesc, isFromTemplate, resourceName, resourcePlacementState, hostSelection, taskCallback)); if (isFromTemplate == null && isClusteringOperation(state)) { getCompositeComponent(state, (isTemplate) -> createContainerState(state, containerDesc, isTemplate, resourceName, groupResourcePlacementState, hostSelection, taskCallback)); containerState.documentSelfLink = buildResourceId(resourceName); containerState.names = new ArrayList<>(); containerState.names.add(resourceName); containerState.volumesFrom = hostSelection.mapNames(containerDesc.volumesFrom); containerState.volumeDriver = containerDesc.volumeDriver; containerState.volumes = mapVolumes(containerDesc, hostSelection); containerState.networks = mapNetworks(containerDesc, hostSelection); if (containerDesc.portBindings != null) { containerState.ports = new ArrayList<PortBinding>( String[] mapLinks = mapLinks(containerDesc, hostSelection); containerState.links = mapLinks; containerState.memoryLimit = getMinParam(groupResourcePlacementState.memoryLimit, containerDesc.memoryLimit);
assertEquals(1, allocationTask.resourceLinks.size()); ContainerAllocationTaskService service = new ContainerAllocationTaskService(); service.setHost(host); .notificationPayload(allocationTask); service.enhanceExtensibilityResponse(allocationTask, payload).whenComplete((r, err) -> { try { ContainerAllocationTaskState document = getDocument(
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(); }
@Test public void testGetMin() { assertEquals(1, ContainerAllocationTaskService.getMinParam(0, 1L).longValue()); assertEquals(1, ContainerAllocationTaskService.getMinParam(1, null).longValue()); assertEquals(1, ContainerAllocationTaskService.getMinParam(2, 1L).longValue()); assertEquals(1, ContainerAllocationTaskService.getMinParam(1, 2L).longValue()); assertEquals(0, ContainerAllocationTaskService.getMinParam(0, null).longValue()); assertEquals(1, ContainerAllocationTaskService.getMinParam(1, 0L).longValue()); }
assertEquals(1, allocationTask.resourceLinks.size()); ContainerAllocationTaskService service = new ContainerAllocationTaskService(); service.setHost(host); .notificationPayload(allocationTask); service.enhanceExtensibilityResponse(allocationTask, payload).whenComplete((r, err) -> { try { ContainerAllocationTaskState document = getDocument(
.getMinParam(groupPlacementState.cpuShares, containerDesc.cpuShares.longValue()) .longValue(), containerState.cpuShares.longValue()); assertEquals(ContainerAllocationTaskService .getMinParam(groupPlacementState.memoryLimit, containerDesc.memoryLimit), containerState.memoryLimit);