incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1489460 - in /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs: JobManagerImpl.java TopologyCapabilities.java console/WebConsolePlugin.java
Date Tue, 04 Jun 2013 14:36:17 GMT
Author: cziegeler
Date: Tue Jun  4 14:36:12 2013
New Revision: 1489460

URL: http://svn.apache.org/r1489460
Log:
Add topology information to web console

Modified:
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/TopologyCapabilities.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java?rev=1489460&r1=1489459&r2=1489460&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
Tue Jun  4 14:36:12 2013
@@ -1308,4 +1308,8 @@ public class JobManagerImpl
             this.maintenanceTask.reassignJob(handler.getJob(), targetId);
         }
     }
+
+    public TopologyCapabilities getTopologyCapabilities() {
+        return this.topologyCapabilities;
+    }
 }

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/TopologyCapabilities.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/TopologyCapabilities.java?rev=1489460&r1=1489459&r2=1489460&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/TopologyCapabilities.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/TopologyCapabilities.java
Tue Jun  4 14:36:12 2013
@@ -258,4 +258,8 @@ public class TopologyCapabilities {
 
         return null;
     }
+
+    public Map<String, List<InstanceDescription>> getInstanceCapabilities() {
+        return this.instanceCapabilities;
+    }
 }

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java?rev=1489460&r1=1489459&r2=1489460&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java
Tue Jun  4 14:36:12 2013
@@ -26,6 +26,8 @@ import java.util.Arrays;
 import java.util.Date;
 import java.util.Dictionary;
 import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -37,7 +39,10 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.discovery.InstanceDescription;
 import org.apache.sling.event.impl.jobs.JobConsumerManager;
+import org.apache.sling.event.impl.jobs.JobManagerImpl;
+import org.apache.sling.event.impl.jobs.TopologyCapabilities;
 import org.apache.sling.event.impl.jobs.config.InternalQueueConfiguration;
 import org.apache.sling.event.impl.jobs.config.QueueConfigurationManager;
 import org.apache.sling.event.jobs.JobManager;
@@ -238,6 +243,31 @@ public class WebConsolePlugin extends Ht
         pw.println("</tbody></table>");
         pw.println("<br/>");
 
+        pw.println("<table class='nicetable'><tbody>");
+        pw.println("<tr><th colspan='2'>Topology Capabilities</th></tr>");
+        final TopologyCapabilities cap = ((JobManagerImpl)this.jobManager).getTopologyCapabilities();
+        if ( cap == null ) {
+            pw.print("<tr><td colspan='2'>No topology information available !</td></tr>");
+        } else {
+            final Map<String, List<InstanceDescription>> instanceCaps = cap.getInstanceCapabilities();
+            for(final Map.Entry<String, List<InstanceDescription>> entry : instanceCaps.entrySet())
{
+                final StringBuilder sb = new StringBuilder();
+                for(final InstanceDescription id : entry.getValue()) {
+                    if ( sb.length() > 0 ) {
+                        sb.append("<br/>");
+                    }
+                    if ( id.isLocal() ) {
+                        sb.append("<b>local</b>");
+                    } else {
+                        sb.append(id.getSlingId());
+                    }
+                }
+                pw.printf("<tr><td>%s</td><td>%s</td></tr>",
entry.getKey(), sb.toString());
+            }
+        }
+        pw.println("</tbody></table>");
+        pw.println("<br/>");
+
         boolean isEmpty = true;
         for(final Queue q : this.jobManager.getQueues()) {
             isEmpty = false;
@@ -438,6 +468,29 @@ public class WebConsolePlugin extends Ht
         pw.printf("Average Waiting Time : %s%n", formatTime(s.getAverageWaitingTime()));
         pw.println();
 
+        pw.println("Topology Capabilities");
+        final TopologyCapabilities cap = ((JobManagerImpl)this.jobManager).getTopologyCapabilities();
+        if ( cap == null ) {
+            pw.print("No topology information available !");
+        } else {
+            final Map<String, List<InstanceDescription>> instanceCaps = cap.getInstanceCapabilities();
+            for(final Map.Entry<String, List<InstanceDescription>> entry : instanceCaps.entrySet())
{
+                final StringBuilder sb = new StringBuilder();
+                for(final InstanceDescription id : entry.getValue()) {
+                    if ( sb.length() > 0 ) {
+                        sb.append(", ");
+                    }
+                    if ( id.isLocal() ) {
+                        sb.append("local");
+                    } else {
+                        sb.append(id.getSlingId());
+                    }
+                }
+                pw.printf("%s : %s%n", entry.getKey(), sb.toString());
+            }
+        }
+        pw.println();
+
         boolean isEmpty = true;
         for(final Queue q : this.jobManager.getQueues()) {
             isEmpty = false;



Mime
View raw message