Author: nextgens
Date: 2006-10-29 15:08:53 +0000 (Sun, 29 Oct 2006)
New Revision: 10734

Modified:
   trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
Log:
Create a new, hidden feature allowing to request a thread dump from fproxy. The 
magic url beeing http://localhost:8888/?getThreadDump

Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2006-10-29 
14:38:08 UTC (rev 10733)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2006-10-29 
15:08:53 UTC (rev 10734)
@@ -5,6 +5,9 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Enumeration;
+
+import org.tanukisoftware.wrapper.WrapperManager;
+
 import freenet.client.ClientMetadata;
 import freenet.client.HighLevelSimpleClient;
 import freenet.client.InsertBlock;
@@ -316,6 +319,20 @@
                        addForm.addChild("input", new String[] { "type", 
"name", "value" }, new String[] { "submit", "addbookmark", "Add bookmark" });
                        this.writeReply(ctx, 200, "text/html", "OK", 
pageNode.generate());
                        return;
+               }else if(request.isParameterSet("getThreadDump")) {
+                       HTMLNode pageNode = ctx.getPageMaker().getPageNode("Get 
a Thread Dump");
+                       HTMLNode contentNode = 
ctx.getPageMaker().getContentNode(pageNode);
+                       if(node.isUsingWrapper()){
+                               HTMLNode infobox = 
contentNode.addChild(ctx.getPageMaker().getInfobox("Thread Dump generation"));
+                               
ctx.getPageMaker().getContentNode(infobox).addChild("#", "A thread dump has 
been generated, it's aviable in "+ 
WrapperManager.getProperties().getProperty("wrapper.logfile"));
+                               System.out.println("Thread Dump:");
+                               WrapperManager.requestThreadDump();
+                       }else{
+                               HTMLNode infobox = 
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-error","Thread Dump 
generation"));
+                               
ctx.getPageMaker().getContentNode(infobox).addChild("#", "It's not possible to 
make the node generate a thread dump if you aren't using the wrapper!");
+                       }
+                       this.writeReply(ctx, 200, "text/html", "OK", 
pageNode.generate());
+                       return;
                } else if 
(request.getParam(GenericReadFilterCallback.magicHTTPEscapeString).length() > 
0) {
                        HTMLNode pageNode = 
ctx.getPageMaker().getPageNode("Link to external resources");
                        HTMLNode contentNode = 
ctx.getPageMaker().getContentNode(pageNode);


Reply via email to