Update of /cvsroot/freenet/freenet/src/freenet/node/http/infolets
In directory sc8-pr-cvs1:/tmp/cvs-serv25857/src/freenet/node/http/infolets

Modified Files:
      Tag: stable
        DefaultInfolet.java EnvironmentInfolet.java 
        GeneralInfolet.java 
Log Message:
5029: Merge from unstable after months of work. MASSIVE changes.
Highlights:
* Next Generation Routing, massive related changes
* Major changes to handling of messages and connections (PeerHandler and related 
changes)
* Even more non-blocking I/O
* Documentation improvements
* Lots of new diagnostics and config options
* Lots of bug fixes and performance tweaking
* Probably lots of new bugs too!


Index: DefaultInfolet.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/http/infolets/DefaultInfolet.java,v
retrieving revision 1.25.2.17.2.11
retrieving revision 1.25.2.17.2.12
diff -u -w -r1.25.2.17.2.11 -r1.25.2.17.2.12
--- DefaultInfolet.java 23 Jul 2003 01:56:53 -0000      1.25.2.17.2.11
+++ DefaultInfolet.java 28 Oct 2003 20:20:38 -0000      1.25.2.17.2.12
@@ -224,7 +224,7 @@
          *  I have used an external template since the insert HTML is quite complex
          */
         
-        if (Node.httpInserts) {
+        if (Node.httpInserts && SimpleAdvanced_ModeUtils.isAdvancedMode(req)) {
             ssw = new StringWriter(100);
             sw = new PrintWriter(ssw);
             insertTmp.toHtml(sw);
@@ -338,7 +338,7 @@
         // ignore... we don't handle any individual values   
     }
     public void configPropertyUpdated(String path, Params fs) {
-       if(Core.logger.shouldLog(Logger.DEBUG))
+       if(Core.logger.shouldLog(Logger.DEBUG,this))
            Core.logger.log(DefaultInfolet.class, "configPropertyUpdated "+
                            "called w/ path [" + path + "]: fs = "+fs, 
                            Core.logger.DEBUG);

Index: EnvironmentInfolet.java
===================================================================
RCS file: 
/cvsroot/freenet/freenet/src/freenet/node/http/infolets/EnvironmentInfolet.java,v
retrieving revision 1.16.4.12.2.8
retrieving revision 1.16.4.12.2.9
diff -u -w -r1.16.4.12.2.8 -r1.16.4.12.2.9
--- EnvironmentInfolet.java     23 Jul 2003 01:56:53 -0000      1.16.4.12.2.8
+++ EnvironmentInfolet.java     28 Oct 2003 20:20:39 -0000      1.16.4.12.2.9
@@ -6,6 +6,7 @@
 import freenet.Core;
 import freenet.support.Logger;
 import freenet.fs.dir.NativeFSDirectory;
+import freenet.thread.*;
 import freenet.thread.PooledThread;
 import freenet.support.servlet.HtmlTemplate;
 import freenet.transport.tcpAddress;
@@ -108,8 +109,8 @@
             sw.println("<tr><td>Space used by temp files</td><td align=right>" + 
format(((NativeFSDirectory)(node.dir)).tempSpaceUsed())+"</td></tr>");
             sw.println("<tr><td>Maximum space for temp files</td><td align=right>"+ 
format(((NativeFSDirectory)(node.dir)).maxTempSpace())+"</td></tr>");
             if (keys > 0) {
-                sw.println("<tr><td>Most recent file timestamp</td><td align=right>" 
+ new 
Date(((NativeFSDirectory)node.dir).mostRecentlyUsedTime()).toString()+"</td></tr>");
-                sw.println("<tr><td>Least recent file timestamp</td><td align=right>" 
+ new 
Date(((NativeFSDirectory)node.dir).leastRecentlyUsedTime()).toString()+"</td></tr>");
+                sw.println("<tr><td>Most recent file access time</td><td 
align=right>" + new 
Date(((NativeFSDirectory)node.dir).mostRecentlyUsedTime()).toString()+"</td></tr>");
+                sw.println("<tr><td>Least recent file access time</td><td 
align=right>" + new 
Date(((NativeFSDirectory)node.dir).leastRecentlyUsedTime()).toString()+"</td></tr>");
             }
         }
        sw.println("</table>");
@@ -153,51 +154,22 @@
            titleBoxTmp.toHtml(pw);
        }
        
