flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject [6/7] flink git commit: [FLINK-2939] add cancel button to web frontend
Date Tue, 03 Nov 2015 09:25:55 GMT
[FLINK-2939] add cancel button to web frontend

This closes #1313.


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

Branch: refs/heads/master
Commit: 143e5e0b815e34e4272525ed79bf9546995d1881
Parents: 5e40c6d
Author: Sachin Goel <sachingoel0101@gmail.com>
Authored: Sun Nov 1 15:54:13 2015 +0530
Committer: Maximilian Michels <mxm@apache.org>
Committed: Mon Nov 2 22:59:20 2015 +0100

----------------------------------------------------------------------
 .../runtime/webmonitor/WebRuntimeMonitor.java   |  6 ++-
 .../handlers/JobCancellationHandler.java        | 46 ++++++++++++++++++++
 .../web-dashboard/app/partials/jobs/job.jade    |  6 ++-
 .../app/scripts/modules/jobs/jobs.ctrl.coffee   |  4 ++
 .../app/scripts/modules/jobs/jobs.svc.coffee    |  3 ++
 .../web-dashboard/app/styles/index.styl         |  5 +--
 .../web-dashboard/web/css/index.css             |  2 +-
 flink-runtime-web/web-dashboard/web/js/index.js | 13 +++++-
 .../web-dashboard/web/partials/jobs/job.html    |  1 +
 9 files changed, 77 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/143e5e0b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
----------------------------------------------------------------------
diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
index e69165d..eed781e 100644
--- a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
+++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
@@ -36,6 +36,7 @@ import org.apache.flink.runtime.akka.AkkaUtils;
 import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService;
 import org.apache.flink.runtime.webmonitor.files.StaticFileServerHandler;
 import org.apache.flink.runtime.webmonitor.handlers.JobAccumulatorsHandler;
+import org.apache.flink.runtime.webmonitor.handlers.JobCancellationHandler;
 import org.apache.flink.runtime.webmonitor.handlers.JobManagerConfigHandler;
 import org.apache.flink.runtime.webmonitor.handlers.JobPlanHandler;
 import org.apache.flink.runtime.webmonitor.handlers.JobConfigHandler;
