### Question:
TaskSlotTable implements TimeoutListener<AllocationID> { public boolean tryMarkSlotActive(JobID jobId, AllocationID allocationId) { TaskSlot taskSlot = getTaskSlot(allocationId); if (taskSlot != null && taskSlot.isAllocated(jobId, allocationId)) { return taskSlot.markActive(); } else { return false; } } TaskSlotTable(
		final Collection<ResourceProfile> resourceProfiles,
		final TimerService<AllocationID> timerService); void start(SlotActions initialSlotActions); void stop(); Set<AllocationID> getAllocationIdsPerJob(JobID jobId); SlotReport createSlotReport(ResourceID resourceId); boolean allocateSlot(int index, JobID jobId, AllocationID allocationId, Time slotTimeout); boolean markSlotActive(AllocationID allocationId); boolean markSlotInactive(AllocationID allocationId, Time slotTimeout); int freeSlot(AllocationID allocationId); int freeSlot(AllocationID allocationId, Throwable cause); boolean isValidTimeout(AllocationID allocationId, UUID ticket); boolean isAllocated(int index, JobID jobId, AllocationID allocationId); boolean tryMarkSlotActive(JobID jobId, AllocationID allocationId); boolean isSlotFree(int index); boolean hasAllocatedSlots(JobID jobId); Iterator<TaskSlot> getAllocatedSlots(JobID jobId); Iterator<AllocationID> getActiveSlots(JobID jobId); @Nullable JobID getOwningJob(AllocationID allocationId); boolean addTask(Task task); Task removeTask(ExecutionAttemptID executionAttemptID); Task getTask(ExecutionAttemptID executionAttemptID); Iterator<Task> getTasks(JobID jobId); AllocationID getCurrentAllocation(int index); @Override void notifyTimeout(AllocationID key, UUID ticket);  }### Answer:
@Test public void testTryMarkSlotActive() throws SlotNotFoundException { final TaskSlotTable taskSlotTable = createTaskSlotTable(Collections.nCopies(3, ResourceProfile.UNKNOWN)); try { taskSlotTable.start(new TestingSlotActionsBuilder().build()); final JobID jobId1 = new JobID(); final AllocationID allocationId1 = new AllocationID(); taskSlotTable.allocateSlot(0, jobId1, allocationId1, SLOT_TIMEOUT); final AllocationID allocationId2 = new AllocationID(); taskSlotTable.allocateSlot(1, jobId1, allocationId2, SLOT_TIMEOUT); final AllocationID allocationId3 = new AllocationID(); final JobID jobId2 = new JobID(); taskSlotTable.allocateSlot(2, jobId2, allocationId3, SLOT_TIMEOUT); taskSlotTable.markSlotActive(allocationId1); assertThat(taskSlotTable.isAllocated(0, jobId1, allocationId1), is(true)); assertThat(taskSlotTable.isAllocated(1, jobId1, allocationId2), is(true)); assertThat(taskSlotTable.isAllocated(2, jobId2, allocationId3), is(true)); assertThat(IteratorUtils.toList(taskSlotTable.getActiveSlots(jobId1)), is(equalTo(Arrays.asList(allocationId1)))); assertThat(taskSlotTable.tryMarkSlotActive(jobId1, allocationId1), is(true)); assertThat(taskSlotTable.tryMarkSlotActive(jobId1, allocationId2), is(true)); assertThat(taskSlotTable.tryMarkSlotActive(jobId1, allocationId3), is(false)); assertThat(Sets.newHashSet(taskSlotTable.getActiveSlots(jobId1)), is(equalTo(new HashSet<>(Arrays.asList(allocationId2, allocationId1))))); } finally { taskSlotTable.stop(); } }