-        ThreadGroup tg = Thread.currentThread().getThreadGroup().getParent();
-        ThreadGroup topMost = null;
-        while(tg != null)
-        {
-            topMost = tg;
-            tg = tg.getParent();
-        }
-       StringBuffer buffer = new StringBuffer();
-       Hashtable consumers = new Hashtable();
-       ThreadCount tc = new ThreadCount();
-        doGroup(topMost, buffer, consumers, tc);
-        if (!consumers.isEmpty()) {
-            ssw = new StringWriter(200);
-            sw = new PrintWriter(ssw);
             
-            total = tc.total;
-            available = tc.available;
-           sw.println("<table width=\"100%\">");
-           sw.println("<tr><td>Total pooled threads</td><td align=right>" + total + 
"</td></tr>");
-            sw.println("<tr><td>Available pooled threads</td><td align=right>" + 
available + "</td></tr>");
-            sw.println("<tr><td>Pooled threads in use</td><td align=right>" + (total 
- available) + "</td></tr>");
-                       sw.println("</table>");
+               ThreadStatusSnapshot t=new ThreadStatusSnapshot();
+               if (!t.getPoolConsumers().isEmpty()) {
             titleBoxTmp.set("TITLE", "Thread Pool");
-            titleBoxTmp.set("CONTENT", ssw.toString());
+            titleBoxTmp.set("CONTENT", t.threadStatusToHTML());
             titleBoxTmp.toHtml(pw);
 
-            ssw = new StringWriter(200);
-            sw = new PrintWriter(ssw);
-                       sw.println("<table width=\"100%\">");
-            sw.println("<tr><th align=\"left\">Class</th><th align=\"right\">Threads 
used</th>");
-            Object[] types = consumers.keySet().toArray();
-            java.util.Arrays.sort(types);
-            for (int x = 0; x < types.length; x++)
-                sw.println("<tr><td>" + types[x] + "</td><td align=\"right\">" +
-                          ((Consumer) consumers.get(types[x])).number + "</td></tr>");
-           sw.println("</table>");
             titleBoxTmp.set("TITLE", "Pooled Thread Consumers");
-            titleBoxTmp.set("CONTENT", ssw.toString());
+            titleBoxTmp.set("CONTENT", t.poolConsumersToHTML());
             titleBoxTmp.toHtml(pw);
         }
         pw.println("</td></tr></table>");
         pw.println("<br><br>");
         pw.println("ThreadGroup/Thread Hierarchy:");
         pw.print("<ul>");
-        pw.println(buffer.toString());
+        pw.println(t.threadTreeToHTML());
         pw.println("</ul><table><tr><td>");
     }
 

Index: GeneralInfolet.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/http/infolets/GeneralInfolet.java,v
retrieving revision 1.6.2.3.2.5
retrieving revision 1.6.2.3.2.6
diff -u -w -r1.6.2.3.2.5 -r1.6.2.3.2.6
--- GeneralInfolet.java 16 Aug 2003 17:30:07 -0000      1.6.2.3.2.5
+++ GeneralInfolet.java 28 Oct 2003 20:20:39 -0000      1.6.2.3.2.6
@@ -1,11 +1,14 @@
+/* -*- Mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*- */
 package freenet.node.http.infolets;
 import freenet.node.http.*;
 import freenet.node.Node;
+import freenet.support.LimitCounter;
 import freenet.diagnostics.Diagnostics;
 import freenet.Version;
 import freenet.support.servlet.*;
 import freenet.Core;
 import java.io.PrintWriter;
+import java.text.NumberFormat;
 
 /**
  * This is the Infolet which is displayed by default
@@ -16,13 +19,40 @@
 public class GeneralInfolet extends Infolet {
   private Node node;
 
+    private static final NumberFormat nfp;
+    private static final NumberFormat nf0;
+    private static final NumberFormat nf1;
+    private static final NumberFormat nf03;
+    private static final NumberFormat nf3;
+    static {
+        nfp = NumberFormat.getPercentInstance();
+        nfp.setMinimumFractionDigits(0);
+        nfp.setMaximumFractionDigits(1);
+        nf0 = NumberFormat.getInstance();
+        nf0.setMinimumFractionDigits(0);
+        nf0.setMaximumFractionDigits(0);
+        nf0.setGroupingUsed(false);
+        nf1 = NumberFormat.getInstance();
+        nf1.setMaximumFractionDigits(1);
+        nf1.setMinimumFractionDigits(1);
+        nf1.setGroupingUsed(false);
+        nf03 = NumberFormat.getInstance();
+        nf03.setMinimumFractionDigits(0);
+        nf03.setMaximumFractionDigits(3);
+        nf03.setGroupingUsed(false);
+        nf3 = NumberFormat.getInstance();
+        nf3.setMaximumFractionDigits(3);
+        nf3.setMinimumFractionDigits(3);
+        nf3.setGroupingUsed(false);
+    }
+
   HtmlTemplate titleBoxTemplate;
 
 
   /**
-   *  Description of the Method
+     *  Return long name of the infolet
    *
-   * @return    Description of the Return Value
+     * @return    String longName
    */
   public String longName() {
     return "General Information";
@@ -30,9 +60,9 @@
 
 
   /**
-   *  Description of the Method
+     *  Return short name of infolet
    *
-   * @return    Description of the Return Value
+     * @return    String shortName
    */
   public String shortName() {
     return "general";
@@ -40,9 +70,9 @@
 
 
   /**
-   *  Description of the Method
+     *  Initialize the node reference and create the title Box template
    *
-   * @param  n  Description of the Parameter
+     * @param  n  The Node object this page describes.
    */
   public void init(Node n) {
     try {
@@ -54,6 +84,11 @@
   }
 
 
+    /**
+     *  Create the General Information web page
+     *
+     * @param  pw  The PrintWriter where the page gets written.
+     */
   public void toHtml(PrintWriter pw) {
     StringBuffer sb = new StringBuffer(500);
     sb.append("From here you can view information about what is going ");
@@ -80,7 +115,7 @@
     titleBoxTemplate.toHtml(pw);
     StringBuffer uptime = new StringBuffer();
 
-    long deltat = (System.currentTimeMillis() - Node.startupTimeMs) / 1000;
+        long deltat = (System.currentTimeMillis() - Node.startupTimeMs + 500) / 1000;
 
     if (deltat < 60) {
       uptime.append("&nbsp;< 1 minute ");
@@ -112,16 +147,28 @@
     sb = new StringBuffer(500);
     sb.append("<table>");
     sb.append("<tr><td nowrap>Current routingTime</td><td>"
-         + (long) Core.diagnostics.getValue("routingTime", Diagnostics.MINUTE, 
Diagnostics.MEAN_VALUE) + "ms</td></tr>");
+                  + (long) Core.diagnostics.getValue("routingTime", 
+                                                     Diagnostics.MINUTE, 
+                                                     Diagnostics.MEAN_VALUE) +
+                  "ms</td></tr>");
+    
+        sb.append("<tr><td nowrap>Curent messageSendTimeRequest</td><td>" +
+                  (long) Core.diagnostics.getValue("messageSendTimeRequest",
+                                                   Diagnostics.MINUTE,
+                                                   Diagnostics.MEAN_VALUE) +
+                  "ms</td></tr>");
 
     // Thread load
     int jobs = node.activeJobs();
     int available = node.availableThreads();
-    float f = node.estimatedLoad();
+        StringBuffer whyLoad = new StringBuffer(500);
+        float f = node.estimatedLoad(whyLoad);
     // It's not just thread based.  There's also a hard
     // rate limit.
-    boolean rejectingRequests = node.rejectingRequests();
-    boolean rejectingConnections = node.rejectingConnections();
+        StringBuffer whyRejectingRequests = new StringBuffer(500);
+        boolean rejectingRequests = node.rejectingRequests(whyRejectingRequests);
+        StringBuffer whyRejectingConnections = new StringBuffer(500);
+        boolean rejectingConnections = 
node.rejectingConnections(whyRejectingConnections);
 
     String color = "black";
     String comment = "";
@@ -139,12 +186,15 @@
 
       int maximumThreads = node.getThreadFactory().maximumThreads();
       if (maximumThreads > 0) {
-        float threadPoolLoad = (((float) jobs) / maximumThreads) * 100.0f;
-        msg += " (" + Float.toString(threadPoolLoad) + "%)";
+                msg += " (" + nfp.format( ((float) jobs) / maximumThreads ) + ")";
       }
 
-      sb.append("<tr><td nowrap>Active pooled jobs</td><td>" + msg + "</td></tr>");
-      sb.append("<tr><td nowrap>Available threads</td><td>" + available + 
"</td></tr>");
+            sb.append("<tr><td nowrap>Pooled threads running jobs</td><td>" + msg + 
"</td></tr>");
+            sb.append("<tr><td nowrap>Pooled threads which are idle</td><td>" + 
available + "</td></tr>");
+            LimitCounter outboundRequestLimit = node.outboundRequestLimit;
+            if(outboundRequestLimit != null)
+                sb.append("<tr><td nowrap>Outbound request quota used</td><td>" +
+                          outboundRequestLimit.toString()+"</td></tr>");
       
       if(node.diagnostics != null && (node.outputBandwidthLimit != 0) &&
         (node.doOutLimitCutoff || node.doOutLimitConnectCutoff)) {
@@ -152,12 +202,20 @@
                                                  Diagnostics.MINUTE,
                                                  Diagnostics.COUNT_CHANGE)
              / 60;
-         int limit = (int)(node.outputBandwidthLimit 
-                           /* * Node.lowLevelBWLimitFudgeFactor*/);
-         sb.append("<tr><td nowrap>Current upstream bandwidth usage</td><td>" + 
(int)sent+
-                   " bytes/second ("+(int)((float)(100*sent) / 
(float)limit)+"%)</td></tr>");
+                double limit = node.outputBandwidthLimit;
+                sb.append("<tr><td nowrap>Current upstream bandwidth usage</td><td>" 
+ nf0.format(sent) +
+                          " bytes/second (" + nfp.format(sent / limit) + 
")</td></tr>");
+            }
+            if (rejectingConnections) {
+                sb.append("<tr><td>Reason for refusing connections:</td><td>");
+                sb.append(whyRejectingConnections);
+                sb.append("</td></tr>");
+            }
+            if (rejectingRequests) {
+                sb.append("<tr><td>Reason for QueryRejecting requests:</td><td>");
+                sb.append(whyRejectingRequests);
+                sb.append("</td></tr>");
       }
-      
       if (rejectingConnections || rejectingRequests) {
         sb.append("<tr><td></td><td>");
         sb.append("It's normal for the node to sometimes reject connections or 
requests");
@@ -170,12 +228,12 @@
         comment = " <font color=\"" + color + "\">" + comment + "</font><br>";
     }
     
-    sb.append(msg + f * 100 + "%"+comment+"</td></tr>");
+        sb.append(msg + nfp.format(f) + comment + "</td></tr>");
+        sb.append("<tr><td>Reason for load:</td><td>" + whyLoad.toString() + 
"</td></tr>");
     sb.append("</table>");
     titleBoxTemplate.set("TITLE", "Load");
     titleBoxTemplate.set("CONTENT", sb.toString());
     titleBoxTemplate.toHtml(pw);
   }
-
 }
 

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to