flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmetz...@apache.org
Subject [1/2] flink git commit: [FLINK-2175] extending WebClient and CLI to show ProgramDescription added WordCountMeta example (used ProgramDescription interface to display meta data by clients) extended WebClient documenation
Date Wed, 01 Jul 2015 10:56:56 GMT
Repository: flink
Updated Branches:
  refs/heads/master abaf4af17 -> bd3c8d525


[FLINK-2175] extending WebClient and CLI to show ProgramDescription
added WordCountMeta example (used ProgramDescription interface to display meta data by clients)
extended WebClient documenation

This closes #707


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

Branch: refs/heads/master
Commit: bd3c8d525203fddf1770b6eb7221f71049480ad8
Parents: 7e75c7b
Author: mjsax <mjsax@informatik.hu-berlin.de>
Authored: Fri Jun 5 18:55:08 2015 +0200
Committer: Robert Metzger <rmetzger@apache.org>
Committed: Wed Jul 1 12:56:41 2015 +0200

----------------------------------------------------------------------
 docs/apis/web_client.md                         |  4 +-
 .../org/apache/flink/client/CliFrontend.java    | 10 ++++
 .../apache/flink/client/web/JobsServlet.java    | 19 ++++++-
 .../src/main/resources/web-docs/js/program.js   |  7 ++-
 .../examples/java/wordcount/WordCountMeta.java  | 54 ++++++++++++++++++++
 5 files changed, 90 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/bd3c8d52/docs/apis/web_client.md
----------------------------------------------------------------------
diff --git a/docs/apis/web_client.md b/docs/apis/web_client.md
index a548a6a..d3680f1 100644
--- a/docs/apis/web_client.md
+++ b/docs/apis/web_client.md
@@ -56,12 +56,14 @@ You can **upload** a Flink program as a jar file. To **execute** an uploaded
pro
 
 If the *“Show optimizer plan”* option is enabled (default), the *plan view* is display
next, otherwise the job is directly submitted to the JobManager for execution.
 
-In case the jar's manifest file does not specify the program class, you can specify it before
the argument list as:
+The web interface can also handle multiple Flink jobs within a single jar file. To use this
feature, package all required class files of all jobs into a single jar and specify the entry
classes for each job as comma-separated-values in *program-class* argument within the jar's
manifest file. The job view displays each entry class and you can pick any of them to preview
the plan and/or submit the job to the JobManager. In case the jar's manifest file does not
specify any entry class, you can specify it before the argument list as:
 
 ```
 -c <assemblerClass> <programArgs...>
 ```
 
+Furthermore, for each entry class implementing ```ProgramDescription``` interface, the provided
description is shown as tooltip for the job (see {% gh_link flink-examples/flink-java-examples/src/main/java/org/apache/flink/examples/java/wordcount/WordCountMeta.java
 "WordCountMeta example" %}).
+
 ### Plan View
 
 The plan view shows the optimized execution plan of the submitted program in the upper half
of the page. The bottom part of the page displays detailed information about the currently
selected plan operator including:

http://git-wip-us.apache.org/repos/asf/flink/blob/bd3c8d52/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java
----------------------------------------------------------------------
diff --git a/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java b/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java
index e1bacde..241df2d 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java
@@ -378,6 +378,16 @@ public class CliFrontend {
 			else {
 				System.out.println("JSON plan could not be generated.");
 			}
+
+			String description = program.getDescription();
+			if (description != null) {
+				System.out.println();
+				System.out.println(description);
+			}
+			else {
+				System.out.println();
+				System.out.println("No description provided.");
+			}
 			return 0;
 		}
 		catch (Throwable t) {

http://git-wip-us.apache.org/repos/asf/flink/blob/bd3c8d52/flink-clients/src/main/java/org/apache/flink/client/web/JobsServlet.java
----------------------------------------------------------------------
diff --git a/flink-clients/src/main/java/org/apache/flink/client/web/JobsServlet.java b/flink-clients/src/main/java/org/apache/flink/client/web/JobsServlet.java
index cee13dd..abf3b3f 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/web/JobsServlet.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/web/JobsServlet.java
@@ -41,6 +41,7 @@ import org.apache.commons.fileupload.FileUploadException;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.flink.client.program.PackagedProgram;
+import org.apache.flink.client.program.ProgramInvocationException;
 
 /**
  * A servlet that accepts uploads of pact programs, returns a listing of the
@@ -144,6 +145,8 @@ public class JobsServlet extends HttpServlet {
 				JarFile jar = new JarFile(files[i]);
 				Manifest manifest = jar.getManifest();
 				String assemblerClass = null;
+				String descriptions = "";
+
 				if (manifest != null) {
 					assemblerClass = manifest.getMainAttributes().getValue(PackagedProgram.MANIFEST_ATTRIBUTE_ASSEMBLER_CLASS);
 					if (assemblerClass == null) {
@@ -153,6 +156,20 @@ public class JobsServlet extends HttpServlet {
 				if (assemblerClass == null) {
 					assemblerClass = "";
 				} else {
+					String[] classes = assemblerClass.split(",");
+					for (String c : classes) {
+						try {
+							String d = new PackagedProgram(files[i], c, new String[0]).getDescription();
+							if (d == null) {
+								d = "No description provided.";
+							}
+							descriptions += "#_#" + d;
+						} catch (ProgramInvocationException e) {
+							descriptions += "#_#No description provided.";
+							continue;
+						}
+					}
+
 					assemblerClass = '\t' + assemblerClass;
 				}
 
@@ -160,7 +177,7 @@ public class JobsServlet extends HttpServlet {
 				writer.println(files[i].getName() + '\t' + (cal.get(GregorianCalendar.MONTH) + 1) + '/'
 					+ cal.get(GregorianCalendar.DAY_OF_MONTH) + '/' + cal.get(GregorianCalendar.YEAR) +
' '
 					+ cal.get(GregorianCalendar.HOUR_OF_DAY) + ':' + cal.get(GregorianCalendar.MINUTE) +
':'
-					+ cal.get(GregorianCalendar.SECOND) + assemblerClass);
+					+ cal.get(GregorianCalendar.SECOND) + assemblerClass + descriptions);
 			}
 		} else if (action.equals(ACTION_DELETE_VALUE)) {
 			String filename = req.getParameter(FILENAME_PARAM_NAME);

http://git-wip-us.apache.org/repos/asf/flink/blob/bd3c8d52/flink-clients/src/main/resources/web-docs/js/program.js
----------------------------------------------------------------------
diff --git a/flink-clients/src/main/resources/web-docs/js/program.js b/flink-clients/src/main/resources/web-docs/js/program.js
index 619deb8..d3c4c88 100644
--- a/flink-clients/src/main/resources/web-docs/js/program.js
+++ b/flink-clients/src/main/resources/web-docs/js/program.js
@@ -150,7 +150,9 @@ function createJobList(data)
 {
   var markup = "";
   
-  var lines = data.split("\n");
+  var entries = data.split("#_#");
+  
+  var lines = entries[0].split("\n");
   for (var i = 0; i < lines.length; i++)
   {
     if (lines[i] == null || lines[i].length == 0) {
@@ -179,9 +181,10 @@ function createJobList(data)
     markup += '<td><p class="JobListItemsDate">' + date + '</p></td>';
     markup += '<td width="30px"><img class="jobItemDeleteIcon" src="img/delete-icon.png"
width="24" height="24" /></td></tr>';
     
+    var i = 0;
     for (var idx in classes) {
       markup += '<tr><td width="30px;"><input id="' + classes[idx] + '" class="jobItemCheckbox"
type="checkbox"></td>';
-      markup += '<td colspan="3"><p class="JobListItemsDate">' + classes[idx]
+ '</p></td></tr>';
+      markup += '<td colspan="3"><p class="JobListItemsDate" title="' + entries[++i]
+ '">' + classes[idx] + '</p></td></tr>';
     }
     markup += '</table></div>';
   }

http://git-wip-us.apache.org/repos/asf/flink/blob/bd3c8d52/flink-examples/flink-java-examples/src/main/java/org/apache/flink/examples/java/wordcount/WordCountMeta.java
----------------------------------------------------------------------
diff --git a/flink-examples/flink-java-examples/src/main/java/org/apache/flink/examples/java/wordcount/WordCountMeta.java
b/flink-examples/flink-java-examples/src/main/java/org/apache/flink/examples/java/wordcount/WordCountMeta.java
new file mode 100644
index 0000000..b8bd7c1
--- /dev/null
+++ b/flink-examples/flink-java-examples/src/main/java/org/apache/flink/examples/java/wordcount/WordCountMeta.java
@@ -0,0 +1,54 @@
+/*
+ * 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.examples.java.wordcount;
+
+import org.apache.flink.api.common.ProgramDescription;
+import org.apache.flink.examples.java.wordcount.util.WordCountData;
+
+/**
+ * Same as {@link WorkCount} but implements {@link ProgramDescription} interface.
+ * 
+ * <p>
+ * The input is a plain text file with lines separated by newline characters.
+ * 
+ * <p>
+ * Usage: <code>WordCountProgram [&lt;text path&gt; &lt;result path&gt;]</code><br>
+ * If no parameters are provided, the program is run with default data from {@link WordCountData}.
+ * 
+ * <p>
+ * This example shows:
+ * <ul>
+ * <li>how to provide additional information (using {@link ProgramDescription} interface},
that can be displayed by
+ * Flink clients, ie, {@link bin/flink} and WebClient</li>
+ * </ul>
+ * 
+ */
+public class WordCountMeta extends WordCount implements ProgramDescription {
+
+	public static void main(String[] args) throws Exception {
+		WordCount.main(args);
+	}
+
+	@Override
+	public String getDescription() {
+		return "Simple Word-Count Example\n"
+				+ "Parameters: [<text path> <result path>]\n"
+				+ "If no parameters are provided, the example will run with built-in default data.";
+	}
+}


Mime
View raw message