@@ -186,7 +187,10 @@ public class WebRuntimeMonitor implements WebMonitor {
 			.GET("/jobmanager/stdout", new StaticFileServerHandler(retriever, jobManagerAddressPromise.future(),
timeout, logFiles.stdOutFile))
 
 			// this handler serves all the static contents
-			.GET("/:*", new StaticFileServerHandler(retriever, jobManagerAddressPromise.future(),
timeout, webRootDir));
+			.GET("/:*", new StaticFileServerHandler(retriever, jobManagerAddressPromise.future(),
timeout, webRootDir))
+
+			// cancel a job
+			.DELETE("/jobs/:jobid", handler(new JobCancellationHandler()));
 
 		synchronized (startupShutdownLock) {
 

http://git-wip-us.apache.org/repos/asf/flink/blob/143e5e0b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JobCancellationHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JobCancellationHandler.java
b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JobCancellationHandler.java
new file mode 100644
index 0000000..20f28bb
--- /dev/null
+++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JobCancellationHandler.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.runtime.webmonitor.handlers;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.instance.ActorGateway;
+import org.apache.flink.runtime.messages.JobManagerMessages;
+import org.apache.flink.util.StringUtils;
+
+import java.util.Map;
+
+public class JobCancellationHandler implements RequestHandler, RequestHandler.JsonResponse
{
+
+	@Override
+	public String handleRequest(Map<String, String> params, ActorGateway jobManager) throws
Exception {
+		try {
+			JobID jobid = new JobID(StringUtils.hexStringToByte(params.get("jobid")));
+			if (jobManager != null) {
+				jobManager.tell(new JobManagerMessages.CancelJob(jobid));
+				return "";
+			}
+			else {
+				throw new Exception("No connection to the leading JobManager.");
+			}
+		}
+		catch (Exception e) {
+			throw new RuntimeException("Failed to cancel the job with id: "  + params.get("jobid")
+ e.getMessage(), e);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/143e5e0b/flink-runtime-web/web-dashboard/app/partials/jobs/job.jade
----------------------------------------------------------------------
diff --git a/flink-runtime-web/web-dashboard/app/partials/jobs/job.jade b/flink-runtime-web/web-dashboard/app/partials/jobs/job.jade
index d0291a4..bdfd7ea 100644
--- a/flink-runtime-web/web-dashboard/app/partials/jobs/job.jade
+++ b/flink-runtime-web/web-dashboard/app/partials/jobs/job.jade
@@ -35,10 +35,14 @@ nav.navbar.navbar-default.navbar-fixed-top.navbar-main(ng-if="job")
     span(ng-if="job['end-time'] > -1")
       | - 
       | {{ job['end-time'] | amDateFormat:'YYYY-MM-DD, H:mm:ss' }}
-  
+
   .navbar-info.last.first(ng-if="job.duration > -1")
     | {{job.duration}} ms
 
+  .navbar-info.last.first(ng-if="job.state=='RUNNING' || job.state=='CREATED'")
+    span.show-pointer.label.label-danger(ng-click="cancelJob($event)")
+      | Cancel
+
 nav.navbar.navbar-default.navbar-fixed-top.navbar-main-additional(ng-if="job")
   ul.nav.nav-tabs
     li(ui-sref-active='active')

http://git-wip-us.apache.org/repos/asf/flink/blob/143e5e0b/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.ctrl.coffee
----------------------------------------------------------------------
diff --git a/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.ctrl.coffee b/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.ctrl.coffee
index 037a7e8..e18a5fc 100644
--- a/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.ctrl.coffee
+++ b/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.ctrl.coffee
@@ -70,6 +70,10 @@ angular.module('flinkApp')
 
     $interval.cancel(refresher)
 
+  $scope.cancelJob = (cancelEvent) ->
+    angular.element(cancelEvent.currentTarget).removeClass('label-danger').addClass('label-info').html('Cancelling...')
+    JobsService.cancelJob($stateParams.jobid).then (data) ->
+      {}
 
 # --------------------------------------
 

http://git-wip-us.apache.org/repos/asf/flink/blob/143e5e0b/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.svc.coffee
----------------------------------------------------------------------
diff --git a/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.svc.coffee b/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.svc.coffee
index 2e45cd9..698437f 100644
--- a/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.svc.coffee
+++ b/flink-runtime-web/web-dashboard/app/scripts/modules/jobs/jobs.svc.coffee
@@ -211,4 +211,7 @@ angular.module('flinkApp')
 
     deferred.promise
 
+  @cancelJob = (jobid) ->
+    $http.delete "jobs/" + jobid
+
   @

http://git-wip-us.apache.org/repos/asf/flink/blob/143e5e0b/flink-runtime-web/web-dashboard/app/styles/index.styl
----------------------------------------------------------------------
diff --git a/flink-runtime-web/web-dashboard/app/styles/index.styl b/flink-runtime-web/web-dashboard/app/styles/index.styl
index 25e1170..7d97efc 100644
--- a/flink-runtime-web/web-dashboard/app/styles/index.styl
+++ b/flink-runtime-web/web-dashboard/app/styles/index.styl
@@ -420,8 +420,5 @@ livechart
 #non-heap-mem
   background-color: #90ed7d
 
-a.show-pointer
+.show-pointer
   cursor: pointer
-
-
-

http://git-wip-us.apache.org/repos/asf/flink/blob/143e5e0b/flink-runtime-web/web-dashboard/web/css/index.css
----------------------------------------------------------------------
diff --git a/flink-runtime-web/web-dashboard/web/css/index.css b/flink-runtime-web/web-dashboard/web/css/index.css
index 43f7d98..101f4cb 100644
--- a/flink-runtime-web/web-dashboard/web/css/index.css
+++ b/flink-runtime-web/web-dashboard/web/css/index.css
@@ -591,6 +591,6 @@ svg.graph .node-label {
 #non-heap-mem {
   background-color: #90ed7d;
 }
-a.show-pointer {
+.show-pointer {
   cursor: pointer;
 }


Mime
View raw message