You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by bu...@apache.org on 2016/11/17 20:21:08 UTC
svn commit: r1770275 - in /uima/uima-ducc/trunk/uima-ducc-web/src/main:
java/org/apache/uima/ducc/ws/server/ java/org/apache/uima/ducc/ws/utils/
webapp/root/ webapp/root/js/
Author: burn
Date: Thu Nov 17 20:21:07 2016
New Revision: 1770275
URL: http://svn.apache.org/viewvc?rev=1770275&view=rev
Log:
UIMA-5182 Make service registry page similar to the Job & AP ones; format and show/hide some large values
Modified:
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/HandlersHelper.java
uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js
uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/service.details.table.registry.jsp
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java?rev=1770275&r1=1770274&r2=1770275&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java Thu Nov 17 20:21:07 2016
@@ -983,28 +983,29 @@ public abstract class DuccAbstractHandle
return sb.toString();
}
- public String formatClasspath(String classpath) {
- String retVal = classpath;
- if(classpath != null) {
- String[] cpList = classpath.split(":");
- if(cpList != null) {
- StringBuffer vb = new StringBuffer();
- vb.append("<br>");
- vb.append("<div>");
- StringBuffer sb = new StringBuffer();
- for(String item : cpList) {
- if(sb.length() > 0) {
- sb.append("<br>");
- }
- sb.append(item);
- }
- vb.append(sb);
- vb.append("</div>");
- retVal = vb.toString();
- }
- }
- return retVal;
- }
+ /*
+ * Format the value of a possibly long string that may contain a classpath
+ * Put space-delimited tokens and the elements of a classpath on separate lines,
+ */
+ public String formatValue(String value, boolean formatCp) {
+ String[] tokens = value.split(" +");
+ StringBuffer sb = new StringBuffer();
+ sb.append("<div>");
+ for (String item : tokens) {
+ if (formatCp) {
+ item = item.replace(":", ":<br>");
+ //sb.append(item.replace(":", ":<br>")).append("<br>");
+ formatCp = false;
+ } //else {
+ sb.append(item).append("<br>");
+ if (item.equals("-cp") || item.equals("-classpath")) {
+ formatCp = true;
+ }
+ //}
+ }
+ sb.append("</div>");
+ return sb.toString();
+ }
protected String getMonitor(DuccId duccId, MonitorType monitorType) {
return getMonitor(duccId, monitorType, false);
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java?rev=1770275&r1=1770274&r2=1770275&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java Thu Nov 17 20:21:07 2016
@@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
-import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -137,7 +136,9 @@ public class DuccHandler extends DuccAbs
private static Messages messages = Messages.getInstance();
private static DuccId jobid = null;
- private final String[] n = {"classpath", "process_executable_args"};
+ // These keys may have large values and be displayed witg Show/Hide buttons.
+ // ducc.js must be updated if more than 4 are needed (services may have 4)
+ private final String[] n = {"classpath", "service_ping_classpath", "process_executable_args", "process_jvm_args", "environment"};
private final Set<String> hideableKeys = new HashSet<String>(Arrays.asList(n));
private enum DetailsType { Job, Reservation, Service };
@@ -216,8 +217,6 @@ public class DuccHandler extends DuccAbs
private String duccReservationSchedulingClasses = duccContext+"/reservation-scheduling-classes";
private String duccReservationInstanceMemoryUnits = duccContext+"/reservation-memory-units";
- protected String headProvider = "Provider";
-
protected String providerUser = "user";
protected String providerFile = "file";
protected String providerSystem = "";
@@ -2027,10 +2026,6 @@ public class DuccHandler extends DuccAbs
duccLogger.trace(methodName, null, messages.fetch("exit"));
}
- private void putJobSpecEntry(Properties properties, String key, String value, StringBuffer sb, int counter) {
- putJobSpecEntry(properties, providerUnknown, key, value, sb, counter);
- }
-
private void putJobSpecEntry(Properties properties, String provider, String key, String value, StringBuffer sb, int counter) {
if(value != null) {
sb.append(trGet(counter));
@@ -2048,77 +2043,78 @@ public class DuccHandler extends DuccAbs
}
}
- private boolean isProvided(Properties usProperties, Properties fsProperties) {
- if(usProperties != null) {
- return true;
- }
- if(fsProperties != null) {
- return true;
- }
- return false;
- }
-
- private String getProvider(String key, Properties usProperties, Properties fsProperties) {
- if(isProvided(usProperties, fsProperties)) {
- if(usProperties != null) {
- if(usProperties.containsKey(key)) {
- return providerUser;
- }
- }
- if(fsProperties != null) {
- if(fsProperties.containsKey(key)) {
- return providerFile;
- }
- }
- return providerSystem;
- }
- else {
- return providerUnknown;
- }
- }
-
- /*
- * Format both job & reservation specification files
+ /**
+ * Format job & reservation & service specification files
+ *
+ * @param request - servlet request
+ * @param response - generated response
+ * @param usProperties - properties specified by the user
+ * @param properties - meta properties (for services), or user + default properties (for jobs & APs)
+ * @param buttonHint - for services says how to enable modification of autostart and instances values
+ * @throws IOException
*/
- private void processSpecificationData(DuccWorkJob work, String specFile, HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ private void processSpecificationData(HttpServletRequest request, HttpServletResponse response,
+ Properties usProperties, Properties properties, String buttonHint) throws IOException {
String methodName = "ProcessSpecificationData";
StringBuffer sb = new StringBuffer();
- if (work != null) {
- try {
- EffectiveUser eu = EffectiveUser.create(request);
- Properties usProperties = DuccFile.getUserSpecifiedProperties(eu, work);
- String path = work.getUserLogsDir() + work.getDuccId().getFriendly() + File.separator + specFile;
- Properties properties = DuccFile.getProperties(eu, path);
- if (properties == null) {
- sb.append(eu.isLoggedin() ? "(data missing or unreadable)" : "(not visible - try logging in)");
- } else {
- int i = 0;
- int counter = 0;
- // Process a sorted list of property names
- TreeSet<String> list = new TreeSet<String>(properties.stringPropertyNames());
- for (String key : list) {
- String value = properties.getProperty(key);
- String provider = getProvider(key, usProperties, null);
- if (hideableKeys.contains(key)) {
- if (key.equals("classpath")) {
- value = formatClasspath(value);
- } // Could try to format the cp part of the executable args?
- String show = "<div class=\"hidedata\"><input type=\"submit\" name=\"showcp\" value=\"Show\" id=\"showbutton"
- + i + "\"/></div>";
- String hide = "<div class=\"showdata\"><input type=\"submit\" name=\"hidecp\" value=\"Hide\" id=\"hidebutton"
- + i + "\"/>" + " " + value + "</div>";
- value = show + hide;
- i++;
- }
- putJobSpecEntry(properties, provider, key, value, sb, counter++);
- }
+ // Create a sorted list of all properties
+ TreeSet<String> list = new TreeSet<String>(properties.stringPropertyNames());
+ if (buttonHint != null) {
+ list.addAll(usProperties.stringPropertyNames()); // Include the service user values as well as the meta ones
+ // Move autostart to the user properties where it should have been all along
+ if (!usProperties.contains("autostart")) {
+ usProperties.put("autostart", properties.remove("autostart"));
+ }
+ }
+ int i = 0;
+ int counter = 0;
+ for (String key : list) {
+ // Determine the origin of the property, User vs. default or meta
+ String provider = "User";
+ String value = usProperties.getProperty(key);
+ if (value == null) {
+ value = properties.getProperty(key);
+ provider = "";
+ }
+ // Format certain values that can be long and attach a Hide/Show button if would span many lines
+ if (hideableKeys.contains(key)) {
+ value = formatValue(value, key.endsWith("classpath"));
+ if (value.length() > 500) {
+ String show = "<div class=\"hidedata" + i + "\"><input type=\"submit\" name=\"showcp" + i
+ + "\" value=\"Show\" id=\"showbutton" + i + "\"/></div>";
+ String hide = "<div class=\"showdata" + i + "\"><input type=\"submit\" name=\"hidecp" + i
+ + "\" value=\"Hide\" id=\"hidebutton" + i + "\"/>" + " " + value + "</div>";
+ value = show + hide;
+ i++;
+ }
+ }
+ // Add a button for modifying the autostart value
+ if (key.equalsIgnoreCase(IServicesRegistry.autostart)) {
+ if (value != null) {
+ value = value.trim();
+ String eulav = value.equals("true") ? "false" : "true"; // Reverse value
+ StringBuffer replacement = new StringBuffer();
+ replacement.append("<select id=\"autostart\"" + buttonHint + ">");
+ replacement.append("<option value=\"" + value + "\" selected=\"selected\">" + value + "</option>");
+ replacement.append("<option value=\"" + eulav + "\" >" + eulav + "</option>");
+ replacement.append("</select>");
+ value = replacement.toString();
+ }
+ }
+ // Add a button for modifying the instances value
+ if (key.equalsIgnoreCase(IServicesRegistry.instances)) {
+ if (value != null) {
+ value = value.trim();
+ StringBuffer replacement = new StringBuffer();
+ replacement.append("<span id=\"instances_area\">");
+ replacement.append("<input type=\"text\" size=\"5\" id=\"instances\" value=\"" + value + "\"" + buttonHint + ">");
+ replacement.append("</span>");
+ value = replacement.toString();
}
- } catch (Throwable t) {
- duccLogger.warn(methodName, null, t);
- sb.append("no accessible data (" + t + ")");
}
+ putJobSpecEntry(properties, provider, key, value, sb, counter++);
}
+
response.getWriter().println(sb);
duccLogger.trace(methodName, null, messages.fetch("exit"));
}
@@ -2129,8 +2125,19 @@ public class DuccHandler extends DuccAbs
String methodName = "handleDuccServletJobSpecificationData";
duccLogger.trace(methodName, null, messages.fetch("enter"));
String jobNo = request.getParameter("id");
- DuccWorkJob job = getJob(jobNo);
- processSpecificationData(job, DuccUiConstants.job_specification_properties, request, response);
+ DuccWorkJob work = getJob(jobNo);
+ EffectiveUser eu = EffectiveUser.create(request);
+ String path = work.getUserLogsDir() + work.getDuccId().getFriendly() + File.separator
+ + DuccUiConstants.job_specification_properties;
+ Properties usProperties;
+ Properties properties;
+ try {
+ usProperties = DuccFile.getUserSpecifiedProperties(eu, work);
+ properties = DuccFile.getProperties(eu, path);
+ } catch (Throwable e) {
+ throw new IOException(e);
+ }
+ processSpecificationData(request, response, usProperties, properties, null);
duccLogger.trace(methodName, null, messages.fetch("exit"));
}
@@ -2631,8 +2638,19 @@ public class DuccHandler extends DuccAbs
String methodName = "handleDuccServletReservationSpecificationData";
duccLogger.trace(methodName, null, messages.fetch("enter"));
String reservationNo = request.getParameter("id");
- DuccWorkJob managedReservation = getManagedReservation(reservationNo);
- processSpecificationData(managedReservation, DuccUiConstants.managed_reservation_properties, request, response);
+ DuccWorkJob work = getManagedReservation(reservationNo);
+
+ EffectiveUser eu = EffectiveUser.create(request);
+ String path = work.getUserLogsDir() + work.getDuccId().getFriendly() + File.separator + DuccUiConstants.managed_reservation_properties;
+ Properties usProperties;
+ Properties properties;
+ try {
+ usProperties = DuccFile.getUserSpecifiedProperties(eu, work);
+ properties = DuccFile.getProperties(eu, path);
+ } catch (Throwable e) {
+ throw new IOException(e);
+ }
+ processSpecificationData(request, response, usProperties, properties, null);
duccLogger.trace(methodName, null, messages.fetch("exit"));
}
@@ -2792,92 +2810,10 @@ public class DuccHandler extends DuccAbs
}
}
}
- String prefix;
- TreeMap<String,String> map;
- Enumeration<?> enumeration;
- Iterator<String> iterator;
- int i = 0;
- int counter = 0;
- //
- prefix = "svc.";
- properties = payload.svc;
- map = new TreeMap<String,String>();
- enumeration = properties.keys();
- while(enumeration.hasMoreElements()) {
- String key = (String)enumeration.nextElement();
- map.put(key, key);
- }
- iterator = map.keySet().iterator();
- while(iterator.hasNext()) {
- String key = iterator.next();
- String value = properties.getProperty(key);
- if(key.endsWith("classpath")) {
- value = formatClasspath(value);
- String show = "<div class=\"hidedata\"><input type=\"submit\" name=\"showcp\" value=\"Show\" id=\"showbutton"+i+"\"/></div>";
- String hide = "<div class=\"showdata\"><input type=\"submit\" name=\"hidecp\" value=\"Hide\" id=\"hidebutton"+i+"\"/>"+" "+value+"</div>";
- value = show+hide;
- i++;
- }
- putJobSpecEntry(properties, prefix+key, value, sb, counter++);
- }
- //
- prefix = "meta.";
- properties = payload.meta;
- map = new TreeMap<String,String>();
- enumeration = properties.keys();
- while(enumeration.hasMoreElements()) {
- String key = (String)enumeration.nextElement();
- map.put(key, key);
- }
- iterator = map.keySet().iterator();
- while(iterator.hasNext()) {
- String key = iterator.next();
- String value = properties.getProperty(key);
- if(key.endsWith("classpath")) {
- value = formatClasspath(value);
- String show = "<div class=\"hidedata\"><input type=\"submit\" name=\"showcp\" value=\"Show\" id=\"showbutton"+i+"\"/></div>";
- String hide = "<div class=\"showdata\"><input type=\"submit\" name=\"hidecp\" value=\"Hide\" id=\"hidebutton"+i+"\"/>"+" "+value+"</div>";
- value = show+hide;
- i++;
- }
- key = key.trim();
- // autostart
- if(key.equalsIgnoreCase(IServicesRegistry.autostart)) {
- if(value != null) {
- value = value.trim();
- if(value.equalsIgnoreCase(IServicesRegistry.constant_true)) {
- StringBuffer replacement = new StringBuffer();
- replacement.append("<select id=\"autostart\""+enable_or_disable+" "+hint+">");
- replacement.append("<option value=\"true\" selected=\"selected\">true</option>");
- replacement.append("<option value=\"false\" >false</option>");
- replacement.append("</select>");
- value = replacement.toString();
- }
- else if(value.equalsIgnoreCase(IServicesRegistry.constant_false)) {
- StringBuffer replacement = new StringBuffer();
- replacement.append("<select id=\"autostart\""+enable_or_disable+" "+hint+">");
- replacement.append("<option value=\"false\" selected=\"selected\">false</option>");
- replacement.append("<option value=\"true\" >true</option>");
- replacement.append("</select>");
- value = replacement.toString();
- }
- }
- }
- // instances
- if(key.equalsIgnoreCase(IServicesRegistry.instances)) {
- if(value != null) {
- value = value.trim();
- StringBuffer replacement = new StringBuffer();
- replacement.append("<span id=\"instances_area\">");
- replacement.append("<input type=\"text\" size=\"5\" id=\"instances\" value=\""+value+"\""+enable_or_disable+" "+hint+">");
- replacement.append("</span>");
- value = replacement.toString();
- }
- }
- putJobSpecEntry(properties, prefix+key, value, sb, counter++);
- }
- }
- else {
+ hint = enable_or_disable + " " + hint;
+ processSpecificationData(request, response, payload.svc, payload.meta, hint);
+
+ } else {
sb.append("<tr>");
sb.append("<td>");
sb.append("not found");
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/HandlersHelper.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/HandlersHelper.java?rev=1770275&r1=1770274&r2=1770275&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/HandlersHelper.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/HandlersHelper.java Thu Nov 17 20:21:07 2016
@@ -213,7 +213,6 @@ public class HandlersHelper {
if(reqUser != null) {
retVal = DuccWebAdministrators.getInstance().isAdministrator(reqUser);
if(retVal) {
- retVal = false; // force DUCC administrator not permitted
duccLogger.debug(location, getDuccId(meta), "user="+reqUser+" "+retVal+" "+"(forced)");
}
}
@@ -261,7 +260,7 @@ public class HandlersHelper {
home = home+File.separator;
}
String path = home+".ducc"+File.separator+"db.access";
- retVal = isFileReadable(svcOwner, path);
+ retVal = isFileReadable(reqUser, path);
if(retVal) {
duccLogger.debug(location, getDuccId(meta), "user="+reqUser+" "+retVal);
}
@@ -330,10 +329,10 @@ public class HandlersHelper {
else if(isServiceAdministrator(reqUser, svc)) {
retVal = ServiceAuthorization.Write;
}
- // write access for ducc administrator
- else if(isDuccAdministrator(reqUser, meta)) {
- retVal = ServiceAuthorization.Write;
- }
+ // Don't permit write access for ducc administrator
+ //else if(isDuccAdministrator(reqUser, meta)) {
+ // retVal = ServiceAuthorization.Write;
+ //}
// read access only if user can read db.access file
else if(isServiceFileAccessForRead(reqUser, meta)) {
retVal = ServiceAuthorization.Read;
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js?rev=1770275&r1=1770274&r2=1770275&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js Thu Nov 17 20:21:07 2016
@@ -1548,47 +1548,53 @@ function ducc_load_service_history_data(
}
}
-function hide_show() {
- var fname = "hide_show";
+// Show or hide one of the buttons on a specification page
+// Set the initial value from a cookie and define the toggle functions
+
+function hide_show_button(index) {
+ var fname = "hide_show_button";
try {
- var classpathdata = ducc_appl("classpathdata");
- var c_value = ducc_get_cookie(classpathdata);
+ var buttondata = ducc_appl("showhidebutton"+index);
+ var c_value = ducc_get_cookie(buttondata);
if (c_value == null) {
c_value = "hide";
}
if (c_value == "hide") {
- $('div.showdata').hide();
- $('div.hidedata').show();
+ $('div.showdata'+index).hide();
+ $('div.hidedata'+index).show();
}
if (c_value == "show") {
- $('div.showdata').show();
- $('div.hidedata').hide();
+ $('div.showdata'+index).show();
+ $('div.hidedata'+index).hide();
}
- $('#showbutton0').click(function() {
- $('div.showdata').show();
- $('div.hidedata').hide();
- ducc_put_cookie(classpathdata, "show")
- });
- $('#hidebutton0').click(function() {
- $('div.showdata').hide();
- $('div.hidedata').show();
- ducc_put_cookie(classpathdata, "hide")
+ $('#showbutton'+index).click(function() {
+ $('div.showdata'+index).show();
+ $('div.hidedata'+index).hide();
+ ducc_put_cookie(buttondata, "show")
});
- $('#showbutton1').click(function() {
- $('div.showdata').show();
- $('div.hidedata').hide();
- ducc_put_cookie(classpathdata, "show")
- });
- $('#hidebutton1').click(function() {
- $('div.showdata').hide();
- $('div.hidedata').show();
- ducc_put_cookie(classpathdata, "hide")
+ $('#hidebutton'+index).click(function() {
+ $('div.showdata'+index).hide();
+ $('div.hidedata'+index).show();
+ ducc_put_cookie(buttondata, "hide")
});
} catch (err) {
ducc_error(fname, err);
}
}
+// Define the show/hide functions for the (possibly) 4 buttons on a specification page
+function hide_show() {
+ var fname = "hide_show";
+ try {
+ hide_show_button(0);
+ hide_show_button(1);
+ hide_show_button(2);
+ hide_show_button(3);
+ } catch (err) {
+ ducc_error(fname, err);
+ }
+}
+
var ms_load_job_processes_data = +new Date() - ms_reload_min;
var wip_job_processes_data = false;
@@ -4043,4 +4049,4 @@ function ducc_preferences() {
} catch (err) {
ducc_error(fname, err);
}
-}
\ No newline at end of file
+}
Modified: uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/service.details.table.registry.jsp
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/service.details.table.registry.jsp?rev=1770275&r1=1770274&r2=1770275&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/service.details.table.registry.jsp (original)
+++ uima/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/service.details.table.registry.jsp Thu Nov 17 20:21:07 2016
@@ -26,6 +26,7 @@ under the License.
<table class="sortable">
<thead>
<tr class="ducc-head">
+ <th class="none" title="the registry variable source">Provider</th>
<th class="none" title="the registry variable name">Key</th>
<th class="none" title="the registry variable value">Value</th>
</tr>
@@ -33,4 +34,4 @@ under the License.
<tbody id="registry_data_area">
</tbody>
</table>
-</table>
\ No newline at end of file
+</table>