You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2013/02/23 12:53:57 UTC
svn commit: r1449303 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main:
java/org/apache/uima/ducc/ws/registry/ java/org/apache/uima/ducc/ws/server/
webapp/root/
Author: degenaro
Date: Sat Feb 23 11:53:57 2013
New Revision: 1449303
URL: http://svn.apache.org/r1449303
Log:
UIMA-2676 DUCC webserver (WS) Services presentation improvements...revise Pinging (Yes/No) and Health (Good/Poor)
Added:
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerUtils.java
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/IServicesRegistry.java
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/services.jsp
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/IServicesRegistry.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/IServicesRegistry.java?rev=1449303&r1=1449302&r2=1449303&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/IServicesRegistry.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/IServicesRegistry.java Sat Feb 23 11:53:57 2013
@@ -33,6 +33,7 @@ public class IServicesRegistry {
public static final String numeric_id = IStateServices.numeric_id;
public static final String ping_active = IStateServices.ping_active;
public static final String service_class = IStateServices.service_class;
+ public static final String service_healthy = IStateServices.service_healthy;
public static final String service_state = IStateServices.service_state;
public static final String user = IStateServices.user;
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java?rev=1449303&r1=1449302&r2=1449303&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java Sat Feb 23 11:53:57 2013
@@ -1082,46 +1082,16 @@ public class DuccHandlerJsonFormat exten
// Type
row.add(new JsonPrimitive(type));
// State
- String state = "";
- if(propertiesMeta != null) {
- if(propertiesMeta.containsKey(IServicesRegistry.service_state)) {
- String value = propertiesMeta.getProperty(IServicesRegistry.service_state);
- if(value != null) {
- state = value;
- }
- }
- }
+ String state = DuccHandlerUtils.getUninterpreted(propertiesMeta, IServicesRegistry.service_state);
row.add(new JsonPrimitive(state));
- // Health
- String health = "";
- if(propertiesMeta != null) {
- if(propertiesMeta.containsKey(IServicesRegistry.ping_active)) {
- String value = propertiesMeta.getProperty(IServicesRegistry.ping_active);
- String text = "";
- if(value != null) {
- value = value.trim();
- if(value.equals("true")) {
- StringBuffer sb = new StringBuffer();
- value = "up";
- text = "pinging";
- sb.append("<span class=\"health_green\" title=\""+text+"\">");
- sb.append(value);
- sb.append("</span>");
- health = sb.toString();
- }
- else {
- StringBuffer sb = new StringBuffer();
- value = "down";
- text = "not pinging";
- sb.append("<span class=\"health_red\" title=\""+text+"\">");
- sb.append(value);
- sb.append("</span>");
- health = sb.toString();
- }
- }
- }
- }
- row.add(new JsonPrimitive(health));
+ // Pinging
+ String pinging = DuccHandlerUtils.getInterpretedYesNo(state, propertiesMeta, IServicesRegistry.ping_active);
+ String decoratedPinging = DuccHandlerUtils.getDecorated(pinging);
+ row.add(new JsonPrimitive(decoratedPinging));
+ // Healthy
+ String healthy = DuccHandlerUtils.getInterpretedGoodPoor(state, propertiesMeta, IServicesRegistry.service_healthy);
+ String decoratedHealthy = DuccHandlerUtils.getDecorated(healthy);
+ row.add(new JsonPrimitive(decoratedHealthy));
// Instances
row.add(new JsonPrimitive(instances));
// Deployments
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java?rev=1449303&r1=1449302&r2=1449303&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java Sat Feb 23 11:53:57 2013
@@ -930,48 +930,20 @@ public class DuccHandlerLegacy extends D
sb.append("</td>");
// State
sb.append("<td>");
- String state = "";
- if(propertiesMeta != null) {
- if(propertiesMeta.containsKey(IServicesRegistry.service_state)) {
- String value = propertiesMeta.getProperty(IServicesRegistry.service_state);
- if(value != null) {
- state = value;
- }
- }
- }
+ String state = DuccHandlerUtils.getUninterpreted(propertiesMeta, IServicesRegistry.service_state);
sb.append(state);
sb.append("</td>");
- // Health
+ // Pinging
sb.append("<td>");
- String health = "";
- if(propertiesMeta != null) {
- if(propertiesMeta.containsKey(IServicesRegistry.ping_active)) {
- String value = propertiesMeta.getProperty(IServicesRegistry.ping_active);
- String text = "";
- if(value != null) {
- value = value.trim();
- if(value.equals("true")) {
- StringBuffer tbuf = new StringBuffer();
- value = "up";
- text = "pinging";
- tbuf.append("<span class=\"health_green\" title=\""+text+"\">");
- tbuf.append(value);
- tbuf.append("</span>");
- health = tbuf.toString();
- }
- else {
- StringBuffer tbuf = new StringBuffer();
- value = "down";
- text = "not pinging";
- tbuf.append("<span class=\"health_red\" title=\""+text+"\">");
- tbuf.append(value);
- tbuf.append("</span>");
- health = tbuf.toString();
- }
- }
- }
- }
- sb.append(health);
+ String pinging = DuccHandlerUtils.getInterpretedYesNo(state, propertiesMeta, IServicesRegistry.ping_active);
+ String decoratedPinging = DuccHandlerUtils.getDecorated(pinging);
+ sb.append(decoratedPinging);
+ sb.append("</td>");
+ // Healthy
+ sb.append("<td>");
+ String healthy = DuccHandlerUtils.getInterpretedGoodPoor(state, propertiesMeta, IServicesRegistry.service_healthy);
+ String decoratedHealthy = DuccHandlerUtils.getDecorated(healthy);
+ sb.append(decoratedHealthy);
sb.append("</td>");
// No. of Instances
sb.append("<td align=\"right\">");
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerUtils.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerUtils.java?rev=1449303&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerUtils.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerUtils.java Sat Feb 23 11:53:57 2013
@@ -0,0 +1,135 @@
+/*
+ * 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.uima.ducc.ws.server;
+
+import java.util.Properties;
+
+public class DuccHandlerUtils {
+
+ private static String stateAvailable = "Available";
+
+ private static String valueTrue = "True";
+ private static String valueFalse = "False";
+
+ private static String valueYes = "Yes";
+ private static String valueNo = "No";
+
+
+ private static String valueGood = "Good";
+ private static String valuePoor = "Poor";
+
+ private static String decorateOpenNeutral = "<span class=\"health_neutral\">";
+ private static String decorateOpenGreen = "<span class=\"health_green\">";
+ private static String decorateOpenRed = "<span class=\"health_red\">";
+ private static String decorateClose = "</span>";
+
+ public static String getUninterpreted(Properties propertiesMeta, String key) {
+ String retVal = "";
+ if(propertiesMeta != null) {
+ if(key != null) {
+ if(propertiesMeta.containsKey(key)) {
+ String value = propertiesMeta.getProperty(key);
+ if(value != null) {
+ retVal = value.trim();
+ }
+ }
+ }
+ }
+ return retVal;
+ }
+
+ public static String getInterpretedYesNo(String state, Properties propertiesMeta, String key) {
+ String retVal = "";
+ if(state != null) {
+ if(state.equals(stateAvailable)) {
+ String value = getUninterpreted(propertiesMeta, key);
+ value = value.trim();
+ if(value.equalsIgnoreCase(valueTrue)) {
+ retVal = valueYes;
+ }
+ else if(value.equalsIgnoreCase(valueFalse)) {
+ retVal = valueNo;
+ }
+ else {
+ retVal = value;
+ }
+ }
+ }
+ return retVal;
+ }
+
+ public static String getInterpretedGoodPoor(String state, Properties propertiesMeta, String key) {
+ String retVal = "";
+ if(state != null) {
+ if(state.equals(stateAvailable)) {
+ String value = getUninterpreted(propertiesMeta, key);
+ value = value.trim();
+ if(value.equalsIgnoreCase(valueTrue)) {
+ retVal = valueGood;
+ }
+ else if(value.equalsIgnoreCase(valueFalse)) {
+ retVal = valuePoor;
+ }
+ else {
+ retVal = value;
+ }
+ }
+ }
+ return retVal;
+ }
+
+ public static String getDecorated(String value) {
+ String retVal = "";
+ if(value != null) {
+ if(value.equalsIgnoreCase(valueYes)) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(decorateOpenNeutral);
+ sb.append(value);
+ sb.append(decorateClose);
+ retVal = sb.toString();
+ }
+ else if(value.equalsIgnoreCase(valueNo)) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(decorateOpenRed);
+ sb.append(value);
+ sb.append(decorateClose);
+ retVal = sb.toString();
+ }
+ else if(value.equalsIgnoreCase(valueGood)) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(decorateOpenGreen);
+ sb.append(value);
+ sb.append(decorateClose);
+ retVal = sb.toString();
+ }
+ else if(value.equalsIgnoreCase(valuePoor)) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(decorateOpenRed);
+ sb.append(value);
+ sb.append(decorateClose);
+ retVal = sb.toString();
+ }
+ else {
+ retVal = value;
+ }
+ }
+ return retVal;
+ }
+
+}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/services.jsp
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/services.jsp?rev=1449303&r1=1449302&r2=1449303&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/services.jsp (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/services.jsp Sat Feb 23 11:53:57 2013
@@ -46,9 +46,9 @@ if (table_style.equals("scroll")) {
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 1 ] } ],
"fnRowCallback" : function(nRow,aData,iDisplayIndex) {
$('td:eq(2)', nRow).css( "text-align", "right" );
- $('td:eq(7)', nRow).css( "text-align", "right" );
$('td:eq(8)', nRow).css( "text-align", "right" );
- $('td:eq(11)', nRow).css( "text-align", "right" );
+ $('td:eq(9)', nRow).css( "text-align", "right" );
+ $('td:eq(12)', nRow).css( "text-align", "right" );
return nRow;
},
} );
@@ -105,6 +105,7 @@ if (table_style.equals("scroll")) {
<th title="The service name">Name</th>
<th title="The service type">Type</th>
<th title="The service state">State</th>
+ <th title="The service pinger">Pinging</th>
<th title="The service health">Health</th>
<th title="The service number of instances">Instances</th>
<th title="The service number of deployments">Deployments</th>
@@ -136,6 +137,7 @@ if (table_style.equals("classic")) {
<th title="The service name">Name</th>
<th title="The service type">Type</th>
<th title="The service state">State</th>
+ <th title="The service pinger">Pinging</th>
<th title="The service health">Health</th>
<th title="The service number of instances">Instances</th>
<th title="The service number of deployments">Deployments</th>