use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class SlotPoolBatchSlotRequestTest method testPendingBatchSlotRequestDoesNotTimeoutIfFulfillingSlotExists.
/**
* Tests that a batch slot request won't time out if there exists a slot in the SlotPool which
* fulfills the requested {@link ResourceProfile}.
*/
@Test
public void testPendingBatchSlotRequestDoesNotTimeoutIfFulfillingSlotExists() throws Exception {
final Time batchSlotTimeout = Time.milliseconds(2L);
final ManualClock clock = new ManualClock();
try (final DeclarativeSlotPoolBridge slotPool = createAndSetUpSlotPool(mainThreadExecutor, null, batchSlotTimeout, clock)) {
SlotPoolUtils.requestNewAllocatedBatchSlot(slotPool, mainThreadExecutor, resourceProfile);
SlotPoolUtils.offerSlots(slotPool, mainThreadExecutor, Arrays.asList(resourceProfile));
final CompletableFuture<PhysicalSlot> firstPendingSlotFuture = SlotPoolUtils.requestNewAllocatedBatchSlot(slotPool, mainThreadExecutor, ResourceProfile.UNKNOWN);
final CompletableFuture<PhysicalSlot> secondPendingSlotFuture = SlotPoolUtils.requestNewAllocatedBatchSlot(slotPool, mainThreadExecutor, resourceProfile);
final List<CompletableFuture<PhysicalSlot>> slotFutures = Arrays.asList(firstPendingSlotFuture, secondPendingSlotFuture);
advanceTimeAndTriggerCheckBatchSlotTimeout(slotPool, mainThreadExecutor, clock, batchSlotTimeout);
for (CompletableFuture<PhysicalSlot> slotFuture : slotFutures) {
assertThat(slotFuture.isDone(), is(false));
}
}
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class ComponentClosingUtilsTest method setup.
@Before
public void setup() {
clock = new ManualClock();
ComponentClosingUtils.setClock(clock);
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class DeploymentStateTimeMetricsTest method testGetCurrentTime.
@Test
void testGetCurrentTime() {
final ManualClock clock = new ManualClock(Duration.ofMillis(5).toNanos());
final DeploymentStateTimeMetrics metrics = new DeploymentStateTimeMetrics(JobType.BATCH, settings, clock);
final ExecutionAttemptID id1 = new ExecutionAttemptID();
final ExecutionAttemptID id2 = new ExecutionAttemptID();
metrics.onStateUpdate(id1, ExecutionState.CREATED, ExecutionState.SCHEDULED);
metrics.onStateUpdate(id1, ExecutionState.SCHEDULED, ExecutionState.DEPLOYING);
clock.advanceTime(Duration.ofMillis(5));
assertThat(metrics.getCurrentTime()).isEqualTo(5L);
}
Aggregations