flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trohrm...@apache.org
Subject [37/82] [abbrv] incubator-flink git commit: Moved WebInfoServer and WebInterfaceServer resources into resource folders of respective projects. Jetty uses the jar as base directory.
Date Thu, 18 Dec 2014 18:45:33 GMT
http://git-wip-us.apache.org/repos/asf/incubator-flink/blob/76d603c0/flink-clients/resources/web-docs/js/program.js
----------------------------------------------------------------------
diff --git a/flink-clients/resources/web-docs/js/program.js b/flink-clients/resources/web-docs/js/program.js
deleted file mode 100644
index c443dab..0000000
--- a/flink-clients/resources/web-docs/js/program.js
+++ /dev/null
@@ -1,240 +0,0 @@
-/*!
- * 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.
- */
-
-var maxColumnWidth = 200;
-var minColumnWidth = 100;
-
-// global variable for the currently requested plan
-var pactPlanRequested = 0;
-
-/*
- * This function toggels the child checkbox on and of, depending on the parent's state
- */
-function toggleShowPlanBox(box)
-{
-  var child = $('#suspendJobDuringPlanCheck');
-  
-  if (box.is(':checked')) {
-    child.attr('disabled', false);
-  }
-  else {
-    child.attr('disabled', true);
-  }
-}
-
-/*
- * Shows an error message below the upload field.
- */
-function showUploadError(message)
-{
-  $('#upload_error_text').fadeOut("fast", function () { $('#upload_error_text')[0].innerHTML
= "" + message;
-                                                           $('#upload_error_text').fadeIn("slow");
} );
-}
-
-/*
- * Checks the selected file and triggers an upload, if all is correct.
- */
-function processUpload()
-{
-
-  var filename = $('#upload_file_input').val();
-  var len = filename.length;
-  if (len == 0) {
-    showUploadError("Please select a file.");
-  }
-  else if (len > 4 && filename.substr(len - 4, len) == ".jar") {
-    $('#upload_form')[0].submit();
-  }
-  else {
-    showUploadError("Please select a .jar file.");
-  }
-}
-
-/*
- * This function makes sure only one checkbox is selected.
- * Upon selection it initializes the drawing of the pact plan.
- * Upon deselection, it clears the pact plan.
- */
-function toggleCheckboxes(box)
-{
-
-  if (box.is(':checked')) {
-    $('.jobItemCheckbox').attr('checked', false);
-    box.attr('checked', true);
-    var id = box.parentsUntil('.JobListItems').parent().attr('id').substr(4);
-
-    $('#mainCanvas').html('');
-    $('#planDescription').html('');
-    pactPlanRequested = id;
-
-    $.ajax({
-        type: "GET",
-        url: "pactPlan",
-        data: { job: id },
-        success: function(response) { showPreviewPlan(response); }
-    });
-  }
-  else {
-    $('#mainCanvas').html('');
-    $('#planplanDescription').html('');
-  }
-}
-
-/*
- * Function that takes the returned plan and draws it.
- */
-function showPreviewPlan(data)
-{
-	//TODO check again the stuff below
-//  // check whether this one is still selected
-//  var active = $('.jobItemCheckbox:checked');
-//  var id = active.parentsUntil('.JobListItems').parent().attr('id').substr(4);
-//  
-//  if (pactPlanRequested == id) {
-//    if (data == undefined || data.jobname == undefined || data.jobname != pactPlanRequested
|| data.plan == undefined) {
-//      pactPlanRequested = 0;
-//    }
-//
-//	if(data.description != undefined) {
-//		$('#planDescription').html(data.description);
-//	}
-	
-	$("#mainCanvas").empty();
-    var svgElement = "<div id=\"attach\"><svg id=\"svg-main\" width=500 height=500><g
transform=\"translate(20, 20)\"/></svg></div>";
-    $("#mainCanvas").append(svgElement);
-    drawGraph(data.plan, "#svg-main");
-    pactPlanRequested = 0;
-    
-    //activate zoom buttons
-    activateZoomButtons();
-//  }
-}
-
-/*
- * Asynchronously loads the jobs and creates a list of them.
- */
-function loadJobList()
-{
-  $.get("jobs", { action: "list" }, createJobList);
-}
-
-/*
- * Triggers an AJAX request to delete a job.
- */
-function deleteJob(id)
-{
-  var name = id.substr(4);
-  $.get("jobs", { action: "delete", filename: name }, loadJobList);
-}
-
-/*
- * Creates and lists the returned jobs.
- */
-function createJobList(data)
-{
-  var markup = "";
-  
-  var lines = data.split("\n");
-  for (var i = 0; i < lines.length; i++)
-  {
-    if (lines[i] == null || lines[i].length == 0) {
-      continue;
-
-    }
-    
-    var name = null;
-    var date = null;
-    var tabIx = lines[i].indexOf("\t");
-
-    if (tabIx > 0) {
-      name = lines[i].substr(0, tabIx);
-      if (tabIx < lines[i].length - 1) {
-        date = lines[i].substr(tabIx + 1);
-      }
-      else {
-        date = "unknown date";
-      }
-    }
-    else {
-      name = lines[i];
-      date = "unknown date";
-    }
-    
-    
-    markup += '<div id="job_' + name + '" class="JobListItems"><table class="table"><tr>';
-    markup += '<td width="30px;"><input class="jobItemCheckbox" type="checkbox"></td>';
-    markup += '<td><p class="JobListItemsName">' + name + '</p></td>';
-    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>';
-    markup += '</tr></table></div>';
-  }
-  
-  // add the contents
-  $('#jobsContents').html(markup); 
-  
-  // register the event handler that triggers the delete when the delete icon is clicked
-  $('.jobItemDeleteIcon').click(function () { deleteJob($(this).parentsUntil('.JobListItems').parent().attr('id'));
} );
-  
-  // register the event handler, that ensures only one checkbox is active
-  $('.jobItemCheckbox').change(function () { toggleCheckboxes($(this)) });
-}
-
-/*
- * Function that checks and launches a pact job.
- */
-function runJob ()
-{
-   var job = $('.jobItemCheckbox:checked');
-   if (job.length == 0) {
-     $('#run_error_text').fadeOut("fast", function () { $('#run_error_text')[0].innerHTML
= "Select a job to run.";
-                                                           $('#run_error_text').fadeIn("slow");
} );
-     return;
-   }
-   
-   var jobName = job.parentsUntil('.JobListItems').parent().attr('id').substr(4);
-   var showPlan = $('#showPlanCheck').is(':checked');
-   var suspendPlan = $('#suspendJobDuringPlanCheck').is(':checked');
-   var args = $('#commandLineArgsField').attr('value'); //TODO? Replace with .val() ?
-   
-   var url = "runJob?" + $.param({ action: "submit", job: jobName, arguments: args, show_plan:
showPlan, suspend: suspendPlan});
-   
-   window.location = url;
-}
-
-/*
- * Document initialization.
- */
-$(document).ready(function ()
-{
-  // hide the error text sections
-  $('#upload_error_text').fadeOut("fast");
-  $('#run_error_text').fadeOut("fast");
-  
-  // register the event listener that keeps the hidden file form and the text fied in sync
-  $('#upload_file_input').change(function () { $('#upload_file_name_text').val($(this).val())
} );
-  
-  // register the event handler for the upload button
-  $('#upload_submit_button').click(processUpload);
-  $('#run_button').click(runJob);
-  
-  // register the event handler that (in)activates the plan display checkbox
-  $('#showPlanCheck').change(function () { toggleShowPlanBox ($(this)); }); 
-  
-  // start the ajax load of the jobs
-  loadJobList();
-}); 

