helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [06/14] helix git commit: Simple workflow pause/resume
Date Sat, 18 Aug 2018 00:20:06 GMT
Simple workflow pause/resume


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/d192afcc
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/d192afcc
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/d192afcc

Branch: refs/heads/master
Commit: d192afccfd950092ab902d9be042aa8a73a4c80e
Parents: 3c3f289
Author: Vivo Xu <vxu@linkedin.com>
Authored: Wed Feb 28 13:46:55 2018 -0800
Committer: Vivo Xu <vxu@linkedin.com>
Committed: Wed Aug 8 15:32:21 2018 -0700

----------------------------------------------------------------------
 .../app/workflow/shared/workflow.service.ts     | 10 ++++++
 .../workflow-detail.component.html              | 14 ++++++++
 .../workflow-detail.component.ts                | 38 +++++++++++++++++---
 3 files changed, 57 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/d192afcc/helix-front/client/app/workflow/shared/workflow.service.ts
----------------------------------------------------------------------
diff --git a/helix-front/client/app/workflow/shared/workflow.service.ts b/helix-front/client/app/workflow/shared/workflow.service.ts
index 9be5337..0602a15 100644
--- a/helix-front/client/app/workflow/shared/workflow.service.ts
+++ b/helix-front/client/app/workflow/shared/workflow.service.ts
@@ -17,4 +17,14 @@ export class WorkflowService extends HelixService {
       .request(`/clusters/${ clusterName }/workflows/${ workflowName }`)
       .map(data => new Workflow(data, clusterName));
   }
+
+  public stop(clusterName: string, workflowName: string) {
+    return this
+      .post(`/clusters/${ clusterName }/workflows/${ workflowName }?command=stop`, null);
+  }
+
+  public resume(clusterName: string, workflowName: string) {
+    return this
+      .post(`/clusters/${ clusterName }/workflows/${ workflowName }?command=resume`, null);
+  }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/d192afcc/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.html
----------------------------------------------------------------------
diff --git a/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.html
b/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.html
index 276e116..e6c816a 100644
--- a/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.html
+++ b/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.html
@@ -13,6 +13,20 @@
       <hi-key-value-pair name="Failure Threshold" prop="config.FailureThreshold"></hi-key-value-pair>
       <hi-key-value-pair name="Expiry" prop="config.Expiry"></hi-key-value-pair>
     </hi-key-value-pairs>
+    <span fxFlex="1 1 auto"></span>
+    <button mat-mini-fab *ngIf="can" [matMenuTriggerFor]="menu">
+      <mat-icon>menu</mat-icon>
+    </button>
+    <mat-menu #menu="matMenu">
+      <button mat-menu-item (click)="stopWorkflow()">
+        <mat-icon>pause_circle_outline</mat-icon>
+        <span>Pause this Workflow</span>
+      </button>
+      <button mat-menu-item (click)="resumeWorkflow()">
+        <mat-icon>play_circle_outline</mat-icon>
+        <span>Resume this workflow</span>
+      </button>
+    </mat-menu>
   </mat-toolbar-row>
 </mat-toolbar>
 <section fxLayout="column" fxLayoutAlign="center center">

http://git-wip-us.apache.org/repos/asf/helix/blob/d192afcc/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.ts
----------------------------------------------------------------------
diff --git a/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.ts
b/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.ts
index a8adcfa..e90af41 100644
--- a/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.ts
+++ b/helix-front/client/app/workflow/workflow-detail/workflow-detail.component.ts
@@ -15,6 +15,8 @@ export class WorkflowDetailComponent implements OnInit {
   isLoading = true;
   workflow: Workflow;
   clusterName: string;
+  workflowName: string;
+  can = false;
 
   constructor(
     protected route: ActivatedRoute,
@@ -24,12 +26,38 @@ export class WorkflowDetailComponent implements OnInit {
 
   ngOnInit() {
     this.clusterName = this.route.snapshot.params['cluster_name'];
+    this.workflowName = this.route.snapshot.params['workflow_name'];
 
-    this.service
-      .get(
-        this.route.snapshot.params['cluster_name'],
-        this.route.snapshot.params['workflow_name']
-      )
+    this.service.can().subscribe(data => this.can = data);
+
+    this.loadWorkflow();
+  }
+
+  stopWorkflow() {
+    this.service.stop(this.clusterName, this.workflowName)
+      .subscribe(
+        () => {
+          this.helper.showSnackBar('Pause command sent.');
+          this.loadWorkflow();
+        },
+        error => this.helper.showError(error)
+      );
+  }
+
+  resumeWorkflow() {
+    this.service.resume(this.clusterName, this.workflowName)
+      .subscribe(
+        () => {
+          this.helper.showSnackBar('Resume command sent.');
+          this.loadWorkflow();
+        },
+        error => this.helper.showError(error)
+      );
+  }
+
+  protected loadWorkflow() {
+    this.isLoading = true;
+    this.service.get(this.clusterName, this.workflowName)
       .subscribe(
         workflow => this.workflow = workflow,
         error => this.helper.showError(error),


Mime
View raw message