private ContainerNetworkAllocationTaskState createContainerNetworkAllocationTask( String networkDocSelfLink, long resourceCount) { ContainerNetworkAllocationTaskState allocationTask = new ContainerNetworkAllocationTaskState(); allocationTask.resourceDescriptionLink = networkDocSelfLink; allocationTask.resourceCount = resourceCount; allocationTask.serviceTaskCallback = ServiceTaskCallback.createEmpty(); allocationTask.customProperties = new HashMap<>(); return allocationTask; }
private void createContainerNetworkAllocationTask(RequestBrokerState state) { // 1. allocate the network ContainerNetworkAllocationTaskState allocationTask = new ContainerNetworkAllocationTaskState(); allocationTask.documentSelfLink = getSelfId(); allocationTask.serviceTaskCallback = ServiceTaskCallback.create( getSelfLink(), TaskStage.STARTED, SubStage.ALLOCATED, TaskStage.STARTED, SubStage.ERROR); allocationTask.customProperties = state.customProperties; allocationTask.resourceDescriptionLink = state.resourceDescriptionLink; allocationTask.tenantLinks = state.tenantLinks; allocationTask.requestTrackerLink = state.requestTrackerLink; allocationTask.resourceLinks = state.resourceLinks; allocationTask.resourceCount = state.actualResourceCount; sendRequest(Operation .createPost(this, ContainerNetworkAllocationTaskService.FACTORY_LINK) .setBodyNoCloning(allocationTask) .setContextId(getSelfId()) .setCompletion((o, e) -> { if (e != null) { failTask("Failure creating resource allocation task", e); return; } proceedTo(SubStage.ALLOCATING); })); }
private void prepareContext(ContainerNetworkAllocationTaskState state, ContainerNetworkDescription networkDescription) { assertNotNull(state, "state"); if (networkDescription == null) { getContainerNetworkDescription(state, (netwkDesc) -> prepareContext(state, netwkDesc)); return; } proceedTo(SubStage.CONTEXT_PREPARED, s -> { // merge request/allocation properties over the network description properties s.customProperties = mergeCustomProperties(networkDescription.customProperties, state.customProperties); if (s.getCustomProperty(RequestUtils.FIELD_NAME_CONTEXT_ID_KEY) == null) { s.addCustomProperty(RequestUtils.FIELD_NAME_CONTEXT_ID_KEY, getSelfId()); } s.descName = networkDescription.name; }); }