http://git-wip-us.apache.org/repos/asf/incubator-flink/blob/76d603c0/flink-clients/resources/web-docs/launch.html
----------------------------------------------------------------------
diff --git a/flink-clients/resources/web-docs/launch.html b/flink-clients/resources/web-docs/launch.html
deleted file mode 100755
index 7564177..0000000
--- a/flink-clients/resources/web-docs/launch.html
+++ /dev/null
@@ -1,110 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!--
-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.
--->
-<html>
-
-<head>
-  <title>Flink Query Interface</title>
-
-  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
-  <link rel="stylesheet" type="text/css" href="css/nephelefrontend.css" />
-  <link rel="stylesheet" type="text/css" href="css/pactgraphs.css" />
-  <link rel="stylesheet" type="text/css" href="css/graph.css" />
-  <link rel="stylesheet" type="text/css" href="css/overlay.css" />
-  <link rel="stylesheet" type="text/css" href="css/bootstrap.css" /> <!-- Changed
Stuff -->
-  <script type="text/javascript" src="js/jquery-2.1.0.js"></script>
-  <script type="text/javascript" src="js/graphCreator.js"></script>
-  <script type="text/javascript" src="js/d3.js" charset="utf-8"></script>
-  <script type="text/javascript" src="js/dagre-d3.js"></script>
-  <script type="text/javascript" src="js/bootstrap.min.js"></script>
-  <script type="text/javascript" src="js/jquery.tools.min.js"></script>
-  
-  
-  <script type="text/javascript" src="js/program.js"></script>
-  
-</head>
-
-<body>
-    <div class="mainHeading" style="min-width: 1225px;">
-      <h1 style="margin-top:0"><img src="img/flink-logo.png" width="100" height="100"
alt="Flink Logo" />Flink Web Submission Client
-      <div style="position:absolute; top:40px; right:110px;">
-		  <button id="zoomIn" type="button" class="btn btn-default">Zoom In</button>
-		  <button id="zoomOut" type="button" class="btn btn-default">Zoom Out</button>
-		</div>
-      </h1>
-    </div>
-
-    <!-- the main panel with the jobs list and the preview pane -->
-    <div style="position: absolute; top: 110px; bottom: 210px; left: 0px; right: 0px;
min-width: 1225px;">
-      <div id="jobsContents" class="boxed" style="position: absolute; top: 0px; bottom:
0px; left: 0px; width: 450px; overflow: auto;"></div>
-      <div class="boxed" style="position: absolute; top: 0px; bottom: 0px; left: 460px;
right: 0px; overflow: auto;">
-        <div id="mainCanvas" class="canvas" style="position: relative; height: 100%"></div>
-      </div>
-    </div>
-
-    <!-- the footer containing the box with the run properties and the box with the upload
field -->
-    <div class="footer" style="min-width: 1225px;">
-    
-      <div class="boxed" style="float: left; width: 700px; height: 200px; position: relative;">
-        <h3>Select program...</h3>
-        <div style="margin-top: 30px;">
-          <div>
-          	<div id="planDescription"></div>
-          </div>
-          <div style="text-align: right;">
-            <span class="formLabel">Arguments:</span>
-            <input id="commandLineArgsField" type="text" name="commandLine" style="width:
580px;"/>
-          </div>
-          <div class="spaced" style="margin-left: 20px;">
-            <input type="checkbox" id="showPlanCheck" checked="checked"><span class="formLabel">Show
optimizer plan</span>
-            <div id="suspendOption"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input
type="checkbox" id="suspendJobDuringPlanCheck" checked="checked"><span class="formLabel">Suspend
execution while showing plan</span></div>
-          </div>
-        </div>
-        <div class="footer" style="text-align: right;">
-          <span id="run_error_text" class="error_text"></span>
-          <input id="run_button" type="button" value="Run Job" style="width: 75px; margin-left:
100px;"/>
-        </div>
-      </div>
-      
-      <div class="boxed" style="float: left; width: 500px; height: 150px; position: relative;">
-        <h3>Select a new program to upload...</h3>
-        <form id="upload_form" action="jobs" enctype="multipart/form-data" method="POST">
-          <div style="position: relative; margin-top: 30px;">
-             <input id="upload_file_name_text" type="text" name="file_name" disabled="disabled"
style="position: absolute; top: 0px; right: 85px; width: 380px; z-index: 3;"/>
-             <input type="button" value="Browse" style="width: 75px; position: absolute;
right: 0px; top: 0px; z-index: 1;" />
-             <input id="upload_file_input" class="translucent" type="file" name="upload_jar_file"
style="position: absolute; right: 0px; top: 0px; height: 30px; width=75px; z-index: 2;" />
-          </div>
-        </form>
-        <div class="footer" style="text-align: right;">
-          <span id="upload_error_text" class="error_text"></span>
-          <input id="upload_submit_button" type="button" value="Upload" style="width:
75px; margin-left: 100px;"/>
-        </div>
-      </div>
-      
-    </div>
-    
-    <!-- the overlay -->
-    <div class="simple_overlay" id="propertyO">
-	  <div id="propertyCanvas" class="propertyCanvas">
-	  </div>
-	</div>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/incubator-flink/blob/76d603c0/flink-clients/src/main/java/org/apache/flink/client/web/WebInterfaceServer.java
----------------------------------------------------------------------
diff --git a/flink-clients/src/main/java/org/apache/flink/client/web/WebInterfaceServer.java
b/flink-clients/src/main/java/org/apache/flink/client/web/WebInterfaceServer.java
index 92f60cd..1de21ff 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/web/WebInterfaceServer.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/web/WebInterfaceServer.java
@@ -22,6 +22,7 @@ package org.apache.flink.client.web;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.net.URL;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,6 +46,9 @@ import org.eclipse.jetty.servlet.ServletHolder;
  * configures an embedded jetty server.
  */
 public class WebInterfaceServer {
+
+	private static final String WEB_ROOT_DIR = "web-docs";
+
 	/**
 	 * The log for this class.
 	 */
@@ -81,20 +85,15 @@ public class WebInterfaceServer {
 		// get base path of Flink installation
 		String basePath = nepheleConfig.getString(ConfigConstants.FLINK_BASE_DIR_PATH_KEY,"");
 
-		File webDir;
 		File tmpDir;
 		File uploadDir;
 		File planDumpDir;
 		
-		String webDirPath = config.getString(ConfigConstants.WEB_ROOT_PATH_KEY,
-			ConfigConstants.DEFAULT_WEB_ROOT_DIR);
-		
-		if(webDirPath.startsWith("/")) {
-			// absolute path
-			webDir = new File(webDirPath);
-		} else {
-			// path relative to base dir
-			webDir = new File(basePath+"/"+webDirPath);
+		URL webRootDir = this.getClass().getClassLoader().getResource(WEB_ROOT_DIR);
+
+		if(webRootDir == null){
+			throw new FileNotFoundException("Cannot start web interface server because the web " +
+					"root dir " + WEB_ROOT_DIR + " is not included in the jar.");
 		}
 		
 		String tmpDirPath = config.getString(ConfigConstants.WEB_TMP_DIR_KEY,
@@ -131,7 +130,8 @@ public class WebInterfaceServer {
 		}
 		
 		if (LOG.isInfoEnabled()) {
-			LOG.info("Setting up web frontend server, using web-root directory '" + webDir.getAbsolutePath()
+ "'.");
+			LOG.info("Setting up web frontend server, using web-root directory '" +
+					webRootDir.toExternalForm()	+ "'.");
 			LOG.info("Web frontend server will store temporary files in '" + tmpDir.getAbsolutePath()
 				+ "', uploaded jobs in '" + uploadDir.getAbsolutePath() + "', plan-json-dumps in '"
 				+ planDumpDir.getAbsolutePath() + "'.");
@@ -144,12 +144,6 @@ public class WebInterfaceServer {
 
 		server = new Server(port);
 
-		// ensure that the directory with the web documents exists
-		if (!webDir.exists()) {
-			throw new FileNotFoundException("The directory containing the web documents does not exist:
"
-				+ webDir.getAbsolutePath());
-		}
-
 		// ensure, that all the directories exist
 		checkAndCreateDirectories(tmpDir, true);
 		checkAndCreateDirectories(uploadDir, true);
@@ -178,7 +172,7 @@ public class WebInterfaceServer {
 		// ----- the handler serving all the static files -----
 		ResourceHandler resourceHandler = new ResourceHandler();
 		resourceHandler.setDirectoriesListed(false);
-		resourceHandler.setResourceBase(webDir.getAbsolutePath());
+		resourceHandler.setResourceBase(webRootDir.toExternalForm());
 
 		// ----- add the handlers to the list handler -----
 		HandlerList handlers = new HandlerList();


Mime
View raw message