ContainerRemovalTaskState removalState = new ContainerRemovalTaskState(); removalState.skipReleaseResourcePlacement = skipReleaseResourcePlacement; removalState.resourceLinks = state.resourceLinks.stream()
ContainerRemovalTaskState containerRemovalTask = new ContainerRemovalTaskState(); containerRemovalTask.taskSubStage = ContainerRemovalTaskState.SubStage.INSTANCES_REMOVED; containerRemovalTask.resourceLinks = containerStateLinks;
@Test public void testRemoveOfClosureContainerOperation() throws Throwable { GroupResourcePlacementState ulimitedPlacementState = TestRequestStateFactory .createGroupResourcePlacementState(placementResourceType()); ulimitedPlacementState.maxNumberInstances = GroupResourcePlacementService .UNLIMITED_NUMBER_INSTANCES; ulimitedPlacementState.resourcePoolLink = resourcePool.documentSelfLink; ulimitedPlacementState = getOrCreateDocument(ulimitedPlacementState, GroupResourcePlacementService.FACTORY_LINK); assertNotNull(ulimitedPlacementState); ContainerState container = TestRequestStateFactory.createContainer(); container.descriptionLink = CLOSURES_CONTAINER_DESC + "-" + UUID.randomUUID().toString(); container.adapterManagementReference = containerDesc.instanceAdapterReference; container.groupResourcePlacementLink = ulimitedPlacementState.documentSelfLink; container.system = Boolean.FALSE; container = doPost(container, ContainerFactoryService.SELF_LINK); Set<String> containerStateLinks = new HashSet<>(1); containerStateLinks.add(container.documentSelfLink); // try to remove the container ContainerRemovalTaskState containerRemovalTask = new ContainerRemovalTaskState(); containerRemovalTask.taskSubStage = ContainerRemovalTaskState.SubStage.INSTANCES_REMOVED; containerRemovalTask.resourceLinks = containerStateLinks; containerRemovalTask.removeOnly = true; containerRemovalTask = startRequest(containerRemovalTask); waitForRequestToComplete(containerRemovalTask); assertDescriptionGetsDeleted(ContainerDescription.class, container.descriptionLink); }
private void removeContainers(ContainerHostRemovalTaskState state, Set<String> containerSelfLinks) { // run a sub task for removing the containers ContainerRemovalTaskState containerRemovalTask = new ContainerRemovalTaskState(); containerRemovalTask.resourceLinks = containerSelfLinks; containerRemovalTask.removeOnly = true; containerRemovalTask.serviceTaskCallback = ServiceTaskCallback.create( getSelfLink(), TaskStage.STARTED, SubStage.REMOVED_CONTAINERS, TaskStage.STARTED, SubStage.ERROR); containerRemovalTask.requestTrackerLink = state.requestTrackerLink; Operation startPost = Operation .createPost(this, ContainerRemovalTaskFactoryService.SELF_LINK) .setBody(containerRemovalTask) .setCompletion((o, e) -> { if (e != null) { failTask("Failure creating container removal task", e); return; } proceedTo(SubStage.REMOVING_CONTAINERS); }); sendRequest(startPost); }