You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "spuru9 (via GitHub)" <gi...@apache.org> on 2026/04/28 18:44:42 UTC
[PR] [runtime-web] Add checkpoint duration Gantt view [flink]
spuru9 opened a new pull request, #28060:
URL: https://github.com/apache/flink/pull/28060
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
*(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
## Brief change log
*(for example:)*
- *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
- *Deployments RPC transmits only the blob storage reference*
- *TaskManagers retrieve the TaskInfo from the blob cache*
## Verifying this change
Please make sure both new and modified tests in this PR follow [the conventions for tests defined in our code quality guide](https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#7-testing).
*(Please pick either of the following options)*
This change is a trivial rework / code cleanup without any test coverage.
*(or)*
This change is already covered by existing tests, such as *(please describe tests)*.
*(or)*
This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads (100MB)*
- *Extended integration test for recovery after master (JobManager) failure*
- *Added test that validates that TaskInfo is transferred only once across recoveries*
- *Manually verified the change by running a 4 node cluster with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
- The serializers: (yes / no / don't know)
- The runtime per-record code paths (performance sensitive): (yes / no / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
- The S3 file system connector: (yes / no / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR, please
change the checkbox below to `[X]` followed by the name of the tool, and uncomment the
"Generated-by" line. See the ASF Generative Tooling Guidance for details:
https://www.apache.org/legal/generative-tooling.html
You are responsible for the quality and correctness of every change in this PR
regardless of the tooling used. Low-effort AI-generated PRs will be closed. See
AGENTS.md for the full guidance.
-->
- [ ] Yes (please specify the tool below)
<!--
Generated-by: [Tool Name and Version]
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub) via issues" <is...@flink.apache.org>.
spuru9 commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-6615345958
Adding a demo after the new fixes
https://github.com/user-attachments/assets/4a700e02-900b-4552-a0a0-b704d31ccabe
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-5087820783
>How about going with a middle ground and starting a discussion the dev@ mailing list, asking for additional feedback?
Thanks @rmetzger and +1 to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r3735206534
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,764 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import * as G2 from '@antv/g2';
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ outlier: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzToolTipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private timelineChart?: Chart;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(private readonly jobService: JobService, private readonly cdr: ChangeDetectorRef) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.clearTimeline();
+ this.renderStrip();
+ }
Review Comment:
`detailsCache` is keyed only by checkpoint id and is not cleared when the `jobId` input changes. If the user navigates to another job (same component instance) and checkpoint ids overlap (common starting at 1), cached per-vertex subtask details from the previous job can be shown for the new job.
This issue also appears on line 502 of the same file.
##########
flink-runtime-web/web-dashboard/src/app/services/job.service.ts:
##########
@@ -183,6 +183,23 @@ export class JobService {
);
}
+ public loadCheckpointAllSubtaskDetails(
+ jobId: string,
+ checkPointId: number,
+ vertexIds: string[]
+ ): Observable<Record<string, CheckpointSubTask | null>> {
+ if (vertexIds.length === 0) {
+ return of({} as Record<string, CheckpointSubTask | null>);
+ }
+ const requests = vertexIds.map(vid =>
+ this.loadCheckpointSubtaskDetails(jobId, checkPointId, vid).pipe(
+ catchError(() => of<CheckpointSubTask | null>(null)),
+ map(result => ({ [vid]: result }))
+ )
+ );
+ return forkJoin(requests).pipe(map(parts => Object.assign({}, ...parts)));
+ }
Review Comment:
`loadCheckpointAllSubtaskDetails` fires one HTTP request per vertex in a single `forkJoin`, which can create very high parallelism (and repeated bursts if the user follows newest). For large jobs this can overwhelm the browser connection pool and the JobManager, and it also makes the whole call wait for the slowest request. Consider chunking the requests (bounded concurrency) while still returning a single merged map.
##########
flink-runtime-web/web-dashboard/src/app/app.interceptor.ts:
##########
@@ -59,9 +59,18 @@ export class AppInterceptor implements HttpInterceptor {
window.location.href = String(res.headers.get('Location'));
}
+ // A per-subtask checkpoint fetch can race the JM reaping that checkpoint (or hit it
+ // before it acks), yielding a benign 404. Suppress only that case; real 5xx/auth on
+ // the same path still surface.
+ const isExpectedSubtaskNotFound =
+ res instanceof HttpResponseBase &&
+ res.status === HttpStatusCode.NotFound &&
+ /\/checkpoints\/details\/\d+\/subtasks\//.test(res.url || '');
+
Review Comment:
This interceptor suppresses the global error toast for *all* 404s on `/checkpoints/details/<id>/subtasks/...`, regardless of whether the checkpoint is merely "in progress" (race-before-ack) vs genuinely unavailable (e.g., retained history expired, wrong vertex id). This is broader than the PR description (“while a checkpoint is still in progress”) and also affects existing pages like the subtask checkpoint view that rely on the toast to explain why the data didn’t load. Consider scoping the suppression to timeline-originated requests (e.g., set a custom request header in the timeline fetches and check it here), or otherwise gating it on an in-progress checkpoint context.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub) via issues" <is...@flink.apache.org>.
spuru9 commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4459941196
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
+ return;
+ }
+
+ const newest = this.toStripDatum(next[0]);
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(newest, false);
+ return;
+ }
+ // Still the same newest checkpoint: reload once it gained acks or finished, or retry a failed load once
+ // (retrying on every poll would repeat the error notifications). Not while a load is in flight, so polling
+ // doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ if (selected?.id !== newest.id || this.loadingTimeline) {
+ return;
+ }
+ const progressed = newest.rawStatus !== selected.rawStatus || newest.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== newest.id;
+ if (retry) {
+ this.retriedCheckpointId = newest.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(newest, false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ // Disabled periodic checkpointing reports Long.MAX_VALUE, which the upper clamp covers.
+ const interval = this.config?.interval ?? 0;
+ return interval > 0
+ ? Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ )
+ : JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ // The component also lives in the hidden tab; don't fetch every vertex's details until it is shown.
+ if (!this.visible$.value) {
+ this.loadDeferred = true;
+ return;
+ }
+ this.loadDeferred = false;
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadError = undefined;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ // In-progress stats still change; only cache terminal checkpoints. `status` is 'SAVEPOINT' for an in-progress
+ // savepoint, so check rawStatus.
+ if (datum.rawStatus === 'IN_PROGRESS') {
+ return;
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.visible$
+ .pipe(
+ filter(visible => visible && this.loadDeferred),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(() => {
+ if (this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ });
+
+ this.loadTimeline$
+ .pipe(
+ switchMap((datum): Observable<TimelineLoad> => {
+ if (!datum) {
+ return EMPTY;
+ }
+ const requestedCount = this.vertices.length;
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({ datum, perVertex: cached, failedCount: 0, requestedCount });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const failedCount = requestedCount - Object.values(perVertex).filter(v => v !== null).length;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ const error: LoadError | undefined =
+ requestedCount > 0 && failedCount === requestedCount ? 'not-retained' : undefined;
+ return { datum, perVertex, failedCount, requestedCount, error };
+ }),
+ catchError(() =>
+ of<TimelineLoad>({
+ datum,
+ perVertex: {},
+ failedCount: requestedCount,
+ requestedCount,
+ error: 'request-failed'
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failedCount, requestedCount, error }) => {
+ this.loadingTimeline = false;
+ if (error) {
+ this.showEmptyTimeline(error);
+ return;
+ }
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const startDelay = Math.max(s.start_delay || 0, 0);
+ const reportedAlignment = Math.max(s.alignment.duration || 0, 0);
+ const unaligned = !!s.unaligned_checkpoint;
+ // In an unaligned checkpoint, async already includes the alignment (checkpoint_monitoring.md), so don't stack it.
+ const alignment = unaligned ? 0 : reportedAlignment;
+ const sync = Math.max(s.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(s.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
+ ];
+ let cursor = base;
+ for (const [phase, ms] of segs) {
+ if (ms > 0) {
+ rows.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ phase,
+ phaseLabel: phase === 'async' && unaligned ? `${phase} (incl. ${reportedAlignment}ms alignment)` : phase,
+ range: [cursor, cursor + ms],
+ durationMs: ms,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ totalDuration: total
+ });
+ }
+ cursor += ms;
+ }
+ }
+ }
+
+ // Unacked subtasks span the whole checkpoint: until it failed, or the latest ack so far while in progress.
+ const unackedEnd = base + Math.max(datum.duration, maxTotal, 1);
+ for (const u of unacked) {
+ u.range = [base, unackedEnd];
+ }
+
+ return { rows, unacked, instants, rowOrder };
+ }
+
+ private renderTimeline(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ const { rows, unacked, instants, rowOrder } = this.buildTimelineRows(datum, perVertex);
+ if (rowOrder.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.timelineEmpty = false;
+ this.cdr.markForCheck();
+
+ const C = JobCheckpointsTimelineComponent;
+ const chartHeight = Math.max(
Review Comment:
Have made some changes. Shows the N slowest subtasks: 25 by default, up to 200 or the row count. The chart is at most 25 rows tall, scrolls inside, and redraws only the visible rows. There's a "slowest first" checkbox, and the time axis is on top.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub)" <gi...@apache.org>.
spuru9 commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-4847647213
@Laffery @MartijnVisser Could you help with a review here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub) via issues" <is...@flink.apache.org>.
spuru9 commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4485612301
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,1047 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgFor, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { formatTimeAxis, startAlignedTicks } from '@flink-runtime-web/utils';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+interface TimelineRows {
+ rows: TimelineDatum[];
+ unacked: UnackedDatum[];
+ instants: InstantDatum[];
+ rowOrder: string[];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+type IntervalMark = ReturnType<Chart['interval']>;
+
+// Built once and updated in place on reloads, so following an in-progress checkpoint doesn't rebuild the canvas.
+interface TimelineChart {
+ chart: Chart;
+ phases: IntervalMark;
+ unacked: IntervalMark;
+ instants: IntervalMark;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgFor,
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineScroll', { static: true }) private readonly timelineScroll: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineWrapper', { static: true }) private readonly timelineWrapper: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+ // Rows of the shown checkpoint, how many of the slowest are shown, and the first one scrolled to.
+ public totalRows = 0;
+ public slowestCount = JobCheckpointsTimelineComponent.SHOWN_ROWS_DEFAULT;
+ public firstRow = 0;
+ public chartHeight = 0;
+ public slowestFirst = false;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: IntervalMark;
+ private timeline?: TimelineChart;
+ // Full operator name per row label, for the native tooltip on the truncated labels.
+ private rowTitles = new Map<string, string>();
+ // Kept so scrolling can redraw another window of rows without rebuilding them.
+ private timelineRows?: TimelineRows & { datum: StripDatum; slowestOrder: string[] };
+ private scrollFrame?: number;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ // Holds only the checkpoints that can be selected again: those in the strip, plus the pinned one.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ // paddingTop (time axis) + paddingBottom, plus a little slack.
+ private static readonly TIMELINE_HEIGHT_BASE = 56;
+ // Rows shown by default (the slowest) and the most that can be picked; the chart is at most VISIBLE_ROWS tall.
+ private static readonly SHOWN_ROWS_DEFAULT = 25;
+ private static readonly SHOWN_ROWS_MAX = 200;
+ private static readonly VISIBLE_ROWS = 25;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
Review Comment:
Agreed this would be nicer. It changes how the other tabs refresh as well, so I've opened FLINK-41364 to follow up on it separately. Have addressed other comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "rmetzger (via GitHub)" <gi...@apache.org>.
rmetzger commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-5087750786
Thanks for reviewing this change @RocMarshal. @spuru9 has asked me to review this as well, but it didn't get to it yet, so thanks for taking a look and moving this forward.
I am not sure if a full FLIP is needed. The change is only about 1100 lines big (size does not determine whether a FLIP is needed, a breaking API change can be a single line change, and still require a FLIP).
I do agree that more feedback about this change would be good, because it is a very visible feature. I also have to admin that just from looking at the screenshots alone, I don't immediately understand if this visualized checkpoint info is correct or not.
How about going with a middle ground and starting a discussion the dev@ mailing list, asking for additional feedback?
If you still think a FLIP is needed, we should do it. I think you have more experience with the UI, you've looked closer at this PR than I and you are currently more active than I, so I am leaving the final decision to you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub) via issues" <is...@flink.apache.org>.
spuru9 commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-6554061644
Updated screenshots after the rebase onto g2 v5 and the outline rework; they replace the one that was in the description.
**Completed checkpoint**
<img width="1046" height="225" alt="1-completed" src="https://github.com/user-attachments/assets/54f69c7d-8d45-4c45-a143-b18bf7bd8fce" />
**Failed checkpoint:** one aborted subtask (dashed outline) and two that never acked (hatched "no ack")
<img width="1046" height="258" alt="2-failed" src="https://github.com/user-attachments/assets/edefdb28-0fe7-4365-9633-9cc5cf7e3f33" />
**In-progress checkpoint:** 5 of 6 subtasks acked; the hatched row hasn't reported yet
<img width="1046" height="269" alt="3-in-progress" src="https://github.com/user-attachments/assets/1c4afe3c-b2f2-45ed-af73-a545f62b22b4" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub) via issues" <is...@flink.apache.org>.
spuru9 commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-6615363930
@ferenc-csaky Can you take another look, have addressed the comments and fixed the JIRA description.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub) via issues" <is...@flink.apache.org>.
spuru9 commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4434877200
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,146 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
Review Comment:
Out of scope for this PR: the dashboard's other charts are pointer-only as well, and the History tab already lists every checkpoint in a keyboard-accessible table.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,146 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
+ <nz-empty
+ *ngIf="!history || history.length === 0"
Review Comment:
Fixed: the empty state now reads the live polled history.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,855 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.detailsCache.clear();
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ const status: StripDatum['status'] = h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'FAILED'
+ ? 'FAILED'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
Review Comment:
Fixed: strip bars have a 3px minimum height; the tooltip keeps the real duration.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,855 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.detailsCache.clear();
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ const status: StripDatum['status'] = h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'FAILED'
+ ? 'FAILED'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ this.cdr.markForCheck();
+ return;
+ }
+
+ // Frozen while pinned; still markForCheck so the rotated-out note updates on poll.
+ if (this.userPinned) {
+ this.cdr.markForCheck();
+ return;
+ }
+
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(this.toStripDatum(next[0]), false);
+ }
Review Comment:
Fixed: while following, the newest checkpoint reloads when its status or ack count changes or its last load failed, skipping polls while a load is in flight; pinned checkpoints stay frozen.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,855 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.detailsCache.clear();
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ const status: StripDatum['status'] = h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'FAILED'
+ ? 'FAILED'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ this.cdr.markForCheck();
+ return;
+ }
+
+ // Frozen while pinned; still markForCheck so the rotated-out note updates on poll.
+ if (this.userPinned) {
+ this.cdr.markForCheck();
+ return;
+ }
+
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(this.toStripDatum(next[0]), false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ const interval = this.config?.interval;
+ if (
+ interval !== undefined &&
+ interval > 0 &&
+ interval < JobCheckpointsTimelineComponent.DISABLED_INTERVAL_THRESHOLD
+ ) {
+ return Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ );
+ }
+ return JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline(false);
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadFailed = false;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ if (datum.status === 'IN_PROGRESS') {
Review Comment:
Fixed: the cache check now uses `rawStatus`.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,855 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.detailsCache.clear();
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ const status: StripDatum['status'] = h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'FAILED'
+ ? 'FAILED'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ this.cdr.markForCheck();
+ return;
+ }
+
+ // Frozen while pinned; still markForCheck so the rotated-out note updates on poll.
+ if (this.userPinned) {
+ this.cdr.markForCheck();
+ return;
+ }
+
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(this.toStripDatum(next[0]), false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ const interval = this.config?.interval;
+ if (
+ interval !== undefined &&
+ interval > 0 &&
+ interval < JobCheckpointsTimelineComponent.DISABLED_INTERVAL_THRESHOLD
+ ) {
+ return Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ );
+ }
+ return JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline(false);
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadFailed = false;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ if (datum.status === 'IN_PROGRESS') {
+ return; // in-progress stats still change; only cache terminal checkpoints
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.loadTimeline$
+ .pipe(
+ switchMap(datum => {
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({
+ datum,
+ perVertex: cached,
+ failed: false,
+ failedCount: 0,
+ requestedCount: this.vertices.length
+ });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ const requestedCount = vertexIds.length;
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const succeeded = Object.values(perVertex).filter(v => v !== null).length;
+ const failedCount = requestedCount - succeeded;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ return {
+ datum,
+ perVertex,
+ failed: requestedCount > 0 && succeeded === 0,
+ failedCount,
+ requestedCount
+ };
+ }),
+ catchError(() =>
+ of({
+ datum,
+ perVertex: {} as Record<string, CheckpointSubTask | null>,
+ failed: true,
+ failedCount: requestedCount,
+ requestedCount
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failed, failedCount, requestedCount }) => {
+ this.loadingTimeline = false;
+ if (failed) {
+ this.showEmptyTimeline(true);
+ return;
+ }
+ this.loadFailed = false;
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const completed = s;
+ const startDelay = Math.max(completed.start_delay || 0, 0);
+ const alignment = Math.max(completed.alignment.duration || 0, 0);
+ const sync = Math.max(completed.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(completed.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: completed.index,
+ aborted: !!completed.aborted,
+ stateSize: completed.state_size,
+ checkpointedSize: completed.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
Review Comment:
Fixed: alignment is no longer stacked for unaligned subtasks; the async tooltip shows it as included and 'total' excludes it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "Copilot (via GitHub) via issues" <is...@flink.apache.org>.
Copilot commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4434571127
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,146 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
Review Comment:
Checkpoint selection is only available through the chart's `interval:click` handler. This container has no focusable checkpoint controls or keyboard handling, so keyboard and screen-reader users cannot choose or pin a checkpoint; the Follow newest button only appears after a pointer selection. Please provide a labeled native checkpoint selector or focusable list wired to the same selection action, with an accessible equivalent for the chart values.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,146 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
+ <nz-empty
+ *ngIf="!history || history.length === 0"
Review Comment:
Polling updates `currentHistory`, not this `history` input, and the parent only refreshes its snapshot on initial load or a manual refresh. If the page is opened before the first checkpoint, polls can populate the strip and timeline while this still displays “No checkpoint history yet.” Please bind the empty state to the same live history used by the strip, exposed through a public field or getter.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,855 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.detailsCache.clear();
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ const status: StripDatum['status'] = h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'FAILED'
+ ? 'FAILED'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ this.cdr.markForCheck();
+ return;
+ }
+
+ // Frozen while pinned; still markForCheck so the rotated-out note updates on poll.
+ if (this.userPinned) {
+ this.cdr.markForCheck();
+ return;
+ }
+
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(this.toStripDatum(next[0]), false);
+ }
Review Comment:
When polling returns the same newest checkpoint ID, only the strip updates; the followed timeline keeps stale status, acknowledgement counts, and subtask details even after the checkpoint finishes. Refresh same-ID selections and retry unavailable details in follow mode, while preserving the intentional freeze for pinned selections. Coordinate reloads with in-flight requests so polling does not repeatedly cancel a slow fetch.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,855 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.detailsCache.clear();
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ const status: StripDatum['status'] = h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'FAILED'
+ ? 'FAILED'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
Review Comment:
The strip has no minimum bar height, so checkpoints with a zero duration produce invisible, unclickable bars. This also affects an IN_PROGRESS checkpoint before its first acknowledgement: the backend returns -1, which `toStripDatum` clamps to zero. Give these bars a minimum visual height, as the timeline already does for instant rows, while keeping the actual duration in the tooltip.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,855 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.detailsCache.clear();
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ const status: StripDatum['status'] = h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'FAILED'
+ ? 'FAILED'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ this.cdr.markForCheck();
+ return;
+ }
+
+ // Frozen while pinned; still markForCheck so the rotated-out note updates on poll.
+ if (this.userPinned) {
+ this.cdr.markForCheck();
+ return;
+ }
+
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(this.toStripDatum(next[0]), false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ const interval = this.config?.interval;
+ if (
+ interval !== undefined &&
+ interval > 0 &&
+ interval < JobCheckpointsTimelineComponent.DISABLED_INTERVAL_THRESHOLD
+ ) {
+ return Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ );
+ }
+ return JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline(false);
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadFailed = false;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ if (datum.status === 'IN_PROGRESS') {
Review Comment:
`status` is the strip's color category, so an in-progress savepoint has `status === 'SAVEPOINT'` and passes this guard. Its still-changing subtask data is then cached and reused even after the savepoint completes, including when the user reselects it or clicks Follow newest. Check `rawStatus` here so in-progress savepoints remain uncached just like ordinary checkpoints.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,855 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.detailsCache.clear();
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ const status: StripDatum['status'] = h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'FAILED'
+ ? 'FAILED'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ this.cdr.markForCheck();
+ return;
+ }
+
+ // Frozen while pinned; still markForCheck so the rotated-out note updates on poll.
+ if (this.userPinned) {
+ this.cdr.markForCheck();
+ return;
+ }
+
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(this.toStripDatum(next[0]), false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ const interval = this.config?.interval;
+ if (
+ interval !== undefined &&
+ interval > 0 &&
+ interval < JobCheckpointsTimelineComponent.DISABLED_INTERVAL_THRESHOLD
+ ) {
+ return Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ );
+ }
+ return JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline(false);
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadFailed = false;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ if (datum.status === 'IN_PROGRESS') {
+ return; // in-progress stats still change; only cache terminal checkpoints
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.loadTimeline$
+ .pipe(
+ switchMap(datum => {
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({
+ datum,
+ perVertex: cached,
+ failed: false,
+ failedCount: 0,
+ requestedCount: this.vertices.length
+ });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ const requestedCount = vertexIds.length;
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const succeeded = Object.values(perVertex).filter(v => v !== null).length;
+ const failedCount = requestedCount - succeeded;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ return {
+ datum,
+ perVertex,
+ failed: requestedCount > 0 && succeeded === 0,
+ failedCount,
+ requestedCount
+ };
+ }),
+ catchError(() =>
+ of({
+ datum,
+ perVertex: {} as Record<string, CheckpointSubTask | null>,
+ failed: true,
+ failedCount: requestedCount,
+ requestedCount
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failed, failedCount, requestedCount }) => {
+ this.loadingTimeline = false;
+ if (failed) {
+ this.showEmptyTimeline(true);
+ return;
+ }
+ this.loadFailed = false;
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const completed = s;
+ const startDelay = Math.max(completed.start_delay || 0, 0);
+ const alignment = Math.max(completed.alignment.duration || 0, 0);
+ const sync = Math.max(completed.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(completed.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: completed.index,
+ aborted: !!completed.aborted,
+ stateSize: completed.state_size,
+ checkpointedSize: completed.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
Review Comment:
For unaligned checkpoints, alignment overlaps snapshot work: `docs/content/docs/ops/monitoring/checkpoint_monitoring.md` documents that async duration includes waiting for the remaining barriers. Stacking alignment before sync/async therefore shifts the displayed wall-clock times and double-counts elapsed time. Represent overlapping phases, or show durations where exact boundaries cannot be inferred, and use the reported end-to-end duration for elapsed time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "ferenc-csaky (via GitHub) via issues" <is...@flink.apache.org>.
ferenc-csaky merged PR #28060:
URL: https://github.com/apache/flink/pull/28060
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-4338163912
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8adfc67e9c0e1cdba62b0d82538bcf3c5393841e",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "8adfc67e9c0e1cdba62b0d82538bcf3c5393841e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8adfc67e9c0e1cdba62b0d82538bcf3c5393841e UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub)" <gi...@apache.org>.
spuru9 commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-5186190193
Have started the thread https://lists.apache.org/thread/r46jtjp6nl21pkn3b44bkh2w9ldzr5z5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "nictownsend (via GitHub) via issues" <is...@flink.apache.org>.
nictownsend commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4480064433
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,174 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
+ <nz-empty *ngIf="!hasHistory" nzNotFoundContent="No checkpoint history yet"></nz-empty>
+ </section>
+
+ <section class="timeline-section">
+ <header class="timeline-header">
+ <div class="timeline-title">
+ <strong *ngIf="selected">
+ Checkpoint #{{ selected.id }}
+ <span
+ *ngIf="userPinned"
+ class="pin-badge"
+ title="Pinned: the timeline below will not change until you click another checkpoint or 'Follow newest'."
+ >
+ pinned
+ </span>
+ </strong>
+ <strong *ngIf="!selected">Per-subtask Timeline</strong>
+ <span *ngIf="selected" class="hint">
+ {{ selected.rawStatus }}
+ <ng-container *ngIf="selected.isSavepoint">· savepoint</ng-container>
+ · triggered {{ selected.triggered | date: 'yyyy-MM-dd HH:mm:ss.SSS' }} ·
+ {{ selected.duration | humanizeDuration }} · acked {{ selected.acked }} ·
+ {{ selected.size | humanizeBytes }}
+ </span>
+ <div class="timeline-actions">
+ <button *ngIf="userPinned" type="button" class="follow-newest" (click)="followNewest()">
Review Comment:
The rest of the repo uses `nz-button` rather than raw stylling
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,174 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
+ <nz-empty *ngIf="!hasHistory" nzNotFoundContent="No checkpoint history yet"></nz-empty>
+ </section>
+
+ <section class="timeline-section">
+ <header class="timeline-header">
+ <div class="timeline-title">
+ <strong *ngIf="selected">
+ Checkpoint #{{ selected.id }}
+ <span
+ *ngIf="userPinned"
+ class="pin-badge"
+ title="Pinned: the timeline below will not change until you click another checkpoint or 'Follow newest'."
+ >
+ pinned
+ </span>
+ </strong>
+ <strong *ngIf="!selected">Per-subtask Timeline</strong>
+ <span *ngIf="selected" class="hint">
+ {{ selected.rawStatus }}
+ <ng-container *ngIf="selected.isSavepoint">· savepoint</ng-container>
+ · triggered {{ selected.triggered | date: 'yyyy-MM-dd HH:mm:ss.SSS' }} ·
+ {{ selected.duration | humanizeDuration }} · acked {{ selected.acked }} ·
+ {{ selected.size | humanizeBytes }}
+ </span>
+ <div class="timeline-actions">
+ <button *ngIf="userPinned" type="button" class="follow-newest" (click)="followNewest()">
+ Follow newest
+ </button>
+ </div>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch phase-start"></span>
+ start_delay
+ </li>
+ <li>
+ <span class="swatch phase-align"></span>
+ alignment
+ </li>
+ <li>
+ <span class="swatch phase-sync"></span>
+ sync
+ </li>
+ <li>
+ <span class="swatch phase-async"></span>
+ async
+ </li>
+ <li nz-tooltip [nzTooltipTitle]="abortedTip" nzTooltipPlacement="bottom">
+ <span class="swatch aborted"></span>
+ aborted
+ </li>
+ <li nz-tooltip [nzTooltipTitle]="noAckTip" nzTooltipPlacement="bottom">
+ <span class="swatch no-ack"></span>
+ no ack
+ </li>
+ <ng-template #abortedTip>
+ Started its snapshot, but the checkpoint failed before it finished. The bar shows the
+ partial work.
+ </ng-template>
+ <ng-template #noAckTip>
+ Reported no statistics for this checkpoint: still pending, or never acknowledged before
+ the checkpoint failed (for example, the barrier never arrived). The bar spans the whole
+ checkpoint.
+ </ng-template>
+ </ul>
+ </header>
+
+ <!-- Reserve the line while a checkpoint is selected so the chart doesn't shift. -->
+ <div *ngIf="selected" class="timeline-note">
+ <span *ngIf="selectedRotatedOut && !timelineEmpty">
+ Checkpoint #{{ selected?.id }} is no longer in the recent-checkpoints strip above — showing
+ the frozen snapshot from when it was pinned.
+ </span>
+ <span *ngIf="totalRows > 1 && !timelineEmpty" class="timeline-controls">
+ <!-- Text, not whitespace-only nodes, around the select: Angular drops whitespace-only nodes. -->
+ <span *ngIf="slowestCountOptions.length > 0">
+ {{ shownRows < totalRows ? 'Showing the' : 'Showing all' }}
+ <select
+ class="row-count"
+ aria-label="Number of slowest subtasks shown"
+ (change)="onSlowestCountChange($event)"
+ >
+ <option *ngFor="let n of slowestCountOptions" [value]="n" [selected]="n === shownRows">
+ {{ n }}
+ </option>
+ </select>
+ {{ shownRows < totalRows ? 'slowest of ' + totalRows + ' subtasks' : 'subtasks' }}
+ {{ scrollable ? '· rows ' + (firstRow + 1) + '–' + (firstRow + visibleRows) : '' }}
+ </span>
+ <label class="slowest-first">
+ <input type="checkbox" [checked]="slowestFirst" (change)="onSlowestFirstChange($event)" />
Review Comment:
The rest of the repo uses `nz-checkbox` rather than raw stylling
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,174 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
+ <nz-empty *ngIf="!hasHistory" nzNotFoundContent="No checkpoint history yet"></nz-empty>
+ </section>
+
+ <section class="timeline-section">
+ <header class="timeline-header">
+ <div class="timeline-title">
+ <strong *ngIf="selected">
+ Checkpoint #{{ selected.id }}
+ <span
+ *ngIf="userPinned"
+ class="pin-badge"
+ title="Pinned: the timeline below will not change until you click another checkpoint or 'Follow newest'."
+ >
+ pinned
+ </span>
+ </strong>
+ <strong *ngIf="!selected">Per-subtask Timeline</strong>
+ <span *ngIf="selected" class="hint">
+ {{ selected.rawStatus }}
+ <ng-container *ngIf="selected.isSavepoint">· savepoint</ng-container>
+ · triggered {{ selected.triggered | date: 'yyyy-MM-dd HH:mm:ss.SSS' }} ·
+ {{ selected.duration | humanizeDuration }} · acked {{ selected.acked }} ·
+ {{ selected.size | humanizeBytes }}
+ </span>
+ <div class="timeline-actions">
+ <button *ngIf="userPinned" type="button" class="follow-newest" (click)="followNewest()">
+ Follow newest
+ </button>
+ </div>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch phase-start"></span>
+ start_delay
+ </li>
+ <li>
+ <span class="swatch phase-align"></span>
+ alignment
+ </li>
+ <li>
+ <span class="swatch phase-sync"></span>
+ sync
+ </li>
+ <li>
+ <span class="swatch phase-async"></span>
+ async
+ </li>
+ <li nz-tooltip [nzTooltipTitle]="abortedTip" nzTooltipPlacement="bottom">
+ <span class="swatch aborted"></span>
+ aborted
+ </li>
+ <li nz-tooltip [nzTooltipTitle]="noAckTip" nzTooltipPlacement="bottom">
+ <span class="swatch no-ack"></span>
+ no ack
+ </li>
+ <ng-template #abortedTip>
+ Started its snapshot, but the checkpoint failed before it finished. The bar shows the
+ partial work.
+ </ng-template>
+ <ng-template #noAckTip>
+ Reported no statistics for this checkpoint: still pending, or never acknowledged before
+ the checkpoint failed (for example, the barrier never arrived). The bar spans the whole
+ checkpoint.
+ </ng-template>
+ </ul>
+ </header>
+
+ <!-- Reserve the line while a checkpoint is selected so the chart doesn't shift. -->
+ <div *ngIf="selected" class="timeline-note">
+ <span *ngIf="selectedRotatedOut && !timelineEmpty">
+ Checkpoint #{{ selected?.id }} is no longer in the recent-checkpoints strip above — showing
+ the frozen snapshot from when it was pinned.
+ </span>
+ <span *ngIf="totalRows > 1 && !timelineEmpty" class="timeline-controls">
+ <!-- Text, not whitespace-only nodes, around the select: Angular drops whitespace-only nodes. -->
+ <span *ngIf="slowestCountOptions.length > 0">
+ {{ shownRows < totalRows ? 'Showing the' : 'Showing all' }}
+ <select
+ class="row-count"
Review Comment:
The rest of the repo uses `nz-select` rather than raw stylling
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,174 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
+ <nz-empty *ngIf="!hasHistory" nzNotFoundContent="No checkpoint history yet"></nz-empty>
+ </section>
+
+ <section class="timeline-section">
+ <header class="timeline-header">
+ <div class="timeline-title">
+ <strong *ngIf="selected">
+ Checkpoint #{{ selected.id }}
+ <span
+ *ngIf="userPinned"
+ class="pin-badge"
Review Comment:
There's an `ng-badge` and `nz-tag` component available
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.spec.ts:
##########
@@ -0,0 +1,672 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { HttpErrorResponse } from '@angular/common/http';
+import { ChangeDetectorRef, ElementRef, SimpleChange } from '@angular/core';
+import { BehaviorSubject, of, Subject, throwError } from 'rxjs';
+
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { JobCheckpointsTimelineComponent } from './job-checkpoints-timeline.component';
+
+const TRIGGERED = 1_000;
+
+interface Phases {
+ start_delay?: number;
+ alignment?: number;
+ sync?: number;
+ async?: number;
+}
+
+const completed = (index: number, phases: Phases, aborted = false): SubTaskCheckpointStatisticsItem =>
+ ({
+ index,
+ status: 'completed',
+ ack_timestamp: 0,
+ end_to_end_duration: 0,
+ checkpointed_size: 0,
+ state_size: 0,
+ checkpoint: { sync: phases.sync ?? 0, async: phases.async ?? 0 },
+ alignment: { buffer: 0, processed: 0, persisted: 0, duration: phases.alignment ?? 0 },
+ start_delay: phases.start_delay ?? 0,
+ unaligned_checkpoint: false,
+ aborted
+ }) as SubTaskCheckpointStatisticsItem;
+
+const noStats = (index: number): SubTaskCheckpointStatisticsItem =>
+ ({ index, status: 'pending_or_failed' }) as SubTaskCheckpointStatisticsItem;
+
+const details = (...subtasks: SubTaskCheckpointStatisticsItem[]): CheckpointSubTask =>
+ ({ subtasks }) as unknown as CheckpointSubTask;
+
+const vertex = (id: string, name: string): VerticesItem => ({ id, name, status: 'RUNNING' }) as VerticesItem;
+
+const checkpoint = (
+ rawStatus: string,
+ duration: number,
+ isSavepoint = false
+): { id: number; duration: number; rawStatus: string; isSavepoint: boolean; triggered: number } => ({
+ id: 7,
+ duration,
+ rawStatus,
+ isSavepoint,
+ triggered: TRIGGERED
+});
+
+type BuildRows = (
+ datum: ReturnType<typeof checkpoint>,
+ perVertex: Record<string, CheckpointSubTask | null>
+) => {
+ rows: Array<{ row: string; phase: string; phaseLabel: string; range: [number, number]; totalDuration: number }>;
+ unacked: Array<{ row: string; label: string; range: [number, number] }>;
+ instants: Array<{ row: string; aborted: boolean; range: [number, number] }>;
+ rowOrder: string[];
+};
+
+const unalignedConfig = (alignedCheckpointTimeout: number, mode = 'exactly_once'): CheckpointConfig =>
+ ({ mode, unaligned_checkpoints: true, aligned_checkpoint_timeout: alignedCheckpointTimeout }) as CheckpointConfig;
+
+const SUBTASK_PHASES = { start_delay: 2, alignment: 5, sync: 1, async: 8 };
+
+describe('JobCheckpointsTimelineComponent rows', () => {
+ let component: JobCheckpointsTimelineComponent;
+ let buildRows: BuildRows;
+
+ beforeEach(() => {
+ component = new JobCheckpointsTimelineComponent(
+ {} as JobService,
+ { markForCheck: () => undefined } as unknown as ChangeDetectorRef
+ );
+ buildRows = (component as unknown as { buildTimelineRows: BuildRows }).buildTimelineRows.bind(component);
+ });
+
+ it('keeps rows in operator then subtask order instead of sorting by duration', () => {
+ component.vertices = [vertex('a', 'Agg'), vertex('s', 'Sink')];
+
+ const { rowOrder } = buildRows(checkpoint('COMPLETED', 60), {
+ a: details(completed(0, { async: 5 }), completed(1, { async: 50 })),
Review Comment:
Can we swap the 5 and 50 for `a` - so that we get `agg 1, agg 0, sink 0` - just to avoid any regressions like "sort by index" would break this test.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.spec.ts:
##########
@@ -0,0 +1,672 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { HttpErrorResponse } from '@angular/common/http';
+import { ChangeDetectorRef, ElementRef, SimpleChange } from '@angular/core';
+import { BehaviorSubject, of, Subject, throwError } from 'rxjs';
+
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { JobCheckpointsTimelineComponent } from './job-checkpoints-timeline.component';
+
+const TRIGGERED = 1_000;
+
+interface Phases {
+ start_delay?: number;
+ alignment?: number;
+ sync?: number;
+ async?: number;
+}
+
+const completed = (index: number, phases: Phases, aborted = false): SubTaskCheckpointStatisticsItem =>
+ ({
+ index,
+ status: 'completed',
+ ack_timestamp: 0,
+ end_to_end_duration: 0,
+ checkpointed_size: 0,
+ state_size: 0,
+ checkpoint: { sync: phases.sync ?? 0, async: phases.async ?? 0 },
+ alignment: { buffer: 0, processed: 0, persisted: 0, duration: phases.alignment ?? 0 },
+ start_delay: phases.start_delay ?? 0,
+ unaligned_checkpoint: false,
+ aborted
+ }) as SubTaskCheckpointStatisticsItem;
+
+const noStats = (index: number): SubTaskCheckpointStatisticsItem =>
+ ({ index, status: 'pending_or_failed' }) as SubTaskCheckpointStatisticsItem;
+
+const details = (...subtasks: SubTaskCheckpointStatisticsItem[]): CheckpointSubTask =>
+ ({ subtasks }) as unknown as CheckpointSubTask;
+
+const vertex = (id: string, name: string): VerticesItem => ({ id, name, status: 'RUNNING' }) as VerticesItem;
+
+const checkpoint = (
+ rawStatus: string,
+ duration: number,
+ isSavepoint = false
+): { id: number; duration: number; rawStatus: string; isSavepoint: boolean; triggered: number } => ({
+ id: 7,
+ duration,
+ rawStatus,
+ isSavepoint,
+ triggered: TRIGGERED
+});
+
+type BuildRows = (
+ datum: ReturnType<typeof checkpoint>,
+ perVertex: Record<string, CheckpointSubTask | null>
+) => {
+ rows: Array<{ row: string; phase: string; phaseLabel: string; range: [number, number]; totalDuration: number }>;
+ unacked: Array<{ row: string; label: string; range: [number, number] }>;
+ instants: Array<{ row: string; aborted: boolean; range: [number, number] }>;
+ rowOrder: string[];
+};
+
+const unalignedConfig = (alignedCheckpointTimeout: number, mode = 'exactly_once'): CheckpointConfig =>
+ ({ mode, unaligned_checkpoints: true, aligned_checkpoint_timeout: alignedCheckpointTimeout }) as CheckpointConfig;
+
+const SUBTASK_PHASES = { start_delay: 2, alignment: 5, sync: 1, async: 8 };
+
+describe('JobCheckpointsTimelineComponent rows', () => {
+ let component: JobCheckpointsTimelineComponent;
+ let buildRows: BuildRows;
+
+ beforeEach(() => {
+ component = new JobCheckpointsTimelineComponent(
+ {} as JobService,
+ { markForCheck: () => undefined } as unknown as ChangeDetectorRef
+ );
+ buildRows = (component as unknown as { buildTimelineRows: BuildRows }).buildTimelineRows.bind(component);
+ });
+
+ it('keeps rows in operator then subtask order instead of sorting by duration', () => {
+ component.vertices = [vertex('a', 'Agg'), vertex('s', 'Sink')];
+
+ const { rowOrder } = buildRows(checkpoint('COMPLETED', 60), {
+ a: details(completed(0, { async: 5 }), completed(1, { async: 50 })),
+ s: details(completed(0, { start_delay: 1 }))
+ });
+
+ expect(rowOrder).toEqual(['Agg #0', 'Agg #1', 'Sink #0']);
+ });
+
+ it('keeps a row with an instant marker for subtasks whose phases all rounded to 0ms', () => {
+ component.vertices = [vertex('s', 'Source')];
+
+ const { instants, rowOrder } = buildRows(checkpoint('COMPLETED', 15), {
+ s: details(completed(0, {}), completed(1, { start_delay: 1 }))
+ });
+
+ expect(rowOrder).toEqual(['Source #0', 'Source #1']);
+ expect(instants).toEqual([
+ expect.objectContaining({ row: 'Source #0', aborted: false, range: [TRIGGERED, TRIGGERED] })
+ ]);
+ });
+
+ it('draws a no-ack bar spanning a failed checkpoint for subtasks without stats', () => {
+ component.vertices = [vertex('a', 'Agg')];
+
+ const { unacked, rowOrder } = buildRows(checkpoint('FAILED', 10), {
+ a: details(completed(0, { start_delay: 1, async: 3 }, true), noStats(1), completed(2, { async: 2 }))
+ });
+
+ expect(unacked).toEqual([
+ expect.objectContaining({ row: 'Agg #1', label: 'no ack', range: [TRIGGERED, TRIGGERED + 10] })
+ ]);
+ expect(rowOrder).toEqual(['Agg #0', 'Agg #1', 'Agg #2']);
+ });
+
+ it('marks subtasks without stats as pending up to the latest known progress while in progress', () => {
+ component.vertices = [vertex('a', 'Agg')];
+
+ const { unacked } = buildRows(checkpoint('IN_PROGRESS', 0), {
+ a: details(completed(0, { start_delay: 1, async: 4 }), noStats(1))
+ });
+
+ expect(unacked).toEqual([expect.objectContaining({ label: 'pending', range: [TRIGGERED, TRIGGERED + 5] })]);
+ });
+
+ it('uses the raw status for savepoints', () => {
+ component.vertices = [vertex('a', 'Agg')];
+
+ const { unacked } = buildRows(checkpoint('FAILED', 10, true), { a: details(noStats(0)) });
+
+ expect(unacked.map(u => u.label)).toEqual(['no ack']);
+ });
+
+ it('ignores missing stats on completed checkpoints', () => {
+ component.vertices = [vertex('a', 'Agg')];
+
+ const { unacked, rowOrder } = buildRows(checkpoint('COMPLETED', 10), {
+ a: details(completed(0, { async: 2 }), noStats(1))
+ });
+
+ expect(unacked).toEqual([]);
+ expect(rowOrder).toEqual(['Agg #0']);
+ });
+
+ const segments = (
+ rows: ReturnType<BuildRows>['rows'],
+ row: string
+ ): Array<[string, string, [number, number], number]> =>
+ rows.filter(r => r.row === row).map(r => [r.phase, r.phaseLabel, r.range, r.totalDuration]);
+
+ // Long.MAX_VALUE (2 ** 63 once parsed) means no timeout, i.e. unaligned from the first barrier, like 0.
+ it.each([0, 2 ** 63])('draws no alignment before sync for checkpoints unaligned from the start (timeout %s)', t => {
+ component.vertices = [vertex('a', 'Agg')];
+ component.config = unalignedConfig(t);
+
+ const { rows } = buildRows(checkpoint('COMPLETED', 20), { a: details(completed(0, SUBTASK_PHASES)) });
+
+ expect(segments(rows, 'Agg #0')).toEqual([
+ ['start_delay', 'start_delay', [TRIGGERED, TRIGGERED + 2], 11],
+ ['sync', 'sync', [TRIGGERED + 2, TRIGGERED + 3], 11],
+ ['async', 'async (incl. 5ms alignment)', [TRIGGERED + 3, TRIGGERED + 11], 11]
+ ]);
+ });
+
+ it('draws the alignment up to the aligned checkpoint timeout before sync', () => {
+ component.vertices = [vertex('a', 'Agg')];
+ component.config = unalignedConfig(30_000);
+
+ const { rows } = buildRows(checkpoint('COMPLETED', 40_000), {
+ a: details(
+ completed(0, { start_delay: 5_000, alignment: 31_000, sync: 10, async: 8_000 }),
+ completed(1, SUBTASK_PHASES)
+ )
+ });
+
+ expect(segments(rows, 'Agg #0')).toEqual([
+ ['start_delay', 'start_delay', [TRIGGERED, TRIGGERED + 5_000], 38_010],
+ ['alignment', 'alignment', [TRIGGERED + 5_000, TRIGGERED + 30_000], 38_010],
+ ['sync', 'sync', [TRIGGERED + 30_000, TRIGGERED + 30_010], 38_010],
+ ['async', 'async (incl. 6000ms alignment)', [TRIGGERED + 30_010, TRIGGERED + 38_010], 38_010]
+ ]);
+ // Aligned within the timeout, so it never switched.
+ expect(segments(rows, 'Agg #1').map(([, label]) => label)).toEqual(['start_delay', 'alignment', 'sync', 'async']);
+ });
+
+ it.each([
+ ['savepoints', unalignedConfig(0), true],
+ ['at-least-once checkpoints', unalignedConfig(0, 'at_least_once'), false],
+ ['jobs without unaligned checkpoints', { ...unalignedConfig(0), unaligned_checkpoints: false }, false]
+ ])('draws the whole alignment before sync for %s', (_, config, isSavepoint) => {
+ component.vertices = [vertex('a', 'Agg')];
+ component.config = config;
+
+ const { rows } = buildRows(checkpoint('COMPLETED', 20, isSavepoint), { a: details(completed(0, SUBTASK_PHASES)) });
+
+ expect(segments(rows, 'Agg #0')).toEqual([
+ ['start_delay', 'start_delay', [TRIGGERED, TRIGGERED + 2], 16],
+ ['alignment', 'alignment', [TRIGGERED + 2, TRIGGERED + 7], 16],
+ ['sync', 'sync', [TRIGGERED + 7, TRIGGERED + 8], 16],
+ ['async', 'async', [TRIGGERED + 8, TRIGGERED + 16], 16]
+ ]);
+ });
+
+ it('updates one timeline chart across reloads instead of rebuilding it', () => {
+ const mark = (): { data: ReturnType<typeof vi.fn>; scale: ReturnType<typeof vi.fn> } => {
+ const m = { data: vi.fn(), scale: vi.fn() };
+ m.data.mockReturnValue(m);
+ m.scale.mockReturnValue(m);
+ return m;
+ };
+ const chart = { attr: vi.fn(), render: vi.fn(), destroy: vi.fn() };
+ const create = vi.fn(() => ({ chart, phases: mark(), unacked: mark(), instants: mark() }));
+ const internals = component as unknown as {
+ createTimelineChart: typeof create;
+ renderTimeline: (datum: ReturnType<typeof checkpoint>, perVertex: Record<string, CheckpointSubTask>) => void;
+ };
+ internals.createTimelineChart = create;
Review Comment:
This is patching internals, could we instead perhaps use TestBed with a mock at the g2 level with a fake Chart that tracks/counts these calls? That way we can assert changes based on public inputs to the component, not `renderTimeline` etc.
```
fixture = TestBed.createComponent(JobCheckpointsTimelineComponent);
fixture.componentRef.setInput('jobId', 'job-1');
fixture.componentRef.setInput('history', [historyEntry(7, 'COMPLETED', 4)]);
fixture.detectChanges(); // first render: ngOnChanges (firstChange), ngOnInit, ngAfterViewInit
fixture.componentRef.setInput('history', [historyEntry(8, 'COMPLETED', 4), ...]);
fixture.detectChanges(); // ngOnChanges again, firstChange: false
```
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,1047 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgFor, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { formatTimeAxis, startAlignedTicks } from '@flink-runtime-web/utils';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+interface TimelineRows {
+ rows: TimelineDatum[];
+ unacked: UnackedDatum[];
+ instants: InstantDatum[];
+ rowOrder: string[];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+type IntervalMark = ReturnType<Chart['interval']>;
+
+// Built once and updated in place on reloads, so following an in-progress checkpoint doesn't rebuild the canvas.
+interface TimelineChart {
+ chart: Chart;
+ phases: IntervalMark;
+ unacked: IntervalMark;
+ instants: IntervalMark;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgFor,
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineScroll', { static: true }) private readonly timelineScroll: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineWrapper', { static: true }) private readonly timelineWrapper: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+ // Rows of the shown checkpoint, how many of the slowest are shown, and the first one scrolled to.
+ public totalRows = 0;
+ public slowestCount = JobCheckpointsTimelineComponent.SHOWN_ROWS_DEFAULT;
+ public firstRow = 0;
+ public chartHeight = 0;
+ public slowestFirst = false;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: IntervalMark;
+ private timeline?: TimelineChart;
+ // Full operator name per row label, for the native tooltip on the truncated labels.
+ private rowTitles = new Map<string, string>();
+ // Kept so scrolling can redraw another window of rows without rebuilding them.
+ private timelineRows?: TimelineRows & { datum: StripDatum; slowestOrder: string[] };
+ private scrollFrame?: number;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ // Holds only the checkpoints that can be selected again: those in the strip, plus the pinned one.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ // paddingTop (time axis) + paddingBottom, plus a little slack.
+ private static readonly TIMELINE_HEIGHT_BASE = 56;
+ // Rows shown by default (the slowest) and the most that can be picked; the chart is at most VISIBLE_ROWS tall.
+ private static readonly SHOWN_ROWS_DEFAULT = 25;
+ private static readonly SHOWN_ROWS_MAX = 200;
+ private static readonly VISIBLE_ROWS = 25;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
Review Comment:
What was the reason for polling inside the component? If the parent polled, would this give a better experience on sibling pages as well as this one?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.spec.ts:
##########
@@ -0,0 +1,672 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { HttpErrorResponse } from '@angular/common/http';
+import { ChangeDetectorRef, ElementRef, SimpleChange } from '@angular/core';
+import { BehaviorSubject, of, Subject, throwError } from 'rxjs';
+
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { JobCheckpointsTimelineComponent } from './job-checkpoints-timeline.component';
+
+const TRIGGERED = 1_000;
+
+interface Phases {
+ start_delay?: number;
+ alignment?: number;
+ sync?: number;
+ async?: number;
+}
+
+const completed = (index: number, phases: Phases, aborted = false): SubTaskCheckpointStatisticsItem =>
+ ({
+ index,
+ status: 'completed',
+ ack_timestamp: 0,
+ end_to_end_duration: 0,
+ checkpointed_size: 0,
+ state_size: 0,
+ checkpoint: { sync: phases.sync ?? 0, async: phases.async ?? 0 },
+ alignment: { buffer: 0, processed: 0, persisted: 0, duration: phases.alignment ?? 0 },
+ start_delay: phases.start_delay ?? 0,
+ unaligned_checkpoint: false,
+ aborted
+ }) as SubTaskCheckpointStatisticsItem;
+
+const noStats = (index: number): SubTaskCheckpointStatisticsItem =>
+ ({ index, status: 'pending_or_failed' }) as SubTaskCheckpointStatisticsItem;
+
+const details = (...subtasks: SubTaskCheckpointStatisticsItem[]): CheckpointSubTask =>
+ ({ subtasks }) as unknown as CheckpointSubTask;
+
+const vertex = (id: string, name: string): VerticesItem => ({ id, name, status: 'RUNNING' }) as VerticesItem;
+
+const checkpoint = (
+ rawStatus: string,
+ duration: number,
+ isSavepoint = false
+): { id: number; duration: number; rawStatus: string; isSavepoint: boolean; triggered: number } => ({
+ id: 7,
+ duration,
+ rawStatus,
+ isSavepoint,
+ triggered: TRIGGERED
+});
+
+type BuildRows = (
+ datum: ReturnType<typeof checkpoint>,
+ perVertex: Record<string, CheckpointSubTask | null>
+) => {
+ rows: Array<{ row: string; phase: string; phaseLabel: string; range: [number, number]; totalDuration: number }>;
+ unacked: Array<{ row: string; label: string; range: [number, number] }>;
+ instants: Array<{ row: string; aborted: boolean; range: [number, number] }>;
+ rowOrder: string[];
+};
+
+const unalignedConfig = (alignedCheckpointTimeout: number, mode = 'exactly_once'): CheckpointConfig =>
+ ({ mode, unaligned_checkpoints: true, aligned_checkpoint_timeout: alignedCheckpointTimeout }) as CheckpointConfig;
+
+const SUBTASK_PHASES = { start_delay: 2, alignment: 5, sync: 1, async: 8 };
+
+describe('JobCheckpointsTimelineComponent rows', () => {
Review Comment:
Wondering if the row building could be a pure function imported by this component? Makes the component smaller, and we can then test it without driving component internals.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,1047 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgFor, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { formatTimeAxis, startAlignedTicks } from '@flink-runtime-web/utils';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+interface TimelineRows {
+ rows: TimelineDatum[];
+ unacked: UnackedDatum[];
+ instants: InstantDatum[];
+ rowOrder: string[];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+type IntervalMark = ReturnType<Chart['interval']>;
+
+// Built once and updated in place on reloads, so following an in-progress checkpoint doesn't rebuild the canvas.
+interface TimelineChart {
+ chart: Chart;
+ phases: IntervalMark;
+ unacked: IntervalMark;
+ instants: IntervalMark;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgFor,
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineScroll', { static: true }) private readonly timelineScroll: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineWrapper', { static: true }) private readonly timelineWrapper: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+ // Rows of the shown checkpoint, how many of the slowest are shown, and the first one scrolled to.
+ public totalRows = 0;
+ public slowestCount = JobCheckpointsTimelineComponent.SHOWN_ROWS_DEFAULT;
+ public firstRow = 0;
+ public chartHeight = 0;
+ public slowestFirst = false;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: IntervalMark;
+ private timeline?: TimelineChart;
+ // Full operator name per row label, for the native tooltip on the truncated labels.
+ private rowTitles = new Map<string, string>();
+ // Kept so scrolling can redraw another window of rows without rebuilding them.
+ private timelineRows?: TimelineRows & { datum: StripDatum; slowestOrder: string[] };
+ private scrollFrame?: number;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ // Holds only the checkpoints that can be selected again: those in the strip, plus the pinned one.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ // paddingTop (time axis) + paddingBottom, plus a little slack.
+ private static readonly TIMELINE_HEIGHT_BASE = 56;
+ // Rows shown by default (the slowest) and the most that can be picked; the chart is at most VISIBLE_ROWS tall.
+ private static readonly SHOWN_ROWS_DEFAULT = 25;
+ private static readonly SHOWN_ROWS_MAX = 200;
+ private static readonly VISIBLE_ROWS = 25;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timeline && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timeline.chart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ if (this.scrollFrame !== undefined) {
+ cancelAnimationFrame(this.scrollFrame);
+ }
+ this.stripChart?.destroy();
+ this.timeline?.chart.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.pruneDetailsCache();
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ // The pinned checkpoint is gone too (e.g. after a JobManager failover), so follow whatever comes next.
+ this.userPinned = false;
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (!this.userPinned && nextNewestId !== prevNewestId) {
+ this.selectInternal(this.toStripDatum(next[0]), false);
+ return;
+ }
+ // Still showing the same checkpoint (the followed newest one, or the pinned one): reload once it gained acks or
+ // finished, or retry a failed load once (retrying on every poll would repeat the error notifications). Not while
+ // a load is in flight, so polling doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ const latest = this.userPinned ? next.find(h => h.id === selected?.id) : next[0];
+ if (!selected || !latest || latest.id !== selected.id || this.loadingTimeline) {
+ return;
+ }
+ const current = this.toStripDatum(latest);
+ const progressed = current.rawStatus !== selected.rawStatus || current.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== current.id;
+ if (retry) {
+ this.retriedCheckpointId = current.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(current, false);
+ }
+ }
+
+ private pruneDetailsCache(): void {
+ const selectable = new Set(
+ this.currentHistory.slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS).map(h => h.id)
+ );
+ for (const id of this.detailsCache.keys()) {
+ if (!selectable.has(id) && id !== this.selected?.id) {
+ this.detailsCache.delete(id);
+ }
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() => {
+ const jobId = this.jobId;
+ return jobId
+ ? this.jobService.loadCheckpointStats(jobId).pipe(
+ catchError(() => of(undefined)),
+ // A response for the previous job can land after a jobId change has reset the state.
+ filter(() => jobId === this.jobId)
+ )
+ : of(undefined);
+ }).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ // Disabled periodic checkpointing reports Long.MAX_VALUE, which the upper clamp covers.
+ const interval = this.config?.interval ?? 0;
+ return interval > 0
+ ? Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ )
+ : JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ // The component also lives in the hidden tab; don't fetch every vertex's details until it is shown.
+ if (!this.visible$.value) {
+ this.loadDeferred = true;
+ return;
+ }
+ this.loadDeferred = false;
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadError = undefined;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ // In-progress stats still change; only cache terminal checkpoints. `status` is 'SAVEPOINT' for an in-progress
+ // savepoint, so check rawStatus.
+ if (datum.rawStatus !== 'IN_PROGRESS') {
+ this.detailsCache.set(datum.id, perVertex);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.visible$
+ .pipe(
+ filter(visible => visible && this.loadDeferred),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(() => {
+ if (this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ });
+
+ this.loadTimeline$
+ .pipe(
+ switchMap((datum): Observable<TimelineLoad> => {
+ if (!datum) {
+ return EMPTY;
+ }
+ const requestedCount = this.vertices.length;
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({ datum, perVertex: cached, failedCount: 0, requestedCount });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const failedCount = requestedCount - Object.values(perVertex).filter(v => v !== null).length;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ const error: LoadError | undefined =
+ requestedCount > 0 && failedCount === requestedCount ? 'not-retained' : undefined;
+ return { datum, perVertex, failedCount, requestedCount, error };
+ }),
+ catchError(() =>
+ of<TimelineLoad>({
+ datum,
+ perVertex: {},
+ failedCount: requestedCount,
+ requestedCount,
+ error: 'request-failed'
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failedCount, requestedCount, error }) => {
+ this.loadingTimeline = false;
+ if (error) {
+ this.showEmptyTimeline(error);
+ return;
+ }
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): TimelineRows {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const startDelay = Math.max(s.start_delay || 0, 0);
+ const reportedAlignment = Math.max(s.alignment.duration || 0, 0);
+ const alignment = this.alignmentBeforeSync(datum, startDelay, reportedAlignment);
+ const alignmentInAsync = reportedAlignment - alignment;
+ const sync = Math.max(s.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(s.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
+ ];
+ let cursor = base;
+ for (const [phase, ms] of segs) {
+ if (ms > 0) {
+ rows.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ phase,
+ phaseLabel:
+ phase === 'async' && alignmentInAsync > 0 ? `${phase} (incl. ${alignmentInAsync}ms alignment)` : phase,
+ range: [cursor, cursor + ms],
+ durationMs: ms,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ totalDuration: total
+ });
+ }
+ cursor += ms;
+ }
+ }
+ }
+
+ // Unacked subtasks span the whole checkpoint: until it failed, or the latest ack so far while in progress.
+ const unackedEnd = base + Math.max(datum.duration, maxTotal, 1);
+ for (const u of unacked) {
+ u.range = [base, unackedEnd];
+ }
+
+ return { rows, unacked, instants, rowOrder };
+ }
+
+ // How much of a subtask's alignment came before its sync phase. With unaligned checkpoints, a checkpoint starts
+ // aligned and switches to unaligned once aligned_checkpoint_timeout has passed since the trigger; after that the
+ // rest of the alignment runs during the async phase, whose duration includes it (checkpoint_monitoring.md).
+ // Savepoints and at-least-once checkpoints never switch. The per-subtask unaligned_checkpoint flag can't tell: it
+ // only says whether in-flight data was persisted.
+ private alignmentBeforeSync(datum: StripDatum, startDelay: number, alignment: number): number {
+ const config = this.config;
+ if (!config?.unaligned_checkpoints || config.mode !== 'exactly_once' || datum.isSavepoint) {
+ return alignment;
+ }
+ const timeout = config.aligned_checkpoint_timeout;
+ // 0 and Long.MAX_VALUE both mean unaligned from the first barrier (CheckpointOptions.forConfig).
+ if (!(timeout > 0) || timeout >= Number.MAX_SAFE_INTEGER) {
+ return 0;
+ }
+ return Math.max(0, Math.min(alignment, timeout - startDelay));
+ }
+
+ private renderTimeline(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ const built = this.buildTimelineRows(datum, perVertex);
+ if (built.rowOrder.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.timelineEmpty = false;
+ this.timelineRows = { datum, ...built, slowestOrder: slowestFirstOrder(built) };
+ this.totalRows = built.rowOrder.length;
+ this.rowTitles = new Map();
+ for (const row of [...built.rows, ...built.unacked, ...built.instants]) {
+ if (!this.rowTitles.has(row.row)) {
+ this.rowTitles.set(row.row, `${row.operatorFull} #${row.subtask}`);
+ }
+ }
+ this.drawTimelineWindow();
+ }
+
+ // Draws the rows scrolled to, out of the slowest ones picked. The chart is at most 25 rows tall and stays in place
+ // while the box around it scrolls, so its canvas stays far below the 65,535 px browsers allow, however big the job.
+ private drawTimelineWindow(): void {
+ const data = this.timelineRows;
+ if (!data) {
+ return;
+ }
+ const { datum, rows, unacked, instants, rowOrder } = data;
+ const C = JobCheckpointsTimelineComponent;
+ const slowest = data.slowestOrder.slice(0, this.shownRows);
+ const picked = new Set(slowest);
+ const order = this.slowestFirst ? slowest : rowOrder.filter(row => picked.has(row));
+ const visible = this.visibleRows;
+ this.firstRow = Math.max(0, Math.min(this.firstRow, order.length - visible));
+ const windowRows = order.slice(this.firstRow, this.firstRow + visible);
+ const inWindow = new Set(windowRows);
+ const shown = <T extends { row: string }>(items: T[]): T[] => items.filter(d => inWindow.has(d.row));
+ this.chartHeight = Math.max(visible * C.TIMELINE_ROW_HEIGHT + C.TIMELINE_HEIGHT_BASE, C.TIMELINE_HEIGHT_MIN);
+
+ // The label padding and the time scale cover all rows, so scrolling or picking more rows doesn't shift them.
+ const longestLabel = rowOrder.reduce((m, s) => Math.max(m, s.length), 0);
+ const leftPadding = Math.min(
+ C.LABEL_PADDING_MAX,
+ Math.max(C.LABEL_PADDING_MIN, longestLabel * C.LABEL_CHAR_WIDTH + C.LABEL_PADDING_BUFFER)
+ );
+ const scaleMin = datum.triggered;
+ const scaleMax = Math.max(
+ [...rows, ...unacked].reduce((m, r) => Math.max(m, r.range[1]), scaleMin),
+ scaleMin + 1
+ );
+ const xScale = { domain: windowRows };
+ const yScale = {
+ domain: [scaleMin, scaleMax],
+ nice: false,
+ tickMethod: () => startAlignedTicks(new Date(scaleMin), new Date(scaleMax)).map(Number)
+ };
+
+ const timeline = (this.timeline ??= this.createTimelineChart());
+ timeline.chart.attr('height', this.chartHeight);
+ timeline.chart.attr('paddingLeft', leftPadding);
+ timeline.phases.data(shown(rows)).scale('x', xScale).scale('y', yScale);
+ timeline.unacked.data(shown(unacked)).scale('x', xScale).scale('y', yScale);
+ timeline.instants.data(shown(instants)).scale('x', xScale).scale('y', yScale);
+ void timeline.chart.render();
+ this.cdr.markForCheck();
+ }
+
+ // How many rows are drawn: the slowest ones picked, or all rows if there are fewer.
+ public get shownRows(): number {
+ return Math.min(this.slowestCount, this.totalRows);
+ }
+
+ public get visibleRows(): number {
+ return Math.min(JobCheckpointsTimelineComponent.VISIBLE_ROWS, this.shownRows);
+ }
+
+ public get scrollable(): boolean {
+ return this.shownRows > this.visibleRows;
+ }
+
+ // The scroll box's content: the chart plus one row height for every shown row out of view.
+ public get scrollContentHeight(): number {
+ return this.chartHeight + (this.shownRows - this.visibleRows) * JobCheckpointsTimelineComponent.TIMELINE_ROW_HEIGHT;
+ }
+
+ // 25, 50, ... up to 200 or the number of rows, whichever is smaller; none when every row is already shown.
+ public get slowestCountOptions(): number[] {
+ const C = JobCheckpointsTimelineComponent;
+ const max = Math.min(C.SHOWN_ROWS_MAX, this.totalRows);
+ if (max <= C.SHOWN_ROWS_DEFAULT) {
+ return [];
+ }
+ const options: number[] = [];
+ for (let n = C.SHOWN_ROWS_DEFAULT; n < max; n += C.SHOWN_ROWS_DEFAULT) {
+ options.push(n);
+ }
+ options.push(max);
+ return options;
+ }
+
+ public setSlowestCount(count: number): void {
+ this.slowestCount = count;
+ this.scrollToTop();
+ }
+
+ public setSlowestFirst(slowestFirst: boolean): void {
+ this.slowestFirst = slowestFirst;
+ this.scrollToTop();
+ }
+
+ // Other rows or another order: start again from the top.
+ private scrollToTop(): void {
+ this.firstRow = 0;
+ this.timelineScroll.nativeElement.scrollTop = 0;
+ this.drawTimelineWindow();
+ }
+
+ public onSlowestFirstChange(event: Event): void {
+ this.setSlowestFirst((event.target as HTMLInputElement).checked);
+ }
+
+ public onSlowestCountChange(event: Event): void {
+ this.setSlowestCount(Number((event.target as HTMLSelectElement).value));
+ }
+
+ public onTimelineScroll(): void {
+ const first = Math.round(
+ this.timelineScroll.nativeElement.scrollTop / JobCheckpointsTimelineComponent.TIMELINE_ROW_HEIGHT
+ );
+ if (first === this.firstRow) {
+ return;
+ }
+ this.firstRow = first;
+ // One redraw per frame, however many scroll events arrive.
+ if (this.scrollFrame === undefined) {
+ this.scrollFrame = requestAnimationFrame(() => {
+ this.scrollFrame = undefined;
+ this.drawTimelineWindow();
+ });
+ }
+ }
+
+ private createTimelineChart(): TimelineChart {
+ const container = this.timelineContainer.nativeElement;
+ const chart = new Chart({ container, autoFit: true, paddingTop: 32, paddingRight: 32, paddingBottom: 16 });
+ chart.coordinate({ transform: [{ type: 'transpose' }] });
+ const phases = chart
+ .interval()
+ .encode('x', 'row')
+ .encode('y', 'range')
+ .encode('color', 'phase')
+ .scale('color', { domain: PHASES, range: PHASES.map(p => PHASE_COLOR[p]) })
+ .axis('x', {
+ title: false,
+ labelAutoHide: false,
+ labelAutoRotate: false,
+ labelFill: '#262626',
+ labelOpacity: 1
+ })
+ // On top, so the time axis is in view as soon as the chart is.
+ .axis('y', { title: false, position: 'top', labelFormatter: (v: number) => formatTimeAxis(new Date(Number(v))) })
+ .legend(false)
+ .animate(false)
+ .style('stroke', (d: TimelineDatum) => (d.aborted ? NOT_COMPLETED_STROKE : 'transparent'))
+ .style('lineWidth', (d: TimelineDatum) => (d.aborted ? 1.5 : 0))
+ .style('lineDash', (d: TimelineDatum) => (d.aborted ? [3, 2] : [0, 0]))
+ .tooltip({
+ title: (d: TimelineDatum) => `${d.operatorFull} #${d.subtask}`,
+ items: [
+ (d: TimelineDatum) => ({ name: d.phaseLabel, color: PHASE_COLOR[d.phase], value: `${d.durationMs}ms` }),
+ (d: TimelineDatum) => ({ name: 'total', color: 'transparent', value: `${d.totalDuration}ms` }),
+ (d: TimelineDatum) => ({
+ name: 'state',
+ color: 'transparent',
+ value: this.humanizeBytesPipe.transform(d.stateSize)
+ }),
+ (d: TimelineDatum) => ({
+ name: 'checkpointed',
+ color: 'transparent',
+ value: this.humanizeBytesPipe.transform(d.checkpointedSize)
+ })
+ ]
+ })
+ .interaction('tooltip', {
+ // Outside the scroll box, which would clip it on the last visible rows. g2 places a tooltip before measuring
+ // it, so on its first frame it doesn't flip up yet.
+ mount: this.timelineWrapper.nativeElement,
+ // g2 5 ellipsizes the tooltip title at 360px; let full operator names wrap instead.
+ css: {
+ '.g2-tooltip': { 'max-width': '480px' },
+ '.g2-tooltip-title': { 'white-space': 'normal', 'overflow-wrap': 'anywhere' }
+ }
+ });
+ // Returned from a callback: g2 deep-copies constant style objects, which would turn the canvas into a plain object.
+ const hatchFill = { image: (this.noAckHatch ??= createHatchPattern()), repetition: 'repeat' };
+ const unacked = chart
+ .interval()
+ .encode('x', 'row')
+ .encode('y', 'range')
+ .animate(false)
+ .style('fill', () => hatchFill)
+ .style('stroke', NOT_COMPLETED_STROKE)
+ .style('lineWidth', 1.5)
+ .style('lineDash', [3, 2])
+ .tooltip({
+ title: (d: UnackedDatum) => `${d.operatorFull} #${d.subtask}`,
+ items: [(d: UnackedDatum) => ({ name: d.label, color: NOT_COMPLETED_STROKE, value: 'no stats reported' })]
+ });
+ const instants = chart
+ .interval()
+ .encode('x', 'row')
+ .encode('y', 'range')
+ .animate(false)
+ // The range is zero-length; once transposed, minHeight is the on-screen length along the time axis.
+ .style('minHeight', 2)
+ .style('fill', (d: InstantDatum) => (d.aborted ? NOT_COMPLETED_STROKE : INSTANT_FILL))
+ .tooltip({
+ title: (d: InstantDatum) => `${d.operatorFull} #${d.subtask}`,
+ // Same rows as the phase bars, so 'total' always means the sum of the phases.
+ items: [
+ (d: InstantDatum) => ({
+ name: 'all phases',
+ color: d.aborted ? NOT_COMPLETED_STROKE : INSTANT_FILL,
+ value: '0ms'
+ }),
+ () => ({ name: 'total', color: 'transparent', value: '0ms' }),
+ (d: InstantDatum) => ({
+ name: 'state',
+ color: 'transparent',
+ value: this.humanizeBytesPipe.transform(d.stateSize)
+ }),
+ (d: InstantDatum) => ({
+ name: 'checkpointed',
+ color: 'transparent',
+ value: this.humanizeBytesPipe.transform(d.checkpointedSize)
+ })
+ ]
+ });
+
+ // Row labels are truncated; show the full operator name as a native tooltip while hovering one.
+ chart.on('axis-label-item:pointerover', (ev: { target?: { attributes?: { text?: unknown } } }) => {
+ container.title = this.rowTitles.get(String(ev.target?.attributes?.text ?? '')) ?? '';
+ });
+ chart.on('axis-label-item:pointerout', () => (container.title = ''));
Review Comment:
```suggestion
chart.on('axis-label-item:pointerout', () => (container.title = '')); chart.interaction('elementHighlightByX', true);
```
Makes it easy to see which row when there are lots of subtasks.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.html:
##########
@@ -0,0 +1,174 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<div class="timeline-wrapper">
+ <section class="strip-section">
+ <header class="strip-header">
+ <div class="strip-title">
+ <strong>Recent Checkpoints</strong>
+ <span class="hint">Click a bar to load its per-subtask timeline below.</span>
+ </div>
+ <ul class="legend">
+ <li>
+ <span class="swatch completed"></span>
+ Completed
+ </li>
+ <li>
+ <span class="swatch savepoint"></span>
+ Savepoint
+ </li>
+ <li>
+ <span class="swatch in-progress"></span>
+ In progress
+ </li>
+ <li>
+ <span class="swatch failed"></span>
+ Failed
+ </li>
+ </ul>
+ </header>
+ <div class="strip-canvas" #stripContainer></div>
+ <nz-empty *ngIf="!hasHistory" nzNotFoundContent="No checkpoint history yet"></nz-empty>
+ </section>
+
+ <section class="timeline-section">
+ <header class="timeline-header">
+ <div class="timeline-title">
+ <strong *ngIf="selected">
+ Checkpoint #{{ selected.id }}
+ <span
+ *ngIf="userPinned"
Review Comment:
Can we use a tooltip like with the legend, for consistency?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.less:
##########
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.timeline-wrapper {
+ display: flex;
+ flex-direction: column;
+ gap: 24px;
+}
+
+header {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 12px;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 8px;
+}
+
+.hint {
+ margin-left: 8px;
+ color: #8c8c8c;
Review Comment:
We should try to use theme imports - like in `flink-runtime-web/web-dashboard/src/app/components/blocked-badge/blocked-badge.component.less` and reference color tokens
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.spec.ts:
##########
@@ -0,0 +1,672 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { HttpErrorResponse } from '@angular/common/http';
Review Comment:
We never actually render the component - can we have tests with TestBed (e.g `pages/job-manager/metrics/job-manager-metrics.component.spec.ts`) so that we can assert on render behaviour (e.g ngIf and bindings)
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,1047 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgFor, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { formatTimeAxis, startAlignedTicks } from '@flink-runtime-web/utils';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+interface TimelineRows {
+ rows: TimelineDatum[];
+ unacked: UnackedDatum[];
+ instants: InstantDatum[];
+ rowOrder: string[];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+type IntervalMark = ReturnType<Chart['interval']>;
+
+// Built once and updated in place on reloads, so following an in-progress checkpoint doesn't rebuild the canvas.
+interface TimelineChart {
+ chart: Chart;
+ phases: IntervalMark;
+ unacked: IntervalMark;
+ instants: IntervalMark;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgFor,
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineScroll', { static: true }) private readonly timelineScroll: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineWrapper', { static: true }) private readonly timelineWrapper: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+ // Rows of the shown checkpoint, how many of the slowest are shown, and the first one scrolled to.
+ public totalRows = 0;
+ public slowestCount = JobCheckpointsTimelineComponent.SHOWN_ROWS_DEFAULT;
+ public firstRow = 0;
+ public chartHeight = 0;
+ public slowestFirst = false;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: IntervalMark;
+ private timeline?: TimelineChart;
+ // Full operator name per row label, for the native tooltip on the truncated labels.
+ private rowTitles = new Map<string, string>();
+ // Kept so scrolling can redraw another window of rows without rebuilding them.
+ private timelineRows?: TimelineRows & { datum: StripDatum; slowestOrder: string[] };
+ private scrollFrame?: number;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ // Holds only the checkpoints that can be selected again: those in the strip, plus the pinned one.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ // paddingTop (time axis) + paddingBottom, plus a little slack.
+ private static readonly TIMELINE_HEIGHT_BASE = 56;
+ // Rows shown by default (the slowest) and the most that can be picked; the chart is at most VISIBLE_ROWS tall.
+ private static readonly SHOWN_ROWS_DEFAULT = 25;
+ private static readonly SHOWN_ROWS_MAX = 200;
+ private static readonly VISIBLE_ROWS = 25;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timeline && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timeline.chart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ if (this.scrollFrame !== undefined) {
+ cancelAnimationFrame(this.scrollFrame);
+ }
+ this.stripChart?.destroy();
+ this.timeline?.chart.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
Review Comment:
```
const chart = new Chart(..);
this.stripChart = chart;
...
.interaction('tooltip', { disableNative: true })
.interaction('elementHighlight', true)
...
chart.on('interval:pointerover', (ev: { data?: { data?: StripDatum } }) => {
const datum = ev.data?.data;
if (datum) {
chart.emit('tooltip:show', { data: { data: datum } });
}
});
chart.on('interval:pointerout', () => chart.emit('tooltip:hide'));
```
This will allow the tooltips to only show when you hover over the actual bar in the recent checkpoints. Currently it's popping up whenever you hover, which for small bars with large whitespace is making it hard to see which is hovered over.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,1047 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgFor, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { formatTimeAxis, startAlignedTicks } from '@flink-runtime-web/utils';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+interface TimelineRows {
+ rows: TimelineDatum[];
+ unacked: UnackedDatum[];
+ instants: InstantDatum[];
+ rowOrder: string[];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+type IntervalMark = ReturnType<Chart['interval']>;
+
+// Built once and updated in place on reloads, so following an in-progress checkpoint doesn't rebuild the canvas.
+interface TimelineChart {
+ chart: Chart;
+ phases: IntervalMark;
+ unacked: IntervalMark;
+ instants: IntervalMark;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgFor,
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineScroll', { static: true }) private readonly timelineScroll: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineWrapper', { static: true }) private readonly timelineWrapper: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+ // Rows of the shown checkpoint, how many of the slowest are shown, and the first one scrolled to.
+ public totalRows = 0;
+ public slowestCount = JobCheckpointsTimelineComponent.SHOWN_ROWS_DEFAULT;
+ public firstRow = 0;
+ public chartHeight = 0;
+ public slowestFirst = false;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: IntervalMark;
+ private timeline?: TimelineChart;
+ // Full operator name per row label, for the native tooltip on the truncated labels.
+ private rowTitles = new Map<string, string>();
+ // Kept so scrolling can redraw another window of rows without rebuilding them.
+ private timelineRows?: TimelineRows & { datum: StripDatum; slowestOrder: string[] };
+ private scrollFrame?: number;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ // Holds only the checkpoints that can be selected again: those in the strip, plus the pinned one.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ // paddingTop (time axis) + paddingBottom, plus a little slack.
+ private static readonly TIMELINE_HEIGHT_BASE = 56;
+ // Rows shown by default (the slowest) and the most that can be picked; the chart is at most VISIBLE_ROWS tall.
+ private static readonly SHOWN_ROWS_DEFAULT = 25;
+ private static readonly SHOWN_ROWS_MAX = 200;
+ private static readonly VISIBLE_ROWS = 25;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timeline && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timeline.chart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ if (this.scrollFrame !== undefined) {
+ cancelAnimationFrame(this.scrollFrame);
+ }
+ this.stripChart?.destroy();
+ this.timeline?.chart.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.pruneDetailsCache();
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ // The pinned checkpoint is gone too (e.g. after a JobManager failover), so follow whatever comes next.
+ this.userPinned = false;
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (!this.userPinned && nextNewestId !== prevNewestId) {
+ this.selectInternal(this.toStripDatum(next[0]), false);
+ return;
+ }
+ // Still showing the same checkpoint (the followed newest one, or the pinned one): reload once it gained acks or
+ // finished, or retry a failed load once (retrying on every poll would repeat the error notifications). Not while
+ // a load is in flight, so polling doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ const latest = this.userPinned ? next.find(h => h.id === selected?.id) : next[0];
+ if (!selected || !latest || latest.id !== selected.id || this.loadingTimeline) {
+ return;
+ }
+ const current = this.toStripDatum(latest);
+ const progressed = current.rawStatus !== selected.rawStatus || current.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== current.id;
+ if (retry) {
+ this.retriedCheckpointId = current.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(current, false);
+ }
+ }
+
+ private pruneDetailsCache(): void {
+ const selectable = new Set(
+ this.currentHistory.slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS).map(h => h.id)
+ );
+ for (const id of this.detailsCache.keys()) {
+ if (!selectable.has(id) && id !== this.selected?.id) {
+ this.detailsCache.delete(id);
+ }
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() => {
+ const jobId = this.jobId;
+ return jobId
+ ? this.jobService.loadCheckpointStats(jobId).pipe(
+ catchError(() => of(undefined)),
Review Comment:
This causes silent failures of the timeline page, making it look like checkpoints have stopped. It would be better to show an error or at least an indicator that the data is stale.
<img width="1542" height="997" alt="Image" src="https://github.com/user-attachments/assets/32e723f6-bfdb-4e6c-a95a-b76382ab5463" />
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,1047 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgFor, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { formatTimeAxis, startAlignedTicks } from '@flink-runtime-web/utils';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+interface TimelineRows {
+ rows: TimelineDatum[];
+ unacked: UnackedDatum[];
+ instants: InstantDatum[];
+ rowOrder: string[];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+type IntervalMark = ReturnType<Chart['interval']>;
+
+// Built once and updated in place on reloads, so following an in-progress checkpoint doesn't rebuild the canvas.
+interface TimelineChart {
+ chart: Chart;
+ phases: IntervalMark;
+ unacked: IntervalMark;
+ instants: IntervalMark;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgFor,
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineScroll', { static: true }) private readonly timelineScroll: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineWrapper', { static: true }) private readonly timelineWrapper: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+ // Rows of the shown checkpoint, how many of the slowest are shown, and the first one scrolled to.
+ public totalRows = 0;
+ public slowestCount = JobCheckpointsTimelineComponent.SHOWN_ROWS_DEFAULT;
+ public firstRow = 0;
+ public chartHeight = 0;
+ public slowestFirst = false;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: IntervalMark;
+ private timeline?: TimelineChart;
+ // Full operator name per row label, for the native tooltip on the truncated labels.
+ private rowTitles = new Map<string, string>();
+ // Kept so scrolling can redraw another window of rows without rebuilding them.
+ private timelineRows?: TimelineRows & { datum: StripDatum; slowestOrder: string[] };
+ private scrollFrame?: number;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ // Holds only the checkpoints that can be selected again: those in the strip, plus the pinned one.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ // paddingTop (time axis) + paddingBottom, plus a little slack.
+ private static readonly TIMELINE_HEIGHT_BASE = 56;
+ // Rows shown by default (the slowest) and the most that can be picked; the chart is at most VISIBLE_ROWS tall.
+ private static readonly SHOWN_ROWS_DEFAULT = 25;
+ private static readonly SHOWN_ROWS_MAX = 200;
+ private static readonly VISIBLE_ROWS = 25;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
Review Comment:
As in, the parent could own the polling and pass a live history to the timeline, leaving the other tabs on manual refresh. Then the refresh button could say "new data available" or something to indicate that it has new data, so the refresh button is more of a "load latest state".
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,1047 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgFor, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { formatTimeAxis, startAlignedTicks } from '@flink-runtime-web/utils';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+interface TimelineRows {
+ rows: TimelineDatum[];
+ unacked: UnackedDatum[];
+ instants: InstantDatum[];
+ rowOrder: string[];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+type IntervalMark = ReturnType<Chart['interval']>;
+
+// Built once and updated in place on reloads, so following an in-progress checkpoint doesn't rebuild the canvas.
+interface TimelineChart {
+ chart: Chart;
+ phases: IntervalMark;
+ unacked: IntervalMark;
+ instants: IntervalMark;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgFor,
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineScroll', { static: true }) private readonly timelineScroll: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineWrapper', { static: true }) private readonly timelineWrapper: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+ // Rows of the shown checkpoint, how many of the slowest are shown, and the first one scrolled to.
+ public totalRows = 0;
+ public slowestCount = JobCheckpointsTimelineComponent.SHOWN_ROWS_DEFAULT;
+ public firstRow = 0;
+ public chartHeight = 0;
+ public slowestFirst = false;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: IntervalMark;
+ private timeline?: TimelineChart;
+ // Full operator name per row label, for the native tooltip on the truncated labels.
+ private rowTitles = new Map<string, string>();
+ // Kept so scrolling can redraw another window of rows without rebuilding them.
+ private timelineRows?: TimelineRows & { datum: StripDatum; slowestOrder: string[] };
+ private scrollFrame?: number;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ // Holds only the checkpoints that can be selected again: those in the strip, plus the pinned one.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ // paddingTop (time axis) + paddingBottom, plus a little slack.
+ private static readonly TIMELINE_HEIGHT_BASE = 56;
+ // Rows shown by default (the slowest) and the most that can be picked; the chart is at most VISIBLE_ROWS tall.
+ private static readonly SHOWN_ROWS_DEFAULT = 25;
+ private static readonly SHOWN_ROWS_MAX = 200;
+ private static readonly VISIBLE_ROWS = 25;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timeline && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timeline.chart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ if (this.scrollFrame !== undefined) {
+ cancelAnimationFrame(this.scrollFrame);
+ }
+ this.stripChart?.destroy();
+ this.timeline?.chart.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
Review Comment:
This is quite small, particularly when one checkpoint is longer than most, the small checkpoints are hard to see in the chart.
Maybe 160? Also [job-checkpoints-timeline.component.less](https://github.com/apache/flink/pull/28060/changes#diff-8cbb2bf30835ffadb766c5014cadfeaac0bbe2e6f3dacca8bb71219bc60df449) sets height of 80, it should match the 160.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "ferenc-csaky (via GitHub) via issues" <is...@flink.apache.org>.
ferenc-csaky commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4456164676
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
Review Comment:
Only the checkpoints in the strip (10 by default) plus the pinned one can be selected again. So most of these 100 entries are never read, and each one holds every subtask's stats. Evict ids that leave `currentHistory`, or cap the cache at the history length plus one?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
+ return;
+ }
+
+ const newest = this.toStripDatum(next[0]);
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(newest, false);
+ return;
+ }
+ // Still the same newest checkpoint: reload once it gained acks or finished, or retry a failed load once
+ // (retrying on every poll would repeat the error notifications). Not while a load is in flight, so polling
+ // doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ if (selected?.id !== newest.id || this.loadingTimeline) {
+ return;
+ }
+ const progressed = newest.rawStatus !== selected.rawStatus || newest.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== newest.id;
+ if (retry) {
+ this.retriedCheckpointId = newest.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(newest, false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
Review Comment:
On a `jobId` change, `ngOnChanges` resets the state, but this poll keeps its in-flight request for the old job. If that response lands after the reset, the old job's history is applied and its newest checkpoint id gets loaded with the new `jobId`. Capturing the `jobId` in the `defer` and dropping responses that don't match would fix it. It could get a test like the existing "drops a load still in flight when the job changes".
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
Review Comment:
If the history goes empty while a checkpoint is pinned (e.g. after a JobManager failover), `selected` is cleared but `userPinned` stays true. Once new checkpoints arrive, the early return below blocks auto-follow, and the timeline stays blank until someone clicks "Follow newest". Reset `userPinned` here?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
Review Comment:
`job-timeline.component.ts` already has `startAlignedTicks` and `formatTimeAxis`. Could both views share one helper, with sub-second steps added, instead of a second step list, tick builder and formatter?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
+ return;
+ }
+
+ const newest = this.toStripDatum(next[0]);
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(newest, false);
+ return;
+ }
+ // Still the same newest checkpoint: reload once it gained acks or finished, or retry a failed load once
+ // (retrying on every poll would repeat the error notifications). Not while a load is in flight, so polling
+ // doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ if (selected?.id !== newest.id || this.loadingTimeline) {
+ return;
+ }
+ const progressed = newest.rawStatus !== selected.rawStatus || newest.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== newest.id;
+ if (retry) {
+ this.retriedCheckpointId = newest.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(newest, false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ // Disabled periodic checkpointing reports Long.MAX_VALUE, which the upper clamp covers.
+ const interval = this.config?.interval ?? 0;
+ return interval > 0
+ ? Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ )
+ : JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ // The component also lives in the hidden tab; don't fetch every vertex's details until it is shown.
+ if (!this.visible$.value) {
+ this.loadDeferred = true;
+ return;
+ }
+ this.loadDeferred = false;
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadError = undefined;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ // In-progress stats still change; only cache terminal checkpoints. `status` is 'SAVEPOINT' for an in-progress
+ // savepoint, so check rawStatus.
+ if (datum.rawStatus === 'IN_PROGRESS') {
+ return;
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.visible$
+ .pipe(
+ filter(visible => visible && this.loadDeferred),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(() => {
+ if (this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ });
+
+ this.loadTimeline$
+ .pipe(
+ switchMap((datum): Observable<TimelineLoad> => {
+ if (!datum) {
+ return EMPTY;
+ }
+ const requestedCount = this.vertices.length;
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({ datum, perVertex: cached, failedCount: 0, requestedCount });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const failedCount = requestedCount - Object.values(perVertex).filter(v => v !== null).length;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ const error: LoadError | undefined =
+ requestedCount > 0 && failedCount === requestedCount ? 'not-retained' : undefined;
+ return { datum, perVertex, failedCount, requestedCount, error };
+ }),
+ catchError(() =>
+ of<TimelineLoad>({
+ datum,
+ perVertex: {},
+ failedCount: requestedCount,
+ requestedCount,
+ error: 'request-failed'
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failedCount, requestedCount, error }) => {
+ this.loadingTimeline = false;
+ if (error) {
+ this.showEmptyTimeline(error);
+ return;
+ }
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const startDelay = Math.max(s.start_delay || 0, 0);
+ const reportedAlignment = Math.max(s.alignment.duration || 0, 0);
+ const unaligned = !!s.unaligned_checkpoint;
+ // In an unaligned checkpoint, async already includes the alignment (checkpoint_monitoring.md), so don't stack it.
+ const alignment = unaligned ? 0 : reportedAlignment;
+ const sync = Math.max(s.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(s.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
+ ];
+ let cursor = base;
+ for (const [phase, ms] of segs) {
+ if (ms > 0) {
+ rows.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ phase,
+ phaseLabel: phase === 'async' && unaligned ? `${phase} (incl. ${reportedAlignment}ms alignment)` : phase,
+ range: [cursor, cursor + ms],
+ durationMs: ms,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ totalDuration: total
+ });
+ }
+ cursor += ms;
+ }
+ }
+ }
+
+ // Unacked subtasks span the whole checkpoint: until it failed, or the latest ack so far while in progress.
+ const unackedEnd = base + Math.max(datum.duration, maxTotal, 1);
+ for (const u of unacked) {
+ u.range = [base, unackedEnd];
+ }
+
+ return { rows, unacked, instants, rowOrder };
+ }
+
+ private renderTimeline(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ const { rows, unacked, instants, rowOrder } = this.buildTimelineRows(datum, perVertex);
+ if (rowOrder.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.timelineEmpty = false;
+ this.cdr.markForCheck();
+
+ const C = JobCheckpointsTimelineComponent;
+ const chartHeight = Math.max(
+ rowOrder.length * C.TIMELINE_ROW_HEIGHT + C.TIMELINE_HEIGHT_BASE,
+ C.TIMELINE_HEIGHT_MIN
+ );
+ // Pad left to the longest label so G2 won't re-clip it.
+ const longestLabel = rowOrder.reduce((m, s) => Math.max(m, s.length), 0);
+ const leftPadding = Math.min(
+ C.LABEL_PADDING_MAX,
+ Math.max(C.LABEL_PADDING_MIN, longestLabel * C.LABEL_CHAR_WIDTH + C.LABEL_PADDING_BUFFER)
+ );
+
+ const container = this.timelineContainer.nativeElement;
+ this.timelineChart?.destroy();
+ this.timelineChart = new Chart({
+ container,
+ autoFit: true,
+ height: chartHeight,
+ paddingTop: 24,
+ paddingRight: 32,
+ paddingBottom: 48,
+ paddingLeft: leftPadding
+ });
+ this.timelineChart.coordinate({ transform: [{ type: 'transpose' }] });
+ const scaleMin = datum.triggered;
+ const scaleMax = Math.max(
+ [...rows, ...unacked].reduce((m, r) => Math.max(m, r.range[1]), scaleMin),
+ scaleMin + 1
+ );
+ const xScale = { domain: rowOrder };
+ const yScale = {
+ domain: [scaleMin, scaleMax],
+ nice: false,
+ tickMethod: () => buildTimelineTicks(scaleMin, scaleMax)
+ };
+ this.timelineChart
+ .interval()
+ .data(rows)
+ .encode('x', 'row')
+ .encode('y', 'range')
+ .encode('color', 'phase')
+ .scale('x', xScale)
+ .scale('y', yScale)
+ .scale('color', { domain: PHASES, range: PHASES.map(p => PHASE_COLOR[p]) })
+ .axis('x', {
+ title: false,
+ labelAutoHide: false,
+ labelAutoRotate: false,
+ labelFill: '#262626',
+ labelOpacity: 1
+ })
+ .axis('y', { title: 'time', labelFormatter: (v: number) => formatWallClock(Number(v)) })
+ .legend(false)
+ .animate(false)
+ .style('stroke', (d: TimelineDatum) => (d.aborted ? NOT_COMPLETED_STROKE : 'transparent'))
Review Comment:
FLINK-39566 says "Outliers and aborts highlighted", but only aborted subtasks get a stroke here. Rows aren't sorted by duration anymore either, so a slow subtask in a big job is easy to miss. Could you either flag subtasks well above the median total, or update the ticket to match what the PR does?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
+ return;
+ }
+
+ const newest = this.toStripDatum(next[0]);
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(newest, false);
+ return;
+ }
+ // Still the same newest checkpoint: reload once it gained acks or finished, or retry a failed load once
+ // (retrying on every poll would repeat the error notifications). Not while a load is in flight, so polling
+ // doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ if (selected?.id !== newest.id || this.loadingTimeline) {
+ return;
+ }
+ const progressed = newest.rawStatus !== selected.rawStatus || newest.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== newest.id;
+ if (retry) {
+ this.retriedCheckpointId = newest.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(newest, false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ // Disabled periodic checkpointing reports Long.MAX_VALUE, which the upper clamp covers.
+ const interval = this.config?.interval ?? 0;
+ return interval > 0
+ ? Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ )
+ : JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ // The component also lives in the hidden tab; don't fetch every vertex's details until it is shown.
+ if (!this.visible$.value) {
+ this.loadDeferred = true;
+ return;
+ }
+ this.loadDeferred = false;
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadError = undefined;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ // In-progress stats still change; only cache terminal checkpoints. `status` is 'SAVEPOINT' for an in-progress
+ // savepoint, so check rawStatus.
+ if (datum.rawStatus === 'IN_PROGRESS') {
+ return;
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.visible$
+ .pipe(
+ filter(visible => visible && this.loadDeferred),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(() => {
+ if (this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ });
+
+ this.loadTimeline$
+ .pipe(
+ switchMap((datum): Observable<TimelineLoad> => {
+ if (!datum) {
+ return EMPTY;
+ }
+ const requestedCount = this.vertices.length;
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({ datum, perVertex: cached, failedCount: 0, requestedCount });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const failedCount = requestedCount - Object.values(perVertex).filter(v => v !== null).length;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ const error: LoadError | undefined =
+ requestedCount > 0 && failedCount === requestedCount ? 'not-retained' : undefined;
+ return { datum, perVertex, failedCount, requestedCount, error };
+ }),
+ catchError(() =>
+ of<TimelineLoad>({
+ datum,
+ perVertex: {},
+ failedCount: requestedCount,
+ requestedCount,
+ error: 'request-failed'
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failedCount, requestedCount, error }) => {
+ this.loadingTimeline = false;
+ if (error) {
+ this.showEmptyTimeline(error);
+ return;
+ }
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const startDelay = Math.max(s.start_delay || 0, 0);
+ const reportedAlignment = Math.max(s.alignment.duration || 0, 0);
+ const unaligned = !!s.unaligned_checkpoint;
+ // In an unaligned checkpoint, async already includes the alignment (checkpoint_monitoring.md), so don't stack it.
+ const alignment = unaligned ? 0 : reportedAlignment;
+ const sync = Math.max(s.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(s.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
+ ];
+ let cursor = base;
+ for (const [phase, ms] of segs) {
+ if (ms > 0) {
+ rows.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ phase,
+ phaseLabel: phase === 'async' && unaligned ? `${phase} (incl. ${reportedAlignment}ms alignment)` : phase,
+ range: [cursor, cursor + ms],
+ durationMs: ms,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ totalDuration: total
+ });
+ }
+ cursor += ms;
+ }
+ }
+ }
+
+ // Unacked subtasks span the whole checkpoint: until it failed, or the latest ack so far while in progress.
+ const unackedEnd = base + Math.max(datum.duration, maxTotal, 1);
+ for (const u of unacked) {
+ u.range = [base, unackedEnd];
+ }
+
+ return { rows, unacked, instants, rowOrder };
+ }
+
+ private renderTimeline(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ const { rows, unacked, instants, rowOrder } = this.buildTimelineRows(datum, perVertex);
+ if (rowOrder.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.timelineEmpty = false;
+ this.cdr.markForCheck();
+
+ const C = JobCheckpointsTimelineComponent;
+ const chartHeight = Math.max(
Review Comment:
The chart grows 22 px per subtask with no cap. Four vertices at parallelism 200 give 17,680 px, which at devicePixelRatio 2 is past the 32,767 px canvas limit in Chrome and Firefox, so I'd expect a blank chart (I haven't tried it in a browser). Could you cap the rows, e.g. draw the slowest N with a "showing N of M" note? A scroll container alone won't help, since the canvas would still be too tall.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
+ return;
+ }
+
+ const newest = this.toStripDatum(next[0]);
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(newest, false);
+ return;
+ }
+ // Still the same newest checkpoint: reload once it gained acks or finished, or retry a failed load once
+ // (retrying on every poll would repeat the error notifications). Not while a load is in flight, so polling
+ // doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ if (selected?.id !== newest.id || this.loadingTimeline) {
+ return;
+ }
+ const progressed = newest.rawStatus !== selected.rawStatus || newest.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== newest.id;
+ if (retry) {
+ this.retriedCheckpointId = newest.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(newest, false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ // Disabled periodic checkpointing reports Long.MAX_VALUE, which the upper clamp covers.
+ const interval = this.config?.interval ?? 0;
+ return interval > 0
+ ? Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ )
+ : JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ // The component also lives in the hidden tab; don't fetch every vertex's details until it is shown.
+ if (!this.visible$.value) {
+ this.loadDeferred = true;
+ return;
+ }
+ this.loadDeferred = false;
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadError = undefined;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ // In-progress stats still change; only cache terminal checkpoints. `status` is 'SAVEPOINT' for an in-progress
+ // savepoint, so check rawStatus.
+ if (datum.rawStatus === 'IN_PROGRESS') {
+ return;
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.visible$
+ .pipe(
+ filter(visible => visible && this.loadDeferred),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(() => {
+ if (this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ });
+
+ this.loadTimeline$
+ .pipe(
+ switchMap((datum): Observable<TimelineLoad> => {
+ if (!datum) {
+ return EMPTY;
+ }
+ const requestedCount = this.vertices.length;
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({ datum, perVertex: cached, failedCount: 0, requestedCount });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const failedCount = requestedCount - Object.values(perVertex).filter(v => v !== null).length;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ const error: LoadError | undefined =
+ requestedCount > 0 && failedCount === requestedCount ? 'not-retained' : undefined;
+ return { datum, perVertex, failedCount, requestedCount, error };
+ }),
+ catchError(() =>
+ of<TimelineLoad>({
+ datum,
+ perVertex: {},
+ failedCount: requestedCount,
+ requestedCount,
+ error: 'request-failed'
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failedCount, requestedCount, error }) => {
+ this.loadingTimeline = false;
+ if (error) {
+ this.showEmptyTimeline(error);
+ return;
+ }
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const startDelay = Math.max(s.start_delay || 0, 0);
+ const reportedAlignment = Math.max(s.alignment.duration || 0, 0);
+ const unaligned = !!s.unaligned_checkpoint;
+ // In an unaligned checkpoint, async already includes the alignment (checkpoint_monitoring.md), so don't stack it.
+ const alignment = unaligned ? 0 : reportedAlignment;
+ const sync = Math.max(s.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(s.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
+ ];
+ let cursor = base;
+ for (const [phase, ms] of segs) {
+ if (ms > 0) {
+ rows.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ phase,
+ phaseLabel: phase === 'async' && unaligned ? `${phase} (incl. ${reportedAlignment}ms alignment)` : phase,
+ range: [cursor, cursor + ms],
+ durationMs: ms,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ totalDuration: total
+ });
+ }
+ cursor += ms;
+ }
+ }
+ }
+
+ // Unacked subtasks span the whole checkpoint: until it failed, or the latest ack so far while in progress.
+ const unackedEnd = base + Math.max(datum.duration, maxTotal, 1);
+ for (const u of unacked) {
+ u.range = [base, unackedEnd];
+ }
+
+ return { rows, unacked, instants, rowOrder };
+ }
+
+ private renderTimeline(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ const { rows, unacked, instants, rowOrder } = this.buildTimelineRows(datum, perVertex);
+ if (rowOrder.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.timelineEmpty = false;
+ this.cdr.markForCheck();
+
+ const C = JobCheckpointsTimelineComponent;
+ const chartHeight = Math.max(
+ rowOrder.length * C.TIMELINE_ROW_HEIGHT + C.TIMELINE_HEIGHT_BASE,
+ C.TIMELINE_HEIGHT_MIN
+ );
+ // Pad left to the longest label so G2 won't re-clip it.
+ const longestLabel = rowOrder.reduce((m, s) => Math.max(m, s.length), 0);
+ const leftPadding = Math.min(
+ C.LABEL_PADDING_MAX,
+ Math.max(C.LABEL_PADDING_MIN, longestLabel * C.LABEL_CHAR_WIDTH + C.LABEL_PADDING_BUFFER)
+ );
+
+ const container = this.timelineContainer.nativeElement;
+ this.timelineChart?.destroy();
Review Comment:
Each reload destroys and recreates the chart, so following an in-progress checkpoint rebuilds the canvas on every poll with new acks, and an open tooltip disappears. `job-timeline` keeps one chart and calls `changeSize()`, `data()` and `render()`; could this do the same?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
Review Comment:
If I pin the newest bar while it's IN_PROGRESS, the header keeps showing IN_PROGRESS and 2/4 acked while the strip already shows it as completed. I get that pinning freezes the view, but for an in-progress checkpoint I'd keep refreshing it until it reaches a terminal state.
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
+ return;
+ }
+
+ const newest = this.toStripDatum(next[0]);
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(newest, false);
+ return;
+ }
+ // Still the same newest checkpoint: reload once it gained acks or finished, or retry a failed load once
+ // (retrying on every poll would repeat the error notifications). Not while a load is in flight, so polling
+ // doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ if (selected?.id !== newest.id || this.loadingTimeline) {
+ return;
+ }
+ const progressed = newest.rawStatus !== selected.rawStatus || newest.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== newest.id;
+ if (retry) {
+ this.retriedCheckpointId = newest.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(newest, false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ // Disabled periodic checkpointing reports Long.MAX_VALUE, which the upper clamp covers.
+ const interval = this.config?.interval ?? 0;
+ return interval > 0
+ ? Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ )
+ : JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ // The component also lives in the hidden tab; don't fetch every vertex's details until it is shown.
+ if (!this.visible$.value) {
+ this.loadDeferred = true;
+ return;
+ }
+ this.loadDeferred = false;
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadError = undefined;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ // In-progress stats still change; only cache terminal checkpoints. `status` is 'SAVEPOINT' for an in-progress
+ // savepoint, so check rawStatus.
+ if (datum.rawStatus === 'IN_PROGRESS') {
+ return;
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.visible$
+ .pipe(
+ filter(visible => visible && this.loadDeferred),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(() => {
+ if (this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ });
+
+ this.loadTimeline$
+ .pipe(
+ switchMap((datum): Observable<TimelineLoad> => {
+ if (!datum) {
+ return EMPTY;
+ }
+ const requestedCount = this.vertices.length;
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({ datum, perVertex: cached, failedCount: 0, requestedCount });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const failedCount = requestedCount - Object.values(perVertex).filter(v => v !== null).length;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ const error: LoadError | undefined =
+ requestedCount > 0 && failedCount === requestedCount ? 'not-retained' : undefined;
+ return { datum, perVertex, failedCount, requestedCount, error };
+ }),
+ catchError(() =>
+ of<TimelineLoad>({
+ datum,
+ perVertex: {},
+ failedCount: requestedCount,
+ requestedCount,
+ error: 'request-failed'
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failedCount, requestedCount, error }) => {
+ this.loadingTimeline = false;
+ if (error) {
+ this.showEmptyTimeline(error);
+ return;
+ }
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const startDelay = Math.max(s.start_delay || 0, 0);
+ const reportedAlignment = Math.max(s.alignment.duration || 0, 0);
+ const unaligned = !!s.unaligned_checkpoint;
+ // In an unaligned checkpoint, async already includes the alignment (checkpoint_monitoring.md), so don't stack it.
+ const alignment = unaligned ? 0 : reportedAlignment;
Review Comment:
This treats every subtask with `unaligned_checkpoint` set as unaligned from its first barrier. With a non-zero `aligned-checkpoint-timeout`, a subtask can stay aligned until the timeout fires and only then switch, so its reported alignment includes that wait while sync starts at the switch. The wait isn't drawn: with a 30 s timeout and the first barrier at 5 s, the row ends about 25 s early, and the tooltip says async includes 31 s of alignment. Could you draw `max(0, min(alignment, aligned_checkpoint_timeout - start_delay))` as alignment before sync? `config` already has the timeout. Also, the flag is just `bytesPersistedDuringAlignment > 0` (see `CheckpointMetricsBuilder`), so `config.unaligned_checkpoints` is probably the better switch, and the docs sentence about alignment being part of async needs the same caveat.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub)" <gi...@apache.org>.
spuru9 commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-4787040578
@RocMarshal @och5351 This is a small feature which I worked on a few weeks back. Have attached the screenshot and made it ready for review. It would be a nice to have in addition to exiting checkpoint table.
Can you review and provide your opinion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub)" <gi...@apache.org>.
spuru9 commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4267427803
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,764 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import * as G2 from '@antv/g2';
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ unaligned: boolean;
+ outlier: boolean;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASE_LABEL: Record<PhaseKey, string> = {
+ start_delay: 'start_delay',
+ alignment: 'alignment',
+ sync: 'sync',
+ async: 'async'
+};
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const niceSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000];
+ const desired = span / target;
+ const step = niceSteps.find(s => s >= desired) ?? span;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzToolTipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadFailed = false;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private timelineChart?: Chart;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ private readonly loadTimeline$ = new Subject<StripDatum>();
+ // Completed-checkpoint stats are immutable; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ // Flink sends Long.MAX_VALUE (well above MAX_SAFE_INTEGER) when periodic checkpointing is disabled.
+ private static readonly DISABLED_INTERVAL_THRESHOLD = Number.MAX_SAFE_INTEGER;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(private readonly jobService: JobService, private readonly cdr: ChangeDetectorRef) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ this.clearTimeline();
+ this.renderStrip();
+ }
Review Comment:
Fixed: `detailsCache` is now cleared when `jobId` changes.
##########
flink-runtime-web/web-dashboard/src/app/services/job.service.ts:
##########
@@ -183,6 +183,23 @@ export class JobService {
);
}
+ public loadCheckpointAllSubtaskDetails(
+ jobId: string,
+ checkPointId: number,
+ vertexIds: string[]
+ ): Observable<Record<string, CheckpointSubTask | null>> {
+ if (vertexIds.length === 0) {
+ return of({} as Record<string, CheckpointSubTask | null>);
+ }
+ const requests = vertexIds.map(vid =>
+ this.loadCheckpointSubtaskDetails(jobId, checkPointId, vid).pipe(
+ catchError(() => of<CheckpointSubTask | null>(null)),
+ map(result => ({ [vid]: result }))
+ )
+ );
+ return forkJoin(requests).pipe(map(parts => Object.assign({}, ...parts)));
+ }
Review Comment:
Fixed: requests are now bounded to 6 concurrent via `mergeMap`, still returning one merged map.
##########
flink-runtime-web/web-dashboard/src/app/app.interceptor.ts:
##########
@@ -59,9 +59,18 @@ export class AppInterceptor implements HttpInterceptor {
window.location.href = String(res.headers.get('Location'));
}
+ // A per-subtask checkpoint fetch can race the JM reaping that checkpoint (or hit it
+ // before it acks), yielding a benign 404. Suppress only that case; real 5xx/auth on
+ // the same path still surface.
+ const isExpectedSubtaskNotFound =
+ res instanceof HttpResponseBase &&
+ res.status === HttpStatusCode.NotFound &&
+ /\/checkpoints\/details\/\d+\/subtasks\//.test(res.url || '');
+
Review Comment:
Fixed: suppression now uses the `EXPECTED_NOT_FOUND` request context and is set only by the timeline fetches, so other pages still show the toast.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub) via issues" <is...@flink.apache.org>.
spuru9 commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4460051355
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
+ return;
+ }
+
+ const newest = this.toStripDatum(next[0]);
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(newest, false);
+ return;
+ }
+ // Still the same newest checkpoint: reload once it gained acks or finished, or retry a failed load once
+ // (retrying on every poll would repeat the error notifications). Not while a load is in flight, so polling
+ // doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ if (selected?.id !== newest.id || this.loadingTimeline) {
+ return;
+ }
+ const progressed = newest.rawStatus !== selected.rawStatus || newest.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== newest.id;
+ if (retry) {
+ this.retriedCheckpointId = newest.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(newest, false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ // Disabled periodic checkpointing reports Long.MAX_VALUE, which the upper clamp covers.
+ const interval = this.config?.interval ?? 0;
+ return interval > 0
+ ? Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ )
+ : JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ // The component also lives in the hidden tab; don't fetch every vertex's details until it is shown.
+ if (!this.visible$.value) {
+ this.loadDeferred = true;
+ return;
+ }
+ this.loadDeferred = false;
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadError = undefined;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ // In-progress stats still change; only cache terminal checkpoints. `status` is 'SAVEPOINT' for an in-progress
+ // savepoint, so check rawStatus.
+ if (datum.rawStatus === 'IN_PROGRESS') {
+ return;
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.visible$
+ .pipe(
+ filter(visible => visible && this.loadDeferred),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(() => {
+ if (this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ });
+
+ this.loadTimeline$
+ .pipe(
+ switchMap((datum): Observable<TimelineLoad> => {
+ if (!datum) {
+ return EMPTY;
+ }
+ const requestedCount = this.vertices.length;
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({ datum, perVertex: cached, failedCount: 0, requestedCount });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const failedCount = requestedCount - Object.values(perVertex).filter(v => v !== null).length;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ const error: LoadError | undefined =
+ requestedCount > 0 && failedCount === requestedCount ? 'not-retained' : undefined;
+ return { datum, perVertex, failedCount, requestedCount, error };
+ }),
+ catchError(() =>
+ of<TimelineLoad>({
+ datum,
+ perVertex: {},
+ failedCount: requestedCount,
+ requestedCount,
+ error: 'request-failed'
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failedCount, requestedCount, error }) => {
+ this.loadingTimeline = false;
+ if (error) {
+ this.showEmptyTimeline(error);
+ return;
+ }
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const startDelay = Math.max(s.start_delay || 0, 0);
+ const reportedAlignment = Math.max(s.alignment.duration || 0, 0);
+ const unaligned = !!s.unaligned_checkpoint;
+ // In an unaligned checkpoint, async already includes the alignment (checkpoint_monitoring.md), so don't stack it.
+ const alignment = unaligned ? 0 : reportedAlignment;
+ const sync = Math.max(s.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(s.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
+ ];
+ let cursor = base;
+ for (const [phase, ms] of segs) {
+ if (ms > 0) {
+ rows.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ phase,
+ phaseLabel: phase === 'async' && unaligned ? `${phase} (incl. ${reportedAlignment}ms alignment)` : phase,
+ range: [cursor, cursor + ms],
+ durationMs: ms,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ totalDuration: total
+ });
+ }
+ cursor += ms;
+ }
+ }
+ }
+
+ // Unacked subtasks span the whole checkpoint: until it failed, or the latest ack so far while in progress.
+ const unackedEnd = base + Math.max(datum.duration, maxTotal, 1);
+ for (const u of unacked) {
+ u.range = [base, unackedEnd];
+ }
+
+ return { rows, unacked, instants, rowOrder };
+ }
+
+ private renderTimeline(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ const { rows, unacked, instants, rowOrder } = this.buildTimelineRows(datum, perVertex);
+ if (rowOrder.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.timelineEmpty = false;
+ this.cdr.markForCheck();
+
+ const C = JobCheckpointsTimelineComponent;
+ const chartHeight = Math.max(
+ rowOrder.length * C.TIMELINE_ROW_HEIGHT + C.TIMELINE_HEIGHT_BASE,
+ C.TIMELINE_HEIGHT_MIN
+ );
+ // Pad left to the longest label so G2 won't re-clip it.
+ const longestLabel = rowOrder.reduce((m, s) => Math.max(m, s.length), 0);
+ const leftPadding = Math.min(
+ C.LABEL_PADDING_MAX,
+ Math.max(C.LABEL_PADDING_MIN, longestLabel * C.LABEL_CHAR_WIDTH + C.LABEL_PADDING_BUFFER)
+ );
+
+ const container = this.timelineContainer.nativeElement;
+ this.timelineChart?.destroy();
+ this.timelineChart = new Chart({
+ container,
+ autoFit: true,
+ height: chartHeight,
+ paddingTop: 24,
+ paddingRight: 32,
+ paddingBottom: 48,
+ paddingLeft: leftPadding
+ });
+ this.timelineChart.coordinate({ transform: [{ type: 'transpose' }] });
+ const scaleMin = datum.triggered;
+ const scaleMax = Math.max(
+ [...rows, ...unacked].reduce((m, r) => Math.max(m, r.range[1]), scaleMin),
+ scaleMin + 1
+ );
+ const xScale = { domain: rowOrder };
+ const yScale = {
+ domain: [scaleMin, scaleMax],
+ nice: false,
+ tickMethod: () => buildTimelineTicks(scaleMin, scaleMax)
+ };
+ this.timelineChart
+ .interval()
+ .data(rows)
+ .encode('x', 'row')
+ .encode('y', 'range')
+ .encode('color', 'phase')
+ .scale('x', xScale)
+ .scale('y', yScale)
+ .scale('color', { domain: PHASES, range: PHASES.map(p => PHASE_COLOR[p]) })
+ .axis('x', {
+ title: false,
+ labelAutoHide: false,
+ labelAutoRotate: false,
+ labelFill: '#262626',
+ labelOpacity: 1
+ })
+ .axis('y', { title: 'time', labelFormatter: (v: number) => formatWallClock(Number(v)) })
+ .legend(false)
+ .animate(false)
+ .style('stroke', (d: TimelineDatum) => (d.aborted ? NOT_COMPLETED_STROKE : 'transparent'))
Review Comment:
Fixed the JIRA for the new state. Also the N value, as discussed in the review comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "spuru9 (via GitHub) via issues" <is...@flink.apache.org>.
spuru9 commented on code in PR #28060:
URL: https://github.com/apache/flink/pull/28060#discussion_r4460243499
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/timeline/job-checkpoints-timeline.component.ts:
##########
@@ -0,0 +1,908 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DatePipe, NgIf } from '@angular/common';
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Input,
+ OnChanges,
+ OnDestroy,
+ SimpleChanges,
+ ViewChild
+} from '@angular/core';
+import { BehaviorSubject, defer, EMPTY, Observable, of, Subject, timer } from 'rxjs';
+import { catchError, distinctUntilChanged, filter, map, repeat, switchMap, takeUntil } from 'rxjs/operators';
+
+import { Chart } from '@antv/g2';
+import { HumanizeBytesPipe } from '@flink-runtime-web/components/humanize-bytes.pipe';
+import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
+import {
+ CheckpointConfig,
+ CheckpointHistory,
+ CheckpointSubTask,
+ CompletedSubTaskCheckpointStatistics,
+ SubTaskCheckpointStatisticsItem,
+ VerticesItem
+} from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+import { NzAlertModule } from 'ng-zorro-antd/alert';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
+import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
+
+type PhaseKey = 'start_delay' | 'alignment' | 'sync' | 'async';
+
+// 'not-retained': every vertex returned 404, i.e. the JobManager no longer keeps this checkpoint's stats.
+type LoadError = 'not-retained' | 'request-failed';
+
+interface TimelineLoad {
+ datum: StripDatum;
+ perVertex: Record<string, CheckpointSubTask | null>;
+ failedCount: number;
+ requestedCount: number;
+ error?: LoadError;
+}
+
+interface StripDatum {
+ id: number;
+ idLabel: string;
+ duration: number;
+ status: 'COMPLETED' | 'SAVEPOINT' | 'IN_PROGRESS' | 'FAILED';
+ rawStatus: string;
+ isSavepoint: boolean;
+ triggered: number;
+ acked: string;
+ size: number;
+}
+
+interface TimelineDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ phase: PhaseKey;
+ phaseLabel: string;
+ range: [number, number];
+ durationMs: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ totalDuration: number;
+}
+
+// A subtask that reported no stats for the checkpoint, drawn as one hatched bar spanning it.
+interface UnackedDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ label: 'no ack' | 'pending';
+ range: [number, number];
+}
+
+// A subtask whose phases all rounded to 0ms, drawn as a hairline at trigger time so its row isn't empty.
+interface InstantDatum {
+ row: string;
+ operatorFull: string;
+ subtask: number;
+ aborted: boolean;
+ stateSize: number;
+ checkpointedSize: number;
+ range: [number, number];
+}
+
+const STRIP_COLOR: Record<StripDatum['status'], string> = {
+ COMPLETED: '#52c41a',
+ SAVEPOINT: '#722ed1',
+ IN_PROGRESS: '#faad14',
+ FAILED: '#f5222d'
+};
+
+const STRIP_STATUSES = Object.keys(STRIP_COLOR) as Array<StripDatum['status']>;
+
+const PHASE_COLOR: Record<PhaseKey, string> = {
+ start_delay: '#b8c0cc',
+ alignment: '#91caff',
+ sync: '#fa8c16',
+ async: '#52c41a'
+};
+
+const PHASES = Object.keys(PHASE_COLOR) as PhaseKey[];
+
+const NOT_COMPLETED_STROKE = '#f5222d';
+const NO_ACK_FILL = '#fff1f0';
+const NO_ACK_STRIPE = '#ffa39e';
+const INSTANT_FILL = '#8c8c8c';
+
+const OPERATOR_NAME_MAX = 60;
+
+// Local HH:MM:SS.mmm — matches the header's DatePipe default (browser timezone).
+function formatWallClock(epochMs: number): string {
+ const d = new Date(epochMs);
+ const pad = (n: number, len = 2): string => String(n).padStart(len, '0');
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
+}
+
+const MINUTE_MS = 60_000;
+const HOUR_MS = 60 * MINUTE_MS;
+const TICK_STEPS_MS = [
+ ...[1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000],
+ ...[1, 2, 5, 10, 30, 60].map(minutes => minutes * MINUTE_MS)
+];
+
+export function buildTimelineTicks(min: number, max: number, target = 5): number[] {
+ const span = Math.max(max - min, 1);
+ const desired = span / target;
+ const step = TICK_STEPS_MS.find(s => s >= desired) ?? Math.ceil(desired / HOUR_MS) * HOUR_MS;
+ const ticks: number[] = [];
+ for (let t = min; t <= max + 0.5; t += step) {
+ ticks.push(t);
+ }
+ if (ticks[ticks.length - 1] < max) {
+ ticks.push(max);
+ }
+ return ticks;
+}
+
+@Component({
+ selector: 'flink-job-checkpoints-timeline',
+ templateUrl: './job-checkpoints-timeline.component.html',
+ styleUrls: ['./job-checkpoints-timeline.component.less'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [
+ NgIf,
+ DatePipe,
+ HumanizeDurationPipe,
+ HumanizeBytesPipe,
+ NzAlertModule,
+ NzEmptyModule,
+ NzSpinModule,
+ NzTooltipModule
+ ]
+})
+export class JobCheckpointsTimelineComponent implements AfterViewInit, OnChanges, OnDestroy {
+ @Input() public jobId: string;
+ @Input() public vertices: VerticesItem[] = [];
+ @Input() public history: CheckpointHistory[] = [];
+ @Input() public config?: CheckpointConfig;
+
+ @ViewChild('stripContainer', { static: true }) private readonly stripContainer: ElementRef<HTMLDivElement>;
+ @ViewChild('timelineContainer', { static: true }) private readonly timelineContainer: ElementRef<HTMLDivElement>;
+
+ public selected?: StripDatum;
+ public loadingTimeline = false;
+ public timelineEmpty = false;
+ public loadError?: LoadError;
+ public failedVertexCount = 0;
+ public requestedVertexCount = 0;
+
+ // Diverges from @Input once polling starts feeding live updates.
+ private currentHistory: CheckpointHistory[] = [];
+ public userPinned = false;
+ private stripChart?: Chart;
+ private stripInterval?: ReturnType<Chart['interval']>;
+ private timelineChart?: Chart;
+ private noAckHatch?: HTMLCanvasElement;
+ private resizeObserver?: ResizeObserver;
+ private readonly destroy$ = new Subject<void>();
+ // null cancels a load in flight.
+ private readonly loadTimeline$ = new Subject<StripDatum | null>();
+ // A load requested while the Timeline tab was hidden; it runs once the tab is shown.
+ private loadDeferred = false;
+ // The checkpoint whose failed load was already retried while following, so polls don't retry it again.
+ private retriedCheckpointId?: number;
+ // Terminal (completed or failed) checkpoint stats no longer change; memoize by id for instant re-selects.
+ private readonly detailsCache = new Map<number, Record<string, CheckpointSubTask | null>>();
+ private readonly visible$ = new BehaviorSubject<boolean>(false);
+ private static readonly POLL_MIN_MS = 1500;
+ private static readonly POLL_MAX_MS = 15000;
+ private static readonly STRIP_MAX_BARS = 60;
+ private static readonly DETAILS_CACHE_MAX = 100;
+ private static readonly TIMELINE_ROW_HEIGHT = 22;
+ private static readonly TIMELINE_HEIGHT_BASE = 80;
+ private static readonly TIMELINE_HEIGHT_MIN = 160;
+ private static readonly LABEL_CHAR_WIDTH = 7;
+ private static readonly LABEL_PADDING_BUFFER = 24;
+ private static readonly LABEL_PADDING_MIN = 260;
+ private static readonly LABEL_PADDING_MAX = 520;
+
+ private readonly humanizeBytesPipe = new HumanizeBytesPipe();
+ private readonly humanizeDurationPipe = new HumanizeDurationPipe();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
+
+ public ngAfterViewInit(): void {
+ this.currentHistory = this.history || [];
+ this.renderStrip();
+ this.subscribeTimelineLoads();
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ }
+ this.startPolling();
+ // G2 locks autoFit at construction; re-fit + resume polling once width is real.
+ this.visible$.next(this.stripContainer.nativeElement.clientWidth > 0);
+ if (typeof ResizeObserver !== 'undefined') {
+ this.resizeObserver = new ResizeObserver(() => {
+ const stripVisible = this.stripContainer.nativeElement.clientWidth > 0;
+ if (this.stripChart && stripVisible) {
+ void this.stripChart.forceFit();
+ }
+ if (this.timelineChart && this.timelineContainer.nativeElement.clientWidth > 0) {
+ void this.timelineChart.forceFit();
+ }
+ this.visible$.next(stripVisible);
+ });
+ this.resizeObserver.observe(this.stripContainer.nativeElement);
+ this.resizeObserver.observe(this.timelineContainer.nativeElement);
+ }
+ }
+
+ public ngOnChanges(changes: SimpleChanges): void {
+ if (!this.stripContainer || !this.stripContainer.nativeElement) {
+ return;
+ }
+ if (changes['jobId'] && !changes['jobId'].firstChange) {
+ this.userPinned = false;
+ this.selected = undefined;
+ this.currentHistory = [];
+ // Otherwise a load still in flight for the old job lands in the cache under an id the new job reuses.
+ this.loadTimeline$.next(null);
+ this.detailsCache.clear();
+ this.retriedCheckpointId = undefined;
+ this.clearTimeline();
+ this.renderStrip();
+ }
+ if (changes['history']) {
+ this.applyHistory(this.history || []);
+ }
+ if (changes['vertices'] && !changes['vertices'].firstChange && this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ }
+
+ public ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ this.resizeObserver?.disconnect();
+ this.stripChart?.destroy();
+ this.timelineChart?.destroy();
+ }
+
+ private toStripDatum(h: CheckpointHistory): StripDatum {
+ // FAILED first, so a failed savepoint shows as failed rather than as a savepoint.
+ const status: StripDatum['status'] =
+ h.status === 'FAILED'
+ ? 'FAILED'
+ : h.is_savepoint
+ ? 'SAVEPOINT'
+ : h.status === 'IN_PROGRESS'
+ ? 'IN_PROGRESS'
+ : 'COMPLETED';
+ return {
+ id: h.id,
+ idLabel: String(h.id),
+ duration: Math.max(h.end_to_end_duration || 0, 0),
+ status,
+ rawStatus: h.status,
+ isSavepoint: h.is_savepoint,
+ triggered: h.trigger_timestamp,
+ acked: `${h.num_acknowledged_subtasks}/${h.num_subtasks}`,
+ size: h.state_size
+ };
+ }
+
+ private renderStrip(): void {
+ const data = (this.currentHistory || [])
+ .slice(0, JobCheckpointsTimelineComponent.STRIP_MAX_BARS)
+ .map(h => this.toStripDatum(h))
+ .reverse();
+
+ if (!this.stripChart || !this.stripInterval) {
+ this.stripChart = new Chart({
+ container: this.stripContainer.nativeElement,
+ autoFit: true,
+ height: 110,
+ paddingTop: 16,
+ paddingRight: 16,
+ paddingBottom: 36,
+ paddingLeft: 56
+ });
+ const isPinned = (d: StripDatum): boolean => this.userPinned && this.selected?.id === d.id;
+ this.stripInterval = this.stripChart
+ .interval()
+ .encode('x', 'idLabel')
+ .encode('y', 'duration')
+ .encode('color', 'status')
+ .scale('y', { nice: true, domainMin: 0 })
+ .scale('color', { domain: STRIP_STATUSES, range: STRIP_STATUSES.map(s => STRIP_COLOR[s]) })
+ .axis('x', { title: false, labelAutoHide: true, labelAutoRotate: false })
+ .axis('y', { title: false })
+ .legend(false)
+ .animate(false)
+ .style('maxWidth', 18)
+ // Keeps 0ms bars (e.g. in progress before the first ack) and very short ones visible and clickable.
+ .style('minHeight', 3)
+ .style('stroke', (d: StripDatum) => (isPinned(d) ? '#1890ff' : 'transparent'))
+ .style('lineWidth', (d: StripDatum) => (isPinned(d) ? 2.5 : 0))
+ .tooltip({
+ title: '',
+ items: [
+ (d: StripDatum) => ({
+ name: `#${d.idLabel}`,
+ color: STRIP_COLOR[d.status],
+ value: `${d.rawStatus} · ${this.humanizeDurationPipe.transform(d.duration)} · acked ${d.acked}`
+ })
+ ]
+ });
+ this.stripChart.on('interval:click', (ev: { data?: { data?: StripDatum } }) => {
+ const datum = ev.data?.data;
+ if (datum) {
+ this.select(datum);
+ }
+ });
+ }
+
+ this.stripInterval.scale('x', { domain: data.map(d => d.idLabel) });
+ this.stripInterval.data(data);
+ void this.stripChart.render();
+ }
+
+ public select(datum: StripDatum): void {
+ // Clicking the already-pinned bar resumes auto-follow.
+ if (this.userPinned && this.selected && this.selected.id === datum.id) {
+ this.followNewest();
+ return;
+ }
+ this.selectInternal(datum, true);
+ }
+
+ public followNewest(): void {
+ this.userPinned = false;
+ if (this.currentHistory.length > 0) {
+ this.selectInternal(this.toStripDatum(this.currentHistory[0]), false);
+ } else {
+ this.cdr.markForCheck();
+ }
+ }
+
+ private selectInternal(datum: StripDatum, pinned: boolean): void {
+ this.selected = datum;
+ if (pinned) {
+ this.userPinned = true;
+ }
+ this.cdr.markForCheck();
+ this.renderStrip();
+ this.loadTimeline(datum);
+ }
+
+ private applyHistory(next: CheckpointHistory[]): void {
+ const prevNewestId = this.currentHistory.length > 0 ? this.currentHistory[0].id : -1;
+ const nextNewestId = next.length > 0 ? next[0].id : -1;
+ this.currentHistory = next;
+ this.renderStrip();
+ // The empty state and the rotated-out note read currentHistory.
+ this.cdr.markForCheck();
+
+ if (next.length === 0) {
+ this.selected = undefined;
+ this.clearTimeline();
+ return;
+ }
+
+ if (this.userPinned) {
+ return;
+ }
+
+ const newest = this.toStripDatum(next[0]);
+ if (nextNewestId !== prevNewestId) {
+ this.selectInternal(newest, false);
+ return;
+ }
+ // Still the same newest checkpoint: reload once it gained acks or finished, or retry a failed load once
+ // (retrying on every poll would repeat the error notifications). Not while a load is in flight, so polling
+ // doesn't keep cancelling a slow fetch.
+ const selected = this.selected;
+ if (selected?.id !== newest.id || this.loadingTimeline) {
+ return;
+ }
+ const progressed = newest.rawStatus !== selected.rawStatus || newest.acked !== selected.acked;
+ const retry =
+ (this.loadError !== undefined || this.failedVertexCount > 0) && this.retriedCheckpointId !== newest.id;
+ if (retry) {
+ this.retriedCheckpointId = newest.id;
+ }
+ if (progressed || retry) {
+ this.selectInternal(newest, false);
+ }
+ }
+
+ private startPolling(): void {
+ this.visible$
+ .pipe(
+ distinctUntilChanged(),
+ switchMap(visible =>
+ visible
+ ? defer(() =>
+ this.jobId
+ ? this.jobService.loadCheckpointStats(this.jobId).pipe(catchError(() => of(undefined)))
+ : of(undefined)
+ ).pipe(repeat({ delay: () => timer(this.computePollDelayMs()) }))
+ : EMPTY
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(stats => {
+ if (!stats) {
+ return;
+ }
+ this.applyHistory(stats.history || []);
+ });
+ }
+
+ private computePollDelayMs(): number {
+ // Disabled periodic checkpointing reports Long.MAX_VALUE, which the upper clamp covers.
+ const interval = this.config?.interval ?? 0;
+ return interval > 0
+ ? Math.max(
+ JobCheckpointsTimelineComponent.POLL_MIN_MS,
+ Math.min(interval, JobCheckpointsTimelineComponent.POLL_MAX_MS)
+ )
+ : JobCheckpointsTimelineComponent.POLL_MAX_MS;
+ }
+
+ private loadTimeline(datum: StripDatum): void {
+ // The component also lives in the hidden tab; don't fetch every vertex's details until it is shown.
+ if (!this.visible$.value) {
+ this.loadDeferred = true;
+ return;
+ }
+ this.loadDeferred = false;
+ if (!this.jobId || this.vertices.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.loadingTimeline = true;
+ this.timelineEmpty = false;
+ this.loadError = undefined;
+ this.failedVertexCount = 0;
+ this.cdr.markForCheck();
+ this.loadTimeline$.next(datum);
+ }
+
+ private cacheDetails(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ // In-progress stats still change; only cache terminal checkpoints. `status` is 'SAVEPOINT' for an in-progress
+ // savepoint, so check rawStatus.
+ if (datum.rawStatus === 'IN_PROGRESS') {
+ return;
+ }
+ this.detailsCache.set(datum.id, perVertex);
+ // Evict oldest (Map keeps insertion order).
+ while (this.detailsCache.size > JobCheckpointsTimelineComponent.DETAILS_CACHE_MAX) {
+ const oldest = this.detailsCache.keys().next().value;
+ if (oldest === undefined) {
+ break;
+ }
+ this.detailsCache.delete(oldest);
+ }
+ }
+
+ private subscribeTimelineLoads(): void {
+ this.visible$
+ .pipe(
+ filter(visible => visible && this.loadDeferred),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(() => {
+ if (this.selected) {
+ this.loadTimeline(this.selected);
+ }
+ });
+
+ this.loadTimeline$
+ .pipe(
+ switchMap((datum): Observable<TimelineLoad> => {
+ if (!datum) {
+ return EMPTY;
+ }
+ const requestedCount = this.vertices.length;
+ const cached = this.detailsCache.get(datum.id);
+ if (cached) {
+ return of({ datum, perVertex: cached, failedCount: 0, requestedCount });
+ }
+ const vertexIds = this.vertices.map(v => v.id);
+ return this.jobService.loadCheckpointAllSubtaskDetails(this.jobId, datum.id, vertexIds).pipe(
+ map(perVertex => {
+ const failedCount = requestedCount - Object.values(perVertex).filter(v => v !== null).length;
+ if (failedCount === 0) {
+ this.cacheDetails(datum, perVertex);
+ }
+ const error: LoadError | undefined =
+ requestedCount > 0 && failedCount === requestedCount ? 'not-retained' : undefined;
+ return { datum, perVertex, failedCount, requestedCount, error };
+ }),
+ catchError(() =>
+ of<TimelineLoad>({
+ datum,
+ perVertex: {},
+ failedCount: requestedCount,
+ requestedCount,
+ error: 'request-failed'
+ })
+ )
+ );
+ }),
+ takeUntil(this.destroy$)
+ )
+ .subscribe(({ datum, perVertex, failedCount, requestedCount, error }) => {
+ this.loadingTimeline = false;
+ if (error) {
+ this.showEmptyTimeline(error);
+ return;
+ }
+ this.failedVertexCount = failedCount;
+ this.requestedVertexCount = requestedCount;
+ this.renderTimeline(datum, perVertex);
+ });
+ }
+
+ private buildTimelineRows(
+ datum: StripDatum,
+ perVertex: Record<string, CheckpointSubTask | null>
+ ): { rows: TimelineDatum[]; unacked: UnackedDatum[]; instants: InstantDatum[]; rowOrder: string[] } {
+ const base = datum.triggered;
+ // A completed checkpoint was acked by every running subtask, so missing stats there are not a failure.
+ const unackedLabel =
+ datum.rawStatus === 'FAILED' ? 'no ack' : datum.rawStatus === 'IN_PROGRESS' ? 'pending' : undefined;
+ const rows: TimelineDatum[] = [];
+ const unacked: UnackedDatum[] = [];
+ const instants: InstantDatum[] = [];
+ const rowOrder: string[] = [];
+ let maxTotal = 0;
+ const rowPrefixOwner = new Map<string, string>();
+
+ for (const vertex of this.vertices) {
+ const cp = perVertex[vertex.id];
+ if (!cp || !cp.subtasks) {
+ continue;
+ }
+ const opNameFull = (vertex.name || '').replace(/\s+/g, ' ').trim();
+ let opName = shortenOperatorName(vertex.name);
+ // shortenOperatorName truncates, so distinct vertices can collide; the row key must stay unique.
+ const owner = rowPrefixOwner.get(opName);
+ if (owner !== undefined && owner !== vertex.id) {
+ opName = `${opName} [${vertex.id.slice(0, 4)}]`;
+ }
+ rowPrefixOwner.set(opName, vertex.id);
+
+ for (const s of cp.subtasks) {
+ const row = `${opName} #${s.index}`;
+ if (!isCompletedSubtask(s)) {
+ // Finished tasks never land here: the JobManager records them as acknowledged when it triggers.
+ if (unackedLabel) {
+ unacked.push({ row, operatorFull: opNameFull, subtask: s.index, label: unackedLabel, range: [base, base] });
+ rowOrder.push(row);
+ }
+ continue;
+ }
+ const startDelay = Math.max(s.start_delay || 0, 0);
+ const reportedAlignment = Math.max(s.alignment.duration || 0, 0);
+ const unaligned = !!s.unaligned_checkpoint;
+ // In an unaligned checkpoint, async already includes the alignment (checkpoint_monitoring.md), so don't stack it.
+ const alignment = unaligned ? 0 : reportedAlignment;
+ const sync = Math.max(s.checkpoint.sync || 0, 0);
+ const asyncMs = Math.max(s.checkpoint.async || 0, 0);
+ const total = startDelay + alignment + sync + asyncMs;
+ rowOrder.push(row);
+ maxTotal = Math.max(maxTotal, total);
+ if (total === 0) {
+ instants.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ range: [base, base]
+ });
+ continue;
+ }
+
+ const segs: Array<[PhaseKey, number]> = [
+ ['start_delay', startDelay],
+ ['alignment', alignment],
+ ['sync', sync],
+ ['async', asyncMs]
+ ];
+ let cursor = base;
+ for (const [phase, ms] of segs) {
+ if (ms > 0) {
+ rows.push({
+ row,
+ operatorFull: opNameFull,
+ subtask: s.index,
+ phase,
+ phaseLabel: phase === 'async' && unaligned ? `${phase} (incl. ${reportedAlignment}ms alignment)` : phase,
+ range: [cursor, cursor + ms],
+ durationMs: ms,
+ aborted: !!s.aborted,
+ stateSize: s.state_size,
+ checkpointedSize: s.checkpointed_size,
+ totalDuration: total
+ });
+ }
+ cursor += ms;
+ }
+ }
+ }
+
+ // Unacked subtasks span the whole checkpoint: until it failed, or the latest ack so far while in progress.
+ const unackedEnd = base + Math.max(datum.duration, maxTotal, 1);
+ for (const u of unacked) {
+ u.range = [base, unackedEnd];
+ }
+
+ return { rows, unacked, instants, rowOrder };
+ }
+
+ private renderTimeline(datum: StripDatum, perVertex: Record<string, CheckpointSubTask | null>): void {
+ const { rows, unacked, instants, rowOrder } = this.buildTimelineRows(datum, perVertex);
+ if (rowOrder.length === 0) {
+ this.showEmptyTimeline();
+ return;
+ }
+ this.timelineEmpty = false;
+ this.cdr.markForCheck();
+
+ const C = JobCheckpointsTimelineComponent;
+ const chartHeight = Math.max(
Review Comment:
Also the aborted onces are at the slowest given they are the most informative and useful in the graph
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39566][runtime-web] Add checkpoint duration Gantt view [flink]
Posted by "ferenc-csaky (via GitHub) via issues" <is...@flink.apache.org>.
ferenc-csaky commented on PR #28060:
URL: https://github.com/apache/flink/pull/28060#issuecomment-6679723458
@nictownsend Thanks for chiming in and the valuable comments! Pls. let us know if you see any remaining issues, or have any other comments. I won't merge until you approve.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org