yangjunhan commented on code in PR #18868:
URL: https://github.com/apache/flink/pull/18868#discussion_r869956168
##########
flink-runtime-web/web-dashboard/src/app/pages/job/checkpoints/job-checkpoints.component.ts:
##########
@@ -16,45 +16,90 @@
* limitations under the License.
*/
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from
'@angular/core';
-import { distinctUntilChanged } from 'rxjs/operators';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy,
OnInit } from '@angular/core';
+import { forkJoin, of, Subject } from 'rxjs';
+import { catchError, distinctUntilChanged, switchMap, takeUntil } from
'rxjs/operators';
-import { CheckpointConfig, CheckpointHistory, Checkpoint, JobDetailCorrect }
from 'interfaces';
-import { JobService } from 'services';
+import { CheckpointConfig, CheckpointHistory, Checkpoint, JobDetailCorrect }
from '@flink-runtime-web/interfaces';
+import { JobService } from '@flink-runtime-web/services';
+
+import { JobLocalService } from '../job-local.service';
@Component({
selector: 'flink-job-checkpoints',
templateUrl: './job-checkpoints.component.html',
styleUrls: ['./job-checkpoints.component.less'],
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class JobCheckpointsComponent implements OnInit {
+export class JobCheckpointsComponent implements OnInit, OnDestroy {
public readonly trackById = (_: number, node: CheckpointHistory): number =>
node.id;
- public checkPointStats: Checkpoint;
- public checkPointConfig: CheckpointConfig;
+ public checkPointStats?: Checkpoint;
+ public checkPointConfig?: CheckpointConfig;
public jobDetail: JobDetailCorrect;
+ public empty = true;
public moreDetailsPanel = { active: false, disabled: false };
- constructor(private readonly jobService: JobService, private readonly cdr:
ChangeDetectorRef) {}
+ private refresh$ = new Subject<void>();
+ private destroy$ = new Subject<void>();
+
+ constructor(
+ private readonly jobService: JobService,
+ private readonly jobLocalService: JobLocalService,
+ private readonly cdr: ChangeDetectorRef
+ ) {}
public ngOnInit(): void {
- this.jobService.jobDetail$.pipe(distinctUntilChanged((pre, next) =>
pre.jid === next.jid)).subscribe(data => {
- this.jobDetail = data;
- this.jobService.loadCheckpointStats(this.jobDetail.jid).subscribe(stats
=> {
- this.checkPointStats = stats;
- this.cdr.markForCheck();
+ this.refresh$
+ .pipe(
+ switchMap(() =>
+ forkJoin([
+ this.jobService.loadCheckpointStats(this.jobDetail.jid),
+ this.jobService.loadCheckpointConfig(this.jobDetail.jid).pipe(
+ catchError(() => {
+ // cp config error won't block displaying cp stats
+ return of(undefined);
+ })
+ )
+ ])
+ ),
+ takeUntil(this.destroy$)
+ )
+ .subscribe({
+ next: ([stats, config]) => {
+ this.empty = false;
+ this.checkPointStats = stats;
+ this.checkPointConfig = config;
+ this.cdr.markForCheck();
+ },
+ error: () => {
+ // only happens when loadCheckpointStats request fails
+ this.empty = true;
+ this.cdr.markForCheck();
+ }
Review Comment:
I get what u mean now. Fixed it already.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]