Author: challngr
Date: Thu Jul  3 15:50:28 2014
New Revision: 1607683

URL: http://svn.apache.org/r1607683
Log:
UIMA-3990 Bug fixes, visual clean-up.

Removed:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/SpectrumColorMap.java
Modified:
    uima/sandbox/uima-ducc/trunk/src/main/config/log4j.xml
    uima/sandbox/uima-ducc/trunk/src/main/resources/ducc.properties
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/JobFragment.java
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/Markup.java
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/NodeViz.java
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/VisualizedHost.java

Modified: uima/sandbox/uima-ducc/trunk/src/main/config/log4j.xml
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/src/main/config/log4j.xml?rev=1607683&r1=1607682&r2=1607683&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/src/main/config/log4j.xml (original)
+++ uima/sandbox/uima-ducc/trunk/src/main/config/log4j.xml Thu Jul  3 15:50:28 
2014
@@ -197,11 +197,6 @@
      <appender-ref ref="wslog" /> 
    </category>
 
-   <category name="org.apache.uima.ducc.ws.server.nodeviz" additivity="true">
-     <priority value="info"/>
-     <appender-ref ref="wslog" /> 
-   </category>
-
    <category name="org.apache.uima.ducc.viz" additivity="true">
      <priority value="debug"/>
      <appender-ref ref="vizlog" /> 

Modified: uima/sandbox/uima-ducc/trunk/src/main/resources/ducc.properties
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/src/main/resources/ducc.properties?rev=1607683&r1=1607682&r2=1607683&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/src/main/resources/ducc.properties (original)
+++ uima/sandbox/uima-ducc/trunk/src/main/resources/ducc.properties Thu Jul  3 
15:50:28 2014
@@ -201,8 +201,8 @@ ducc.ws.jsp.compilation.directory = /tmp
 ducc.ws.login.enabled = false
 # Specify precalculate machines (default is true)
 ducc.ws.precalculate.machines = true
-# multihomed systems, viz may have an external face other than ${ducc.head}
-ducc.viz.public.hostname = ${ducc.head}
+# For node fisualization - if true,strip domain names from labels for cleaner 
visuals
+ducc.ws.visualization.strip.domain = true
 
 # ========== Web Server Configuration block ==========
 

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/JobFragment.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/JobFragment.java?rev=1607683&r1=1607682&r2=1607683&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/JobFragment.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/JobFragment.java
 Thu Jul  3 15:50:28 2014
@@ -17,6 +17,9 @@ class JobFragment
     String   color;            // color to draw this
     DuccType type;             // Job, Service, Reservation, Pop. 
 
+    String textColor = "white";
+    String fillColor = "black";
+
     JobFragment(String user, DuccType type, String id, int mem, int qshares, 
String service_endpoint)
     {
         this.user             = user;
@@ -26,6 +29,7 @@ class JobFragment
         this.mem              = mem;
         this.nprocesses       = 1;
         this.service_endpoint = service_endpoint;
+        setColors();
     }
 
     void addShares(int qshares)
@@ -39,6 +43,36 @@ class JobFragment
         return this.id.equals(id);
     }
 
+    /**
+     * Set the fill and text color based on a hash of the user.
+     */
+    void setColors ()
+    {
+        if ( type == DuccType.Undefined ) {
+            fillColor = "0,0,0";
+            textColor = "256,256,256";
+        } else {
+            int color_index = (user + " ").hashCode();  // we add " " because 
orginal viz did and this keeps the colors consistent.
+
+            color_index = Math.abs(color_index) % 512;
+            int r = (color_index % 8)        * 28 + 44;
+            int g = ((color_index / 8) % 8)  * 28 + 44;
+            int b = ((color_index / 64) % 8) * 28 + 44;
+            if (r + g + b < 60) {
+                r *=2 ; g *=2; b *=2;
+            }
+
+            int brightness = (int)Math.sqrt(
+                              r * r * .241 + 
+                              g * g * .691 + 
+                              b * b * .068);
+
+            fillColor = "rgb(" + r + "," + g + "," + b + ")";
+            textColor = ( brightness < 130 ? "white" : "black" );
+        }
+//    
+    }
+
     String getTitle() { 
         switch ( type ) {
             case Reservation:

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/Markup.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/Markup.java?rev=1607683&r1=1607682&r2=1607683&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/Markup.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/Markup.java
 Thu Jul  3 15:50:28 2014
@@ -72,6 +72,20 @@ public class Markup
                                + "/> ");
        }
     
