use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class JobStatusMetricsTest method testTotalTimeMetric.
@Test
void testTotalTimeMetric() {
final ManualClock clock = new ManualClock(0);
final JobStatusMetrics jobStatusMetrics = new JobStatusMetrics(0L, enable(MetricOptions.JobStatusMetrics.STATE, MetricOptions.JobStatusMetrics.CURRENT_TIME, MetricOptions.JobStatusMetrics.TOTAL_TIME), clock);
final StateTimeMetric metric = jobStatusMetrics.createTimeMetric(JobStatus.RUNNING);
assertThat(metric.getTotalTime()).isEqualTo(0L);
jobStatusMetrics.jobStatusChanges(new JobID(), JobStatus.RUNNING, clock.absoluteTimeMillis());
clock.advanceTime(Duration.ofMillis(10));
assertThat(metric.getTotalTime()).isEqualTo(10L);
jobStatusMetrics.jobStatusChanges(new JobID(), JobStatus.RESTARTING, clock.absoluteTimeMillis());
clock.advanceTime(Duration.ofMillis(4));
assertThat(metric.getTotalTime()).isEqualTo(10L);
jobStatusMetrics.jobStatusChanges(new JobID(), JobStatus.RUNNING, clock.absoluteTimeMillis());
clock.advanceTime(Duration.ofMillis(1));
assertThat(metric.getTotalTime()).isEqualTo(11L);
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class DeploymentStateTimeMetricsTest method testGetTotalTime.
@Test
void testGetTotalTime() {
final ManualClock clock = new ManualClock(Duration.ofMillis(5).toNanos());
final DeploymentStateTimeMetrics metrics = new DeploymentStateTimeMetrics(JobType.BATCH, settings, clock);
final ExecutionAttemptID id1 = new ExecutionAttemptID();
metrics.onStateUpdate(id1, ExecutionState.CREATED, ExecutionState.SCHEDULED);
metrics.onStateUpdate(id1, ExecutionState.SCHEDULED, ExecutionState.DEPLOYING);
clock.advanceTime(Duration.ofMillis(5));
metrics.onStateUpdate(id1, ExecutionState.DEPLOYING, ExecutionState.FINISHED);
assertThat(metrics.getTotalTime()).isEqualTo(5L);
final ExecutionAttemptID id2 = new ExecutionAttemptID();
metrics.onStateUpdate(id2, ExecutionState.CREATED, ExecutionState.SCHEDULED);
metrics.onStateUpdate(id2, ExecutionState.SCHEDULED, ExecutionState.DEPLOYING);
clock.advanceTime(Duration.ofMillis(5));
metrics.onStateUpdate(id2, ExecutionState.DEPLOYING, ExecutionState.FINISHED);
assertThat(metrics.getTotalTime()).isEqualTo(10L);
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class DeploymentStateTimeMetricsTest method testInitialValues.
@Test
void testInitialValues() {
final ManualClock clock = new ManualClock(Duration.ofMillis(5).toNanos());
final DeploymentStateTimeMetrics deploymentStateTimeMetrics = new DeploymentStateTimeMetrics(JobType.BATCH, settings, clock);
assertThat(deploymentStateTimeMetrics.getCurrentTime()).isEqualTo(0L);
assertThat(deploymentStateTimeMetrics.getTotalTime()).isEqualTo(0L);
assertThat(deploymentStateTimeMetrics.getBinary()).isEqualTo(0L);
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class DeploymentStateTimeMetricsTest method testGetCurrentTimeResetOndDeployentEnd.
@Test
void testGetCurrentTimeResetOndDeployentEnd() {
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);
metrics.onStateUpdate(id1, ExecutionState.DEPLOYING, ExecutionState.INITIALIZING);
assertThat(metrics.getCurrentTime()).isEqualTo(0L);
}
use of org.apache.flink.util.clock.ManualClock in project flink by apache.
the class DeploymentStateTimeMetricsTest method testGetTotalTimeIncludesCurrentTime.
@Test
void testGetTotalTimeIncludesCurrentTime() {
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.getTotalTime()).isEqualTo(5L);
}
Aggregations