Java Code Examples for org.apache.flink.runtime.taskmanager.TaskManagerLocation#getResourceID()
The following examples show how to use
org.apache.flink.runtime.taskmanager.TaskManagerLocation#getResourceID() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProducerDescriptor.java From flink with Apache License 2.0 | 5 votes |
public static ProducerDescriptor create(TaskManagerLocation producerLocation, ExecutionAttemptID attemptId) { return new ProducerDescriptor( producerLocation.getResourceID(), attemptId, producerLocation.address(), producerLocation.dataPort()); }
Example 2
Source File: SlotPoolUtils.java From flink with Apache License 2.0 | 5 votes |
public static ResourceID offerSlots( SlotPoolImpl slotPool, ComponentMainThreadExecutor mainThreadExecutor, List<ResourceProfile> resourceProfiles, TaskManagerGateway taskManagerGateway) { final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); CompletableFuture.runAsync( () -> { slotPool.registerTaskManager(taskManagerLocation.getResourceID()); final Collection<SlotOffer> slotOffers = IntStream .range(0, resourceProfiles.size()) .mapToObj(i -> new SlotOffer(new AllocationID(), i, resourceProfiles.get(i))) .collect(Collectors.toList()); final Collection<SlotOffer> acceptedOffers = slotPool.offerSlots( taskManagerLocation, taskManagerGateway, slotOffers); assertThat(acceptedOffers, is(slotOffers)); }, mainThreadExecutor ).join(); return taskManagerLocation.getResourceID(); }
Example 3
Source File: ProducerDescriptor.java From flink with Apache License 2.0 | 5 votes |
public static ProducerDescriptor create(TaskManagerLocation producerLocation, ExecutionAttemptID attemptId) { return new ProducerDescriptor( producerLocation.getResourceID(), attemptId, producerLocation.address(), producerLocation.dataPort()); }
Example 4
Source File: SlotPoolUtils.java From flink with Apache License 2.0 | 5 votes |
public static ResourceID offerSlots( SlotPoolImpl slotPool, ComponentMainThreadExecutor mainThreadExecutor, List<ResourceProfile> resourceProfiles, TaskManagerGateway taskManagerGateway) { final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); CompletableFuture.runAsync( () -> { slotPool.registerTaskManager(taskManagerLocation.getResourceID()); final Collection<SlotOffer> slotOffers = IntStream .range(0, resourceProfiles.size()) .mapToObj(i -> new SlotOffer(new AllocationID(), i, resourceProfiles.get(i))) .collect(Collectors.toList()); final Collection<SlotOffer> acceptedOffers = slotPool.offerSlots( taskManagerLocation, taskManagerGateway, slotOffers); assertThat(acceptedOffers, is(slotOffers)); }, mainThreadExecutor ).join(); return taskManagerLocation.getResourceID(); }
Example 5
Source File: SlotPoolImpl.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Slot offering by TaskExecutor with AllocationID. The AllocationID is originally generated by this pool and * transfer through the ResourceManager to TaskManager. We use it to distinguish the different allocation * we issued. Slot offering may be rejected if we find something mismatching or there is actually no pending * request waiting for this slot (maybe fulfilled by some other returned slot). * * @param taskManagerLocation location from where the offer comes from * @param taskManagerGateway TaskManager gateway * @param slotOffer the offered slot * @return True if we accept the offering */ boolean offerSlot( final TaskManagerLocation taskManagerLocation, final TaskManagerGateway taskManagerGateway, final SlotOffer slotOffer) { componentMainThreadExecutor.assertRunningInMainThread(); // check if this TaskManager is valid final ResourceID resourceID = taskManagerLocation.getResourceID(); final AllocationID allocationID = slotOffer.getAllocationId(); if (!registeredTaskManagers.contains(resourceID)) { log.debug("Received outdated slot offering [{}] from unregistered TaskManager: {}", slotOffer.getAllocationId(), taskManagerLocation); return false; } // check whether we have already using this slot AllocatedSlot existingSlot; if ((existingSlot = allocatedSlots.get(allocationID)) != null || (existingSlot = availableSlots.get(allocationID)) != null) { // we need to figure out if this is a repeated offer for the exact same slot, // or another offer that comes from a different TaskManager after the ResourceManager // re-tried the request // we write this in terms of comparing slot IDs, because the Slot IDs are the identifiers of // the actual slots on the TaskManagers // Note: The slotOffer should have the SlotID final SlotID existingSlotId = existingSlot.getSlotId(); final SlotID newSlotId = new SlotID(taskManagerLocation.getResourceID(), slotOffer.getSlotIndex()); if (existingSlotId.equals(newSlotId)) { log.info("Received repeated offer for slot [{}]. Ignoring.", allocationID); // return true here so that the sender will get a positive acknowledgement to the retry // and mark the offering as a success return true; } else { // the allocation has been fulfilled by another slot, reject the offer so the task executor // will offer the slot to the resource manager return false; } } final AllocatedSlot allocatedSlot = new AllocatedSlot( allocationID, taskManagerLocation, slotOffer.getSlotIndex(), slotOffer.getResourceProfile(), taskManagerGateway); // check whether we have request waiting for this slot PendingRequest pendingRequest = pendingRequests.removeKeyB(allocationID); if (pendingRequest != null) { // we were waiting for this! allocatedSlots.add(pendingRequest.getSlotRequestId(), allocatedSlot); if (!pendingRequest.getAllocatedSlotFuture().complete(allocatedSlot)) { // we could not complete the pending slot future --> try to fulfill another pending request allocatedSlots.remove(pendingRequest.getSlotRequestId()); tryFulfillSlotRequestOrMakeAvailable(allocatedSlot); } else { log.debug("Fulfilled slot request [{}] with allocated slot [{}].", pendingRequest.getSlotRequestId(), allocationID); } } else { // we were actually not waiting for this: // - could be that this request had been fulfilled // - we are receiving the slots from TaskManagers after becoming leaders tryFulfillSlotRequestOrMakeAvailable(allocatedSlot); } // we accepted the request in any case. slot will be released after it idled for // too long and timed out return true; }
Example 6
Source File: AllocatedSlotsTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testOperations() throws Exception { SlotPoolImpl.AllocatedSlots allocatedSlots = new SlotPoolImpl.AllocatedSlots(); final AllocationID allocation1 = new AllocationID(); final SlotRequestId slotRequestID = new SlotRequestId(); final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); final ResourceID resource1 = taskManagerLocation.getResourceID(); final AllocatedSlot slot1 = createSlot(allocation1, taskManagerLocation); allocatedSlots.add(slotRequestID, slot1); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.size()); final AllocationID allocation2 = new AllocationID(); final SlotRequestId slotRequestID2 = new SlotRequestId(); final AllocatedSlot slot2 = createSlot(allocation2, taskManagerLocation); allocatedSlots.add(slotRequestID2, slot2); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(slot2, allocatedSlots.get(allocation2)); assertEquals(2, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(2, allocatedSlots.size()); final AllocationID allocation3 = new AllocationID(); final SlotRequestId slotRequestID3 = new SlotRequestId(); final TaskManagerLocation taskManagerLocation2 = new LocalTaskManagerLocation(); final ResourceID resource2 = taskManagerLocation2.getResourceID(); final AllocatedSlot slot3 = createSlot(allocation3, taskManagerLocation2); allocatedSlots.add(slotRequestID3, slot3); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(slot2, allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(2, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(3, allocatedSlots.size()); allocatedSlots.remove(slot2.getAllocationId()); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(2, allocatedSlots.size()); allocatedSlots.remove(slot1.getAllocationId()); assertFalse(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertFalse(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertNull(allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(1, allocatedSlots.size()); allocatedSlots.remove(slot3.getAllocationId()); assertFalse(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertFalse(allocatedSlots.contains(slot3.getAllocationId())); assertFalse(allocatedSlots.containResource(resource1)); assertFalse(allocatedSlots.containResource(resource2)); assertNull(allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertNull(allocatedSlots.get(allocation3)); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(0, allocatedSlots.size()); }
Example 7
Source File: SlotPoolImpl.java From flink with Apache License 2.0 | 4 votes |
/** * Slot offering by TaskExecutor with AllocationID. The AllocationID is originally generated by this pool and * transfer through the ResourceManager to TaskManager. We use it to distinguish the different allocation * we issued. Slot offering may be rejected if we find something mismatching or there is actually no pending * request waiting for this slot (maybe fulfilled by some other returned slot). * * @param taskManagerLocation location from where the offer comes from * @param taskManagerGateway TaskManager gateway * @param slotOffer the offered slot * @return True if we accept the offering */ boolean offerSlot( final TaskManagerLocation taskManagerLocation, final TaskManagerGateway taskManagerGateway, final SlotOffer slotOffer) { componentMainThreadExecutor.assertRunningInMainThread(); // check if this TaskManager is valid final ResourceID resourceID = taskManagerLocation.getResourceID(); final AllocationID allocationID = slotOffer.getAllocationId(); if (!registeredTaskManagers.contains(resourceID)) { log.debug("Received outdated slot offering [{}] from unregistered TaskManager: {}", slotOffer.getAllocationId(), taskManagerLocation); return false; } // check whether we have already using this slot AllocatedSlot existingSlot; if ((existingSlot = allocatedSlots.get(allocationID)) != null || (existingSlot = availableSlots.get(allocationID)) != null) { // we need to figure out if this is a repeated offer for the exact same slot, // or another offer that comes from a different TaskManager after the ResourceManager // re-tried the request // we write this in terms of comparing slot IDs, because the Slot IDs are the identifiers of // the actual slots on the TaskManagers // Note: The slotOffer should have the SlotID final SlotID existingSlotId = existingSlot.getSlotId(); final SlotID newSlotId = new SlotID(taskManagerLocation.getResourceID(), slotOffer.getSlotIndex()); if (existingSlotId.equals(newSlotId)) { log.info("Received repeated offer for slot [{}]. Ignoring.", allocationID); // return true here so that the sender will get a positive acknowledgement to the retry // and mark the offering as a success return true; } else { // the allocation has been fulfilled by another slot, reject the offer so the task executor // will offer the slot to the resource manager return false; } } final AllocatedSlot allocatedSlot = new AllocatedSlot( allocationID, taskManagerLocation, slotOffer.getSlotIndex(), slotOffer.getResourceProfile(), taskManagerGateway); // check whether we have request waiting for this slot PendingRequest pendingRequest = pendingRequests.removeKeyB(allocationID); if (pendingRequest != null) { // we were waiting for this! allocatedSlots.add(pendingRequest.getSlotRequestId(), allocatedSlot); if (!pendingRequest.getAllocatedSlotFuture().complete(allocatedSlot)) { // we could not complete the pending slot future --> try to fulfill another pending request allocatedSlots.remove(pendingRequest.getSlotRequestId()); tryFulfillSlotRequestOrMakeAvailable(allocatedSlot); } else { log.debug("Fulfilled slot request [{}] with allocated slot [{}].", pendingRequest.getSlotRequestId(), allocationID); } } else { // we were actually not waiting for this: // - could be that this request had been fulfilled // - we are receiving the slots from TaskManagers after becoming leaders tryFulfillSlotRequestOrMakeAvailable(allocatedSlot); } // we accepted the request in any case. slot will be released after it idled for // too long and timed out return true; }
Example 8
Source File: AllocatedSlotsTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testOperations() throws Exception { SlotPoolImpl.AllocatedSlots allocatedSlots = new SlotPoolImpl.AllocatedSlots(); final AllocationID allocation1 = new AllocationID(); final SlotRequestId slotRequestID = new SlotRequestId(); final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); final ResourceID resource1 = taskManagerLocation.getResourceID(); final AllocatedSlot slot1 = createSlot(allocation1, taskManagerLocation); allocatedSlots.add(slotRequestID, slot1); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.size()); final AllocationID allocation2 = new AllocationID(); final SlotRequestId slotRequestID2 = new SlotRequestId(); final AllocatedSlot slot2 = createSlot(allocation2, taskManagerLocation); allocatedSlots.add(slotRequestID2, slot2); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(slot2, allocatedSlots.get(allocation2)); assertEquals(2, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(2, allocatedSlots.size()); final AllocationID allocation3 = new AllocationID(); final SlotRequestId slotRequestID3 = new SlotRequestId(); final TaskManagerLocation taskManagerLocation2 = new LocalTaskManagerLocation(); final ResourceID resource2 = taskManagerLocation2.getResourceID(); final AllocatedSlot slot3 = createSlot(allocation3, taskManagerLocation2); allocatedSlots.add(slotRequestID3, slot3); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(slot2, allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(2, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(3, allocatedSlots.size()); allocatedSlots.remove(slot2.getAllocationId()); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(2, allocatedSlots.size()); allocatedSlots.remove(slot1.getAllocationId()); assertFalse(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertFalse(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertNull(allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(1, allocatedSlots.size()); allocatedSlots.remove(slot3.getAllocationId()); assertFalse(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertFalse(allocatedSlots.contains(slot3.getAllocationId())); assertFalse(allocatedSlots.containResource(resource1)); assertFalse(allocatedSlots.containResource(resource2)); assertNull(allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertNull(allocatedSlots.get(allocation3)); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(0, allocatedSlots.size()); }
Example 9
Source File: SlotPoolImpl.java From flink with Apache License 2.0 | 4 votes |
/** * Slot offering by TaskExecutor with AllocationID. The AllocationID is originally generated by this pool and * transfer through the ResourceManager to TaskManager. We use it to distinguish the different allocation * we issued. Slot offering may be rejected if we find something mismatching or there is actually no pending * request waiting for this slot (maybe fulfilled by some other returned slot). * * @param taskManagerLocation location from where the offer comes from * @param taskManagerGateway TaskManager gateway * @param slotOffer the offered slot * @return True if we accept the offering */ boolean offerSlot( final TaskManagerLocation taskManagerLocation, final TaskManagerGateway taskManagerGateway, final SlotOffer slotOffer) { componentMainThreadExecutor.assertRunningInMainThread(); // check if this TaskManager is valid final ResourceID resourceID = taskManagerLocation.getResourceID(); final AllocationID allocationID = slotOffer.getAllocationId(); if (!registeredTaskManagers.contains(resourceID)) { log.debug("Received outdated slot offering [{}] from unregistered TaskManager: {}", slotOffer.getAllocationId(), taskManagerLocation); return false; } // check whether we have already using this slot AllocatedSlot existingSlot; if ((existingSlot = allocatedSlots.get(allocationID)) != null || (existingSlot = availableSlots.get(allocationID)) != null) { // we need to figure out if this is a repeated offer for the exact same slot, // or another offer that comes from a different TaskManager after the ResourceManager // re-tried the request // we write this in terms of comparing slot IDs, because the Slot IDs are the identifiers of // the actual slots on the TaskManagers // Note: The slotOffer should have the SlotID final SlotID existingSlotId = existingSlot.getSlotId(); final SlotID newSlotId = new SlotID(taskManagerLocation.getResourceID(), slotOffer.getSlotIndex()); if (existingSlotId.equals(newSlotId)) { log.info("Received repeated offer for slot [{}]. Ignoring.", allocationID); // return true here so that the sender will get a positive acknowledgement to the retry // and mark the offering as a success return true; } else { // the allocation has been fulfilled by another slot, reject the offer so the task executor // will offer the slot to the resource manager return false; } } final AllocatedSlot allocatedSlot = new AllocatedSlot( allocationID, taskManagerLocation, slotOffer.getSlotIndex(), slotOffer.getResourceProfile(), taskManagerGateway); // use the slot to fulfill pending request, in requested order tryFulfillSlotRequestOrMakeAvailable(allocatedSlot); // we accepted the request in any case. slot will be released after it idled for // too long and timed out return true; }
Example 10
Source File: AllocatedSlotsTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testOperations() throws Exception { SlotPoolImpl.AllocatedSlots allocatedSlots = new SlotPoolImpl.AllocatedSlots(); final AllocationID allocation1 = new AllocationID(); final SlotRequestId slotRequestID = new SlotRequestId(); final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); final ResourceID resource1 = taskManagerLocation.getResourceID(); final AllocatedSlot slot1 = createSlot(allocation1, taskManagerLocation); allocatedSlots.add(slotRequestID, slot1); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.size()); final AllocationID allocation2 = new AllocationID(); final SlotRequestId slotRequestID2 = new SlotRequestId(); final AllocatedSlot slot2 = createSlot(allocation2, taskManagerLocation); allocatedSlots.add(slotRequestID2, slot2); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(slot2, allocatedSlots.get(allocation2)); assertEquals(2, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(2, allocatedSlots.size()); final AllocationID allocation3 = new AllocationID(); final SlotRequestId slotRequestID3 = new SlotRequestId(); final TaskManagerLocation taskManagerLocation2 = new LocalTaskManagerLocation(); final ResourceID resource2 = taskManagerLocation2.getResourceID(); final AllocatedSlot slot3 = createSlot(allocation3, taskManagerLocation2); allocatedSlots.add(slotRequestID3, slot3); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertTrue(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertEquals(slot2, allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(2, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(3, allocatedSlots.size()); allocatedSlots.remove(slot2.getAllocationId()); assertTrue(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertTrue(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertEquals(slot1, allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(2, allocatedSlots.size()); allocatedSlots.remove(slot1.getAllocationId()); assertFalse(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertTrue(allocatedSlots.contains(slot3.getAllocationId())); assertFalse(allocatedSlots.containResource(resource1)); assertTrue(allocatedSlots.containResource(resource2)); assertNull(allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertEquals(slot3, allocatedSlots.get(allocation3)); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(1, allocatedSlots.size()); allocatedSlots.remove(slot3.getAllocationId()); assertFalse(allocatedSlots.contains(slot1.getAllocationId())); assertFalse(allocatedSlots.contains(slot2.getAllocationId())); assertFalse(allocatedSlots.contains(slot3.getAllocationId())); assertFalse(allocatedSlots.containResource(resource1)); assertFalse(allocatedSlots.containResource(resource2)); assertNull(allocatedSlots.get(allocation1)); assertNull(allocatedSlots.get(allocation2)); assertNull(allocatedSlots.get(allocation3)); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource1).size()); assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource2).size()); assertEquals(0, allocatedSlots.size()); }