You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ju...@apache.org on 2022/12/12 03:40:07 UTC

[flink] branch master updated: [FLINK-30250][web][flame-graph] Fix the bug that show the flame graph of old type (#21432)

This is an automated email from the ASF dual-hosted git repository.

junhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 6af92a3eda4 [FLINK-30250][web][flame-graph] Fix the bug that show the flame graph of old type (#21432)
6af92a3eda4 is described below

commit 6af92a3eda4d243f765f6ea0c8c548ca70ca423a
Author: Rui Fan <19...@gmail.com>
AuthorDate: Mon Dec 12 11:40:00 2022 +0800

    [FLINK-30250][web][flame-graph] Fix the bug that show the flame graph of old type (#21432)
    
    * [FLINK-30250][refactor][flame-graph] Using the enum to manage the graphType instead of string
    
    * [FLINK-30250][web][flame-graph] Fix the bug that show the flame graph of old graph type
---
 .../app/components/flame-graph/flame-graph.component.ts |  6 +++---
 .../web-dashboard/src/app/interfaces/job-flamegraph.ts  |  6 ++++++
 .../job-overview-drawer-flamegraph.component.html       | 12 ++++++------
 .../job-overview-drawer-flamegraph.component.ts         | 17 +++++++++--------
 4 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/flink-runtime-web/web-dashboard/src/app/components/flame-graph/flame-graph.component.ts b/flink-runtime-web/web-dashboard/src/app/components/flame-graph/flame-graph.component.ts
index 6c36fa63e33..14db6cddc91 100644
--- a/flink-runtime-web/web-dashboard/src/app/components/flame-graph/flame-graph.component.ts
+++ b/flink-runtime-web/web-dashboard/src/app/components/flame-graph/flame-graph.component.ts
@@ -18,7 +18,7 @@
 
 import { Component, ChangeDetectionStrategy, ElementRef, Input, ViewChild } from '@angular/core';
 
-import { JobFlameGraphNode } from '@flink-runtime-web/interfaces';
+import { FlameGraphType, JobFlameGraphNode } from '@flink-runtime-web/interfaces';
 import * as _d3 from 'd3';
 import { flamegraph, offCpuColorMapper } from 'd3-flame-graph';
 import { format } from 'd3-format';
@@ -35,7 +35,7 @@ import _d3Tip from 'd3-tip';
 export class FlameGraphComponent {
   @ViewChild('flameGraphContainer', { static: true }) flameGraphContainer: ElementRef<Element>;
   @Input() data: JobFlameGraphNode;
-  @Input() graphType: string;
+  @Input() graphType: FlameGraphType;
 
   draw(): void {
     if (this.data) {
@@ -55,7 +55,7 @@ export class FlameGraphComponent {
 
       chart.tooltip(tip);
 
-      if (this.graphType == 'off_cpu') {
+      if (this.graphType == FlameGraphType.OFF_CPU) {
         chart.setColorMapper(offCpuColorMapper);
       }
 
diff --git a/flink-runtime-web/web-dashboard/src/app/interfaces/job-flamegraph.ts b/flink-runtime-web/web-dashboard/src/app/interfaces/job-flamegraph.ts
index 3001b53f8a3..6685b723a6e 100644
--- a/flink-runtime-web/web-dashboard/src/app/interfaces/job-flamegraph.ts
+++ b/flink-runtime-web/web-dashboard/src/app/interfaces/job-flamegraph.ts
@@ -27,3 +27,9 @@ export interface JobFlameGraphNode {
   value: number;
   children: JobFlameGraphNode[];
 }
+
+export enum FlameGraphType {
+  ON_CPU = 'on_cpu',
+  OFF_CPU = 'off_cpu',
+  FULL = 'full'
+}
diff --git a/flink-runtime-web/web-dashboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.html b/flink-runtime-web/web-dashboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.html
index b5b49d59e15..92cd970e53b 100644
--- a/flink-runtime-web/web-dashboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.html
+++ b/flink-runtime-web/web-dashboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.html
@@ -24,24 +24,24 @@ Type:
 <nz-radio-group [(ngModel)]="graphType" nzButtonStyle="solid">
   <label
     nz-radio-button
-    nzValue="on_cpu"
-    (click)="selectFrameGraphType()"
+    [nzValue]="FlameGraphType.ON_CPU"
+    (click)="selectFrameGraphType(FlameGraphType.ON_CPU)"
     title="Includes Thread.State.[RUNNABLE, NEW]"
   >
     On-CPU
   </label>
   <label
     nz-radio-button
-    nzValue="off_cpu"
-    (click)="selectFrameGraphType()"
+    [nzValue]="FlameGraphType.OFF_CPU"
+    (click)="selectFrameGraphType(FlameGraphType.OFF_CPU)"
     title="Includes Thread.State.[WAITING, TIMED_WAITING, BLOCKED]"
   >
     Off-CPU
   </label>
   <label
     nz-radio-button
-    nzValue="full"
-    (click)="selectFrameGraphType()"
+    [nzValue]="FlameGraphType.FULL"
+    (click)="selectFrameGraphType(FlameGraphType.FULL)"
     title="Includes stack traces of threads in all states"
   >
     Mixed
diff --git a/flink-runtime-web/web-dashboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.ts b/flink-runtime-web/web-dashboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.ts
index 96216cf714f..acc182e6a6a 100644
--- a/flink-runtime-web/web-dashboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.ts
+++ b/flink-runtime-web/web-dashboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.ts
@@ -24,7 +24,7 @@ import { mergeMap, takeUntil, tap } from 'rxjs/operators';
 
 import { FlameGraphComponent } from '@flink-runtime-web/components/flame-graph/flame-graph.component';
 import { HumanizeDurationPipe } from '@flink-runtime-web/components/humanize-duration.pipe';
-import { JobFlameGraph, NodesItemCorrect } from '@flink-runtime-web/interfaces';
+import { FlameGraphType, JobFlameGraph, NodesItemCorrect } from '@flink-runtime-web/interfaces';
 import { JobService } from '@flink-runtime-web/services';
 import { NzRadioModule } from 'ng-zorro-antd/radio';
 import { NzSpinModule } from 'ng-zorro-antd/spin';
@@ -50,12 +50,13 @@ import { JobLocalService } from '../../job-local.service';
   standalone: true
 })
 export class JobOverviewDrawerFlameGraphComponent implements OnInit, OnDestroy {
+  readonly FlameGraphType = FlameGraphType;
   public isLoading = true;
   public now = Date.now();
   public selectedVertex: NodesItemCorrect | null;
   public flameGraph = {} as JobFlameGraph;
 
-  public graphType = 'on_cpu';
+  public graphType = FlameGraphType.ON_CPU;
 
   private readonly destroy$ = new Subject<void>();
 
@@ -66,7 +67,7 @@ export class JobOverviewDrawerFlameGraphComponent implements OnInit, OnDestroy {
   ) {}
 
   public ngOnInit(): void {
-    this.requestFlameGraph();
+    this.requestFlameGraph(this.graphType);
   }
 
   public ngOnDestroy(): void {
@@ -74,12 +75,12 @@ export class JobOverviewDrawerFlameGraphComponent implements OnInit, OnDestroy {
     this.destroy$.complete();
   }
 
-  private requestFlameGraph(): void {
+  private requestFlameGraph(graphType: FlameGraphType): void {
     this.jobLocalService
       .jobWithVertexChanges()
       .pipe(
         tap(data => (this.selectedVertex = data.vertex)),
-        mergeMap(data => this.jobService.loadOperatorFlameGraph(data.job.jid, data.vertex!.id, this.graphType)),
+        mergeMap(data => this.jobService.loadOperatorFlameGraph(data.job.jid, data.vertex!.id, graphType)),
         takeUntil(this.destroy$)
       )
       .subscribe(
@@ -88,7 +89,7 @@ export class JobOverviewDrawerFlameGraphComponent implements OnInit, OnDestroy {
           if (this.flameGraph.endTimestamp !== data['endTimestamp']) {
             this.isLoading = false;
             this.flameGraph = data;
-            this.flameGraph.graphType = this.graphType;
+            this.flameGraph.graphType = graphType;
           }
           this.cdr.markForCheck();
         },
@@ -99,9 +100,9 @@ export class JobOverviewDrawerFlameGraphComponent implements OnInit, OnDestroy {
       );
   }
 
-  public selectFrameGraphType(): void {
+  public selectFrameGraphType(graphType: FlameGraphType): void {
     this.destroy$.next();
     this.flameGraph = {} as JobFlameGraph;
-    this.requestFlameGraph();
+    this.requestFlameGraph(graphType);
   }
 }