Author: degenaro
Date: Thu Feb 28 21:19:05 2013
New Revision: 1451356

URL: http://svn.apache.org/r1451356
Log:
UIMA-2676 DUCC webserver (WS) Services presentation improvements...display 
service's dependent jobs/services/reservation count and display list on 
(non-zero) hover

Added:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java
Modified:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.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

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java?rev=1451356&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/DuccDataHelper.java
 Thu Feb 28 21:19:05 2013
@@ -0,0 +1,159 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.TreeMap;
+import java.util.concurrent.ConcurrentSkipListMap;
+
+import org.apache.uima.ducc.common.utils.id.DuccId;
+import org.apache.uima.ducc.transport.event.common.DuccWorkJob;
+import 
org.apache.uima.ducc.transport.event.common.IDuccWorkService.ServiceDeploymentType;
+import org.apache.uima.ducc.ws.registry.IServicesRegistry;
+import org.apache.uima.ducc.ws.registry.ServicesRegistry;
+import org.apache.uima.ducc.ws.registry.ServicesRegistryMap;
+import org.apache.uima.ducc.ws.registry.ServicesRegistryMapPayload;
+
+public class DuccDataHelper {
+
+       private static DuccDataHelper duccDataHelper = new DuccDataHelper();
+       
+       public static DuccDataHelper getInstance() {
+               return duccDataHelper;
+       }
+       
+       public TreeMap<String,ArrayList<DuccId>> getServiceToJobsUsageMap() {
+               TreeMap<String,ArrayList<DuccId>> map = new 
TreeMap<String,ArrayList<DuccId>>();
+               DuccData duccData = DuccData.getInstance();
+               ConcurrentSkipListMap<JobInfo, JobInfo> jobs = 
duccData.getSortedJobs();
+               for(JobInfo jobInfo : jobs.descendingKeySet()) {
+                       DuccWorkJob job = jobInfo.getJob();
+                       if(job.isOperational()) {
+                               DuccId duccId = job.getDuccId();
+                               String[] dependencies = 
job.getServiceDependencies();
+                               if(dependencies != null) {
+                                       for(String dependency : dependencies) {
+                                               
if(!map.containsKey(dependency)) {
+                                                       map.put(dependency, new 
ArrayList<DuccId>());
+                                               }
+                                               ArrayList<DuccId> duccIds = 
map.get(dependency);
+                                               if(!duccIds.contains(duccId)) {
+                                                       duccIds.add(duccId);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return map;
+       }
+       
+       private String getServiceId(DuccId serviceId) {
+               String retVal = null;
+               ServicesRegistry servicesRegistry = new ServicesRegistry();
+               ServicesRegistryMap map = servicesRegistry.getMap();
+               for(Integer key : map.getDescendingKeySet()) {
+                       ServicesRegistryMapPayload payload = map.get(key);
+                       Properties meta = payload.meta;
+                       String implementors = 
meta.getProperty(IServicesRegistry.implementors);
+                       if(implementors != null) {
+                               String[] implementorsArray = 
implementors.trim().split(" ");
+                               for(String implementor : implementorsArray) {
+                                       
if(implementor.trim().equals(""+serviceId.getFriendly()));
+                                       retVal = 
meta.getProperty(IServicesRegistry.numeric_id);
+                                       break;
+                               }
+                       }
+               }
+               return retVal;
+       }
+       
+       public TreeMap<String,ArrayList<String>> getServiceToServicesUsageMap() 
{
+               TreeMap<String,ArrayList<String>> map = new 
TreeMap<String,ArrayList<String>>();
+               DuccData duccData = DuccData.getInstance();
+               ConcurrentSkipListMap<JobInfo, JobInfo> jobs = 
duccData.getSortedServices();
+               for(JobInfo jobInfo : jobs.descendingKeySet()) {
+                       DuccWorkJob service = jobInfo.getJob();
+                       if(service.isOperational()) {
+                               ServiceDeploymentType type = 
service.getServiceDeploymentType();
+                               if(type != null) {
+                                       switch(type) {
+                                       case uima:
+                                       case custom:
+                                               DuccId duccId = 
service.getDuccId();
+                                               String serviceId = 
getServiceId(duccId);
+                                               if(serviceId != null) {
+                                                       String[] dependencies = 
service.getServiceDependencies();
+                                                       if(dependencies != 
null) {
+                                                               for(String 
dependency : dependencies) {
+                                                                       
if(!map.containsKey(dependency)) {
+                                                                               
map.put(dependency, new ArrayList<String>());
+                                                                       }
+                                                                       
ArrayList<String> serviceIds = map.get(dependency);
+                                                                       
if(!serviceIds.contains(serviceId)) {
+                                                                               
serviceIds.add(serviceId);
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                               break;
+                                       default:
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               return map;
+       }
+       
+       public TreeMap<String,ArrayList<DuccId>> 
getServiceToReservationsUsageMap() {
+               TreeMap<String,ArrayList<DuccId>> map = new 
TreeMap<String,ArrayList<DuccId>>();
+               DuccData duccData = DuccData.getInstance();
+               ConcurrentSkipListMap<JobInfo, JobInfo> services = 
duccData.getSortedServices();
+               for(JobInfo jobInfo : services.descendingKeySet()) {
+                       DuccWorkJob service = jobInfo.getJob();
+                       if(service.isOperational()) {
+                               ServiceDeploymentType type = 
service.getServiceDeploymentType();
+                               if(type != null) {
+                                       switch(type) {
+                                       case other:
+                                               DuccId duccId = 
service.getDuccId();
+                                               String[] dependencies = 
service.getServiceDependencies();
+                                               if(dependencies != null) {
+                                                       for(String dependency : 
dependencies) {
+                                                               
if(!map.containsKey(dependency)) {
+                                                                       
map.put(dependency, new ArrayList<DuccId>());
+                                                               }
+                                                               
ArrayList<DuccId> duccIds = map.get(dependency);
+                                                               
if(!duccIds.contains(duccId)) {
+                                                                       
duccIds.add(duccId);
+                                                               }
+                                                       }
+                                               }
+                                               break;
+                                       default:
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               return map;
+       }
+
+}

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java?rev=1451356&r1=1451355&r2=1451356&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
 Thu Feb 28 21:19:05 2013
@@ -803,7 +803,7 @@ public abstract class DuccAbstractHandle
                        sb.append("0");
                        sb.append("</span>");
                }
-               else if(serviceDependencies.length == 0) {
+               else if(job.isCompleted()){
                        sb.append("<span class=\"health_neutral\" >");
                        sb.append(serviceDependencies.length);
                        sb.append("</span>");

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=1451356&r1=1451355&r2=1451356&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
 Thu Feb 28 21:19:05 2013
@@ -65,6 +65,7 @@ import org.apache.uima.ducc.transport.ev
 import org.apache.uima.ducc.transport.event.common.IRationale;
 import org.apache.uima.ducc.ws.DuccDaemonsData;
 import org.apache.uima.ducc.ws.DuccData;
+import org.apache.uima.ducc.ws.DuccDataHelper;
 import org.apache.uima.ducc.ws.DuccMachinesData;
 import org.apache.uima.ducc.ws.JobInfo;
 import org.apache.uima.ducc.ws.MachineInfo;
@@ -1068,7 +1069,12 @@ public class DuccHandlerJsonFormat exten
                
                JsonObject jsonResponse = new JsonObject();
                JsonArray data = new JsonArray();
-
+               
+               DuccDataHelper duccDataHelper = DuccDataHelper.getInstance();
+               TreeMap<String, ArrayList<DuccId>> serviceToJobsMap = 
duccDataHelper.getServiceToJobsUsageMap();
+               TreeMap<String, ArrayList<String>> serviceToServicesMap = 
duccDataHelper.getServiceToServicesUsageMap();
+               TreeMap<String, ArrayList<DuccId>> serviceToReservationsMap = 
duccDataHelper.getServiceToReservationsUsageMap();
+               
                ServicesRegistry servicesRegistry = new ServicesRegistry();
                
                IStateServices iss = StateServices.getInstance();
@@ -1169,6 +1175,60 @@ public class DuccHandlerJsonFormat exten
                                row.add(new 
JsonPrimitive(getValue(propertiesSvc,IStateServices.scheduling_class,"")));
                                // Size
                                row.add(new 
JsonPrimitive(getValue(propertiesSvc,IStateServices.process_memory_size,"")));
+                               // Jobs                 
+                               String jobs = "0";
+                               if(serviceToJobsMap.containsKey(name)) {
+                                       ArrayList<DuccId> duccIds = 
serviceToJobsMap.get(name);
+                                       int size = duccIds.size();
+                                       if(size > 0) {
+                                               StringBuffer idList = new 
StringBuffer();
+                                               for(DuccId duccId : duccIds) {
+                                                       if(idList.length() > 0) 
{
+                                                               
idList.append(",");
+                                                       }
+                                                       idList.append(duccId);
+                                               }
+                                               String title = "active Job Id 
list: "+idList;
+                                               jobs = "<span 
title=\""+title+"\">"+size+"</span>";
+                                       }
+                               }
+                               row.add(new JsonPrimitive(jobs));
+                               // Services
+                               String services = "0";
+                               if(serviceToServicesMap.containsKey(name)) {
+                                       ArrayList<String> duccIds = 
serviceToServicesMap.get(name);
+                                       int size = duccIds.size();
+                                       if(size > 0) {
+                                               StringBuffer idList = new 
StringBuffer();
+                                               for(String duccId : duccIds) {
+                                                       if(idList.length() > 0) 
{
+                                                               
idList.append(",");
+                                                       }
+                                                       idList.append(duccId);
+                                               }
+                                               String title = "active Service 
Id list: "+idList;
+                                               services = "<span 
title=\""+title+"\">"+size+"</span>";
+                                       }
+                               }
+                               row.add(new JsonPrimitive(services));
+                               // Reservations
+                               String reservations = "0";
+                               if(serviceToReservationsMap.containsKey(name)) {
+                                       ArrayList<DuccId> duccIds = 
serviceToReservationsMap.get(name);
+                                       int size = duccIds.size();
+                                       if(size > 0) {
+                                               StringBuffer idList = new 
StringBuffer();
+                                               for(DuccId duccId : duccIds) {
+                                                       if(idList.length() > 0) 
{
+                                                               
idList.append(",");
+                                                       }
+                                                       idList.append(duccId);
+                                               }
+                                               String title = "active 
Reservation Id list: "+idList;
+                                               reservations = "<span 
title=\""+title+"\">"+size+"</span>";
+                                       }
+                               }
+                               row.add(new JsonPrimitive(reservations));
                                // Description
                                StringBuffer sb = new StringBuffer();
                                String description = 
getValue(propertiesSvc,IStateServices.description,"");

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=1451356&r1=1451355&r2=1451356&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
 Thu Feb 28 21:19:05 2013
@@ -50,12 +50,13 @@ import org.apache.uima.ducc.transport.ev
 import org.apache.uima.ducc.transport.event.common.IDuccReservation;
 import org.apache.uima.ducc.transport.event.common.IDuccReservationMap;
 import org.apache.uima.ducc.transport.event.common.IDuccUnits.MemoryUnits;
-import 
org.apache.uima.ducc.transport.event.common.IDuccWorkService.ServiceDeploymentType;
 import org.apache.uima.ducc.transport.event.common.IDuccWork;
 import org.apache.uima.ducc.transport.event.common.IDuccWorkJob;
+import 
org.apache.uima.ducc.transport.event.common.IDuccWorkService.ServiceDeploymentType;
 import org.apache.uima.ducc.transport.event.common.IRationale;
 import org.apache.uima.ducc.ws.DuccDaemonsData;
 import org.apache.uima.ducc.ws.DuccData;
+import org.apache.uima.ducc.ws.DuccDataHelper;
 import org.apache.uima.ducc.ws.DuccMachinesData;
 import org.apache.uima.ducc.ws.JobInfo;
 import org.apache.uima.ducc.ws.MachineInfo;
@@ -918,6 +919,11 @@ public class DuccHandlerLegacy extends D
                duccLogger.trace(methodName, jobid, messages.fetch("enter"));
                StringBuffer sb = new StringBuffer();
                
+               DuccDataHelper duccDataHelper = DuccDataHelper.getInstance();
+               TreeMap<String, ArrayList<DuccId>> serviceToJobsMap = 
duccDataHelper.getServiceToJobsUsageMap();
+               TreeMap<String, ArrayList<String>> serviceToServicesMap = 
duccDataHelper.getServiceToServicesUsageMap();
+               TreeMap<String, ArrayList<DuccId>> serviceToReservationsMap = 
duccDataHelper.getServiceToReservationsUsageMap();
+               
                ServicesRegistry servicesRegistry = new ServicesRegistry();
                ServicesRegistryMap map = servicesRegistry.getMap();
                if(!map.isEmpty()) {
@@ -1022,6 +1028,66 @@ public class DuccHandlerLegacy extends D
                                sb.append("<td align=\"right\">");
                                
sb.append(getValue(propertiesSvc,IServicesRegistry.process_memory_size,""));
                                sb.append("</td>");
+                               // Jobs                 
+                               sb.append("<td align=\"right\">");
+                               String jobs = "0";
+                               if(serviceToJobsMap.containsKey(name)) {
+                                       ArrayList<DuccId> duccIds = 
serviceToJobsMap.get(name);
+                                       int size = duccIds.size();
+                                       if(size > 0) {
+                                               StringBuffer idList = new 
StringBuffer();
+                                               for(DuccId duccId : duccIds) {
+                                                       if(idList.length() > 0) 
{
+                                                               
idList.append(",");
+                                                       }
+                                                       idList.append(duccId);
+                                               }
+                                               String title = "active Job Id 
list: "+idList;
+                                               jobs = "<span 
title=\""+title+"\">"+size+"</span>";
+                                       }
+                               }
+                               sb.append(jobs);
+                               sb.append("</td>");
+                               // Services
+                               sb.append("<td align=\"right\">");
+                               String services = "0";
+                               if(serviceToServicesMap.containsKey(name)) {
+                                       ArrayList<String> duccIds = 
serviceToServicesMap.get(name);
+                                       int size = duccIds.size();
+                                       if(size > 0) {
+                                               StringBuffer idList = new 
StringBuffer();
+                                               for(String duccId : duccIds) {
+                                                       if(idList.length() > 0) 
{
+                                                               
idList.append(",");
+                                                       }
+                                                       idList.append(duccId);
+                                               }
+                                               String title = "active Service 
Id list: "+idList;
+                                               services = "<span 
title=\""+title+"\">"+size+"</span>";
+                                       }
+                               }
+                               sb.append(services);
+                               sb.append("</td>");
+                               // Reservations
+                               sb.append("<td align=\"right\">");
+                               String reservations = "0";
+                               if(serviceToReservationsMap.containsKey(name)) {
+                                       ArrayList<DuccId> duccIds = 
serviceToReservationsMap.get(name);
+                                       int size = duccIds.size();
+                                       if(size > 0) {
+                                               StringBuffer idList = new 
StringBuffer();
+                                               for(DuccId duccId : duccIds) {
+                                                       if(idList.length() > 0) 
{
+                                                               
idList.append(",");
+                                                       }
+                                                       idList.append(duccId);
+                                               }
+                                               String title = "active 
Reservation Id list: "+idList;
+                                               reservations = "<span 
title=\""+title+"\">"+size+"</span>";
+                                       }
+                               }
+                               sb.append(reservations);
+                               sb.append("</td>");
                                // Description
                                sb.append("<td>");
                                String description = 
getValue(propertiesSvc,IServicesRegistry.description,"");

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=1451356&r1=1451355&r2=1451356&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 
Thu Feb 28 21:19:05 2013
@@ -49,6 +49,9 @@ if (table_style.equals("scroll")) {
                                        $('td:eq(8)', nRow).css( "text-align", 
"right" );
                                        $('td:eq(9)', nRow).css( "text-align", 
"right" );
                                        $('td:eq(12)', nRow).css( "text-align", 
"right" );
+                                       $('td:eq(13)', nRow).css( "text-align", 
"right" );
+                                       $('td:eq(14)', nRow).css( "text-align", 
"right" );
+                                       $('td:eq(15)', nRow).css( "text-align", 
"right" );
                                        return nRow;
                        },
                } );
@@ -112,6 +115,9 @@ if (table_style.equals("scroll")) {
                <th class="ducc-no-filter" id="user_column_heading" title="The 
service owning user">User</th>
                <th title="The service scheduling class">Class</th>
                <th title="The service process memory size (GB)">Size</th>
+               <th title="The number of active Jobs that depend on this 
service">Jobs</th>
+               <th title="The number of active Services that depend on this 
service">Ser-<br>vices</th>
+               <th title="The number of active Reservations that depend on 
this service">Reser-<br>vations</th>
                <th title="The service description">Description</th>
        </tr>
        </thead>
@@ -144,6 +150,9 @@ if (table_style.equals("classic")) {
                <th class="ducc-no-filter" id="user_column_heading" title="The 
service owning user">User</th>
                <th title="The service scheduling class">Class</th>
                <th title="The service process memory size (GB)">Size</th>
+               <th title="The number of active Jobs that depend on this 
service">Jobs</th>
+               <th title="The number of active Services that depend on this 
service">Ser-<br>vices</th>
+               <th title="The number of active Reservations that depend on 
this service">Reser-<br>vations</th>
                <th title="The service description">Description</th>
                </tr>
                </thead>


Reply via email to