+       void nodeLabel(float x, float y, String label)
+    {
+               out.append(
+                               "<text x=\"" 
+                                               + (x*XSCALE) 
+                                               + "\" y=\""
+                                               + (y*YSCALE) 
+                                               + "\" font-family=\"helvetica\" 
font-size=\"10\" font-weight=\"bold\"" 
+                                               + " fill=\"black\">" 
+                                               + label
+                                               + "</text>"
+                               );
+       }
+
        void text(float x, float y, String label, String color, float fontsize, 
String newAttr) 
     {
                if (newAttr == null) { 
@@ -99,11 +113,7 @@ public class Markup
         switch ( j.type ) {
             case Job:
                 out.append(
-                           "<a xlink:href=http://"; +
-                           NodeViz.wshost +
-                           ":" +
-                           NodeViz.wsport + 
-                           "/job.details.jsp?id=" +
+                           "<a xlink:href=job.details.jsp?id=" +
                            j.id + 
                            ">"
                            );
@@ -111,11 +121,7 @@ public class Markup
                 break;
             case Service:
                 out.append(
-                           "<a xlink:href=http://"; +
-                           NodeViz.wshost +
-                           ":" +
-                           NodeViz.wsport + 
-                           "/service.details.jsp?name=" +
+                           "<a xlink:href=/service.details.jsp?name=" +
                            j.service_endpoint +
                            ">"
                            );
@@ -123,11 +129,7 @@ public class Markup
                 break;
             case Pop:
                 out.append(
-                           "<a xlink:href=http://"; +
-                           NodeViz.wshost +
-                           ":" +
-                           NodeViz.wsport + 
-                           "/reservations.details.jsp?id=" +
+                           "<a xlink:href=/reservations.details.jsp?id=" +
                            j.id + 
                            ">"
                            );
@@ -135,11 +137,7 @@ public class Markup
                 break;
             case Reservation:
                 out.append(
-                           "<a xlink:href=http://"; +
-                           NodeViz.wshost +
-                           ":" +
-                           NodeViz.wsport + 
-                           "/reservations.jsp>"
+                           "<a xlink:href=/reservations.jsp>"
                           );
                 break;
             case Undefined:
@@ -213,7 +211,7 @@ public class Markup
 
     String patternedFill(JobFragment j)
     {
-        String color = "rgb(" +        
SpectrumColorMap.neverDarkColorAlmostLight(j.user + " ")+")";
+        String color = j.fillColor;
 
         switch ( j.type ) {
             case Job:

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/NodeViz.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/NodeViz.java?rev=1607683&r1=1607682&r2=1607683&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/NodeViz.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/NodeViz.java
 Thu Jul  3 15:50:28 2014
@@ -46,6 +46,7 @@ public class NodeViz
     static int quantum = 4;
     static String wshost = "";
     static String wsport = "42133";
+    static boolean strip_domain = true;
 
        public NodeViz()
        {
@@ -55,18 +56,18 @@ public class NodeViz
         quantum         = 
SystemPropertyResolver.getIntProperty("ducc.rm.share.quantum", quantum);
 
         wshost          = 
SystemPropertyResolver.getStringProperty("ducc.ws.node", 
System.getProperty("ducc.head"));
-        wshost          = 
SystemPropertyResolver.getStringProperty("ducc.viz.public.hostname", wshost);
-
         wsport          = 
SystemPropertyResolver.getStringProperty("ducc.ws.port", wsport);
+        strip_domain   = 
SystemPropertyResolver.getBooleanProperty("ducc.ws.visualization.strip.domain", 
true);
         
         logger.info(methodName, null, 
"------------------------------------------------------------------------------------");
-        logger.info(methodName, null, "Nodeviz starting:");
+        logger.info(methodName, null, "Node Visualization starting:");
         logger.info(methodName, null, "    DUCC home               : ", 
System.getProperty("DUCC_HOME"));
         logger.info(methodName, null, "    ActiveMQ URL            : ", 
System.getProperty("ducc.broker.url"));
         logger.info(methodName, null, "Using Share Quantum         : ", 
quantum);
         logger.info(methodName, null, "Viz update Interval         : ", 
update_interval);
         logger.info(methodName, null, "Web Server Host             : ", 
wshost);
         logger.info(methodName, null, "Web Server Port             : ", 
wsport);
+        logger.info(methodName, null, "Strip Domains               : ", 
strip_domain);
         logger.info(methodName, null, "");
         logger.info(methodName, null, "    JVM                     : ", 
System.getProperty("java.vendor") +
                                                                    " "+ 
System.getProperty("java.version"));
@@ -77,7 +78,7 @@ public class NodeViz
         logger.info(methodName, null, "    OS Architecture         : ", 
System.getProperty("os.arch"));
         logger.info(methodName, null, "");
         logger.info(methodName, null, "    DUCC Version            : ", 
Version.version());
-        logger.info(methodName, null, "    Viz Version             : ", 
version);
+        logger.info(methodName, null, "    Vizualization Version   : ", 
version);
         logger.info(methodName, null, 
"------------------------------------------------------------------------------------");
 
         DuccListeners.getInstance().register(this);
@@ -283,14 +284,20 @@ public class NodeViz
         //}
     }
 
+    /**
+     * The contract:
+     * - when equals returns true,  compare must return 0
+     * - when equals returns false, compare must return 1 or -1
+     */
     private static class HostSorter
         implements Comparator<VisualizedHost>
     {
         public int compare(VisualizedHost h1, VisualizedHost h2)
         {
+            if ( h1 == h2 ) return 0;
             if ( h1.equals(h2) ) return 0;       
-            if ( h2.shares == h1.shares ) return h2.name.compareTo(h1.name);
-            return h2.shares - h1.shares;
+            if ( h2.mem == h1.mem ) return h1.name.compareTo(h2.name);
+            return h2.mem - h1.mem;
         }
     }
 

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/VisualizedHost.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/VisualizedHost.java?rev=1607683&r1=1607682&r2=1607683&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/VisualizedHost.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/nodeviz/VisualizedHost.java
 Thu Jul  3 15:50:28 2014
@@ -37,7 +37,7 @@ class VisualizedHost
     VisualizedHost(Node n, int quantum)
     {
         this.quantum = quantum;
-        this.name = n.getNodeIdentity().getName();
+        this.name = strip(n.getNodeIdentity().getName());
         this.ip = n.getNodeIdentity().getIp();            
         
         // mem from OR pub is in KB.  must convert to GB
@@ -55,7 +55,7 @@ class VisualizedHost
     {
         this.quantum = quantum;
 
-        this.name = info.getName();
+        this.name = strip(info.getName());
         this.ip = info.getIp();
 
         String ns = info.getSharesTotal();
@@ -72,6 +72,18 @@ class VisualizedHost
         this.shares_free = shares;        
     }
 
+    /**
+     * Possibly strip domain name from hostname
+     */
+    String strip(String n)
+    {
+        if ( NodeViz.strip_domain ) {
+            int ndx = n.indexOf(".");
+            n = n.substring(0, ndx);
+        }
+        return n;
+    }
+
     int countShares()
     {
         return shares;
@@ -131,22 +143,29 @@ class VisualizedHost
         if ( shares_free > 0 ) addWork(DuccType.Undefined, "", "", 0, 
shares_free, null);
 
         float size = (float) Math.sqrt(mem);
-        logger.debug(methodName, null, name, "size =", size);
+        logger.debug(methodName, null, name, "mem =", mem, "size =", size);
             
+        // here set a div that is TITLE_ADJUSTMENT higher and .2 wider than 
the actual node
         m.divStart();
         m.svgStart(size + TITLE_ADJUSTMENT, size + .2f);       // a bit taller 
than needed to make room for label
         // a bit wider, for horizontal spacing
 
+        // here draw the box for the node, offset by TITLE_ADJUSTMENT from the 
top of the div
         m.rect(0f, TITLE_ADJUSTMENT, size, size, "white", "none", .1f, "");
         
+        // here draw the node name just above the node box, including the hover
         m.tooltipStart(name + " (" + mem + "GB)");
-        m.text(0f, TITLE_ADJUSTMENT - .1f, name, "black", 10, "");
+        m.nodeLabel(0f, TITLE_ADJUSTMENT - .1f, name);
         m.tooltipEnd();
         
         Collections.sort(fragments, sorter);
-        float height_one_share = size / shares;
+        float height_one_share = (float) Math.sqrt(shares * NodeViz.quantum) / 
shares;
+        float foo = (float) Math.sqrt(mem) / shares;
+        logger.debug(methodName, null, name, "shares", shares, 
"height-one-share", height_one_share, "foo", foo);
         float top = 0f + TITLE_ADJUSTMENT;                   // the top of the 
box
         logger.debug(methodName, null, name, "Draw", fragments.size(), 
"rectangles, box size", size, "share height", height_one_share);
+
+
         for (JobFragment j : fragments ) {
 
             /**
@@ -158,26 +177,33 @@ class VisualizedHost
              *       <text>  text for job fragment (job id) </text>
              *   </a>
              */
-            if ( top > size ) {
-                logger.debug(methodName, null, name, "Box overflow. Size", 
size, "top", top);
-            }
-
             float height = j.qshares * height_one_share;
-            logger.debug(methodName, null, name, "Draw box of height", height, 
"for", j.type, j.id, "shares", j.qshares);
+            logger.debug(methodName, null, name, "Draw box at", top, "of 
width", size, "height", height,  "at (0, " + top +") for", j.type, j.id, 
"shares", j.qshares);
 
+            if ( top > (size + TITLE_ADJUSTMENT) ) {
+                logger.warn(methodName, null, name, "Box overflow. Size", 
size, "top", top);
+            }
+
+            // generate the fill patern for reservations, services, MR, jobs
                        String fill = m.patternedFill(j);
 
+            // establish the link into the ws proper for each work type
             m.hyperlinkStart(this, j);
 
+            // establish the tooltip for each fragment
             m.titleForFragment(this, j);
 
+            // draw the share block for each fragment
             if ( j.type == DuccType.Undefined ) {
                 m.rect(0, top, size, height, "", "black", .1f, "");
             } else {
                 m.rect(0, top, size, height, fill, "black", .1f, "");
             }
-            m.text(.1f, top + 1.5f, j.id, "white", 12, "");
 
+            // draw the work duccid in the fragment
+            m.text(.1f, top + 1.5f, j.id, j.textColor, 12, "");
+
+            // close off the markup elements
             m.hyperlinkEnd();
 
             top += height;


Reply via email to