Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) bugfix for wrong proxy traffic accounting
theli91c2a042a765
diff --git a/htroot/Status.java b/htroot/Status.javaindex 03f1a063c..c188c2c61 100644--- a/htroot/Status.java+++ b/htroot/Status.java@@ -298,8 +298,8 @@ public class Status {prop.put("processors", rt.availableProcessors());// proxy traffic- prop.put("trafficIn",bytesToString(httpdByteCountInputStream.getGlobalCount()));- prop.put("trafficOut",bytesToString(httpdByteCountOutputStream.getGlobalCount()));+ //prop.put("trafficIn",bytesToString(httpdByteCountInputStream.getGlobalCount()));+ prop.put("trafficProxy",bytesToString(httpdByteCountOutputStream.getAccountCount("PROXY")));prop.put("trafficCrawler",bytesToString(httpdByteCountInputStream.getAccountCount("CRAWLER")));// connection informationdiff --git a/htroot/Status_p.inc b/htroot/Status_p.incindex a80c5f358..ec7e2536e 100644--- a/htroot/Status_p.inc+++ b/htroot/Status_p.inc@@ -59,7 +59,7 @@</tr><tr class="TableCellDark"><td>Traffic</td>- <td>Proxy: #[trafficOut]# | Crawler: #[trafficCrawler]#</td>+ <td>Proxy: #[trafficProxy]# | Crawler: #[trafficCrawler]#</td><td>[<a href="Status.html?ResetTraffic=">Reset</a>]</td></tr><tr class="TableCellLight">diff --git a/htroot/xml/status_p.java b/htroot/xml/status_p.javaindex 325afb5d4..5e2311e1d 100644--- a/htroot/xml/status_p.java+++ b/htroot/xml/status_p.java@@ -75,7 +75,7 @@ public class status_p {// proxy trafficprop.put("trafficIn", httpdByteCountInputStream.getGlobalCount());- prop.put("trafficOut", httpdByteCountOutputStream.getGlobalCount());+ prop.put("trafficProxy", httpdByteCountOutputStream.getAccountCount("PROXY"));prop.put("trafficCrawler", httpdByteCountInputStream.getAccountCount("CRAWLER"));// return rewrite propertiesdiff --git a/htroot/xml/status_p.xml b/htroot/xml/status_p.xmlindex 2df05cbab..8eb7f9503 100644--- a/htroot/xml/status_p.xml+++ b/htroot/xml/status_p.xml@@ -14,7 +14,7 @@<processors>#[processors]#</processors><traffic><in>#[trafficIn]#</in>- <out>#[trafficOut]#</out>+ <proxy>#[trafficProxy]#</proxy><crawler>#[trafficCrawler]#</crawler></traffic></status>diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.javaindex ff761b815..a26a96697 100644--- a/source/de/anomic/http/httpc.java+++ b/source/de/anomic/http/httpc.java@@ -572,6 +572,7 @@ public final class httpc {/*** Returns the given date in an HTTP-usable format.+ * (according to RFC822)** @param date The Date-Object to be converted.* @return String with the date.@@ -696,6 +697,10 @@ public final class httpc {if (incomingByteCountAccounting != null) {this.clientInputByteCount = new httpdByteCountInputStream(this.socket.getInputStream(),incomingByteCountAccounting);}+ if (outgoingByteCountAccounting != null) {+ this.clientOutputByteCount = new httpdByteCountOutputStream(this.socket.getOutputStream(),outgoingByteCountAccounting);+ }+// getting input and output streamsthis.clientInput = new PushbackInputStream((this.clientInputByteCount!=null)?diff --git a/source/de/anomic/http/httpdBoundedSizeOutputStream.java b/source/de/anomic/http/httpdBoundedSizeOutputStream.javaindex 2b7fdb4e5..872c310d6 100644--- a/source/de/anomic/http/httpdBoundedSizeOutputStream.java+++ b/source/de/anomic/http/httpdBoundedSizeOutputStream.java@@ -55,7 +55,7 @@ public class httpdBoundedSizeOutputStream extends httpdByteCountOutputStream {}public httpdBoundedSizeOutputStream(OutputStream outputStream, long initByteCount, long sizeLimit) {- super(outputStream,initByteCount);+ super(outputStream,initByteCount,null);this.maxSize = sizeLimit;}diff --git a/source/de/anomic/http/httpdByteCountInputStream.java b/source/de/anomic/http/httpdByteCountInputStream.javaindex 45fadf682..457e3b6af 100644--- a/source/de/anomic/http/httpdByteCountInputStream.java+++ b/source/de/anomic/http/httpdByteCountInputStream.java@@ -70,8 +70,7 @@ public class httpdByteCountInputStream extends FilterInputStream {* @param inputStream the {@link InputStream} to read from*/public httpdByteCountInputStream(InputStream inputStream, String accountName) {- super(inputStream);- this.byteCountAccountName = accountName;+ this(inputStream,0,accountName);}/**diff --git a/source/de/anomic/http/httpdByteCountOutputStream.java b/source/de/anomic/http/httpdByteCountOutputStream.javaindex 5403be173..c6f6d2e33 100644--- a/source/de/anomic/http/httpdByteCountOutputStream.java+++ b/source/de/anomic/http/httpdByteCountOutputStream.java@@ -47,6 +47,7 @@ package de.anomic.http;import java.io.BufferedOutputStream;import java.io.IOException;import java.io.OutputStream;+import java.util.HashMap;public class httpdByteCountOutputStream extends BufferedOutputStream {@@ -54,24 +55,31 @@ public class httpdByteCountOutputStream extends BufferedOutputStream {private static long globalByteCount = 0;private boolean finished = false;+ private static final HashMap byteCountInfo = new HashMap(2);protected long byteCount;+ protected String byteCountAccountName = null;/*** Constructor of this class* @param outputStream the {@link OutputStream} to write to*/public httpdByteCountOutputStream(OutputStream outputStream) {- this(outputStream,0);+ this(outputStream,null);}+ public httpdByteCountOutputStream(OutputStream outputStream, String accountName) {+ this(outputStream,0,accountName);+ }+/*** Constructor of this class* @param outputStream the {@link OutputStream} to write to* @param initByteCount to initialize the bytecount with a given value*/- public httpdByteCountOutputStream(OutputStream outputStream, long initByteCount) {+ public httpdByteCountOutputStream(OutputStream outputStream, long initByteCount, String accountName) {super(outputStream);this.byteCount = initByteCount;+ this.byteCountAccountName = accountName;}/** @see java.io.OutputStream#write(byte[]) */@@ -100,15 +108,29 @@ public class httpdByteCountOutputStream extends BufferedOutputStream {return this.byteCount;}+ public String getAccountName() {+ return this.byteCountAccountName;+ }+public static long getGlobalCount() {synchronized (syncObject) {return globalByteCount;}}+ public static long getAccountCount(String accountName) {+ synchronized (syncObject) {+ if (byteCountInfo.containsKey(accountName)) {+ return ((Long)byteCountInfo.get(accountName)).longValue();+ }+ return 0;+ }+ }+public static void resetCount() {synchronized (syncObject) {globalByteCount = 0;+ byteCountInfo.clear();}}@@ -118,7 +140,16 @@ public class httpdByteCountOutputStream extends BufferedOutputStream {this.finished = true;synchronized (syncObject) {globalByteCount += this.byteCount;- }+ if (this.byteCountAccountName != null) {+ long lastByteCount = 0;+ if (byteCountInfo.containsKey(this.byteCountAccountName)) {+ lastByteCount = ((Long)byteCountInfo.get(this.byteCountAccountName)).longValue();+ }+ lastByteCount += this.byteCount;+ byteCountInfo.put(this.byteCountAccountName,new Long(lastByteCount));+ }++ }}protected void finalize() throws Throwable {diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.javaindex 0fd48164c..187326b65 100644--- a/source/de/anomic/http/httpdProxyHandler.java+++ b/source/de/anomic/http/httpdProxyHandler.java@@ -328,7 +328,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements httswitchboard.proxyLastAccess = System.currentTimeMillis();// using an ByteCount OutputStream to count the send bytes (needed for the logfile)- respond = new httpdByteCountOutputStream(respond,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE).length() + 2);+ respond = new httpdByteCountOutputStream(respond,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE).length() + 2,"PROXY");String host = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);String path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH); // always starts with leading '/'@@ -893,7 +893,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements httswitchboard.proxyLastAccess = System.currentTimeMillis();// using an ByteCount OutputStream to count the send bytes- respond = new httpdByteCountOutputStream(respond,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE).length() + 2);+ respond = new httpdByteCountOutputStream(respond,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE).length() + 2,"PROXY");String host = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);String path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);@@ -998,7 +998,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements httswitchboard.proxyLastAccess = System.currentTimeMillis();// using an ByteCount OutputStream to count the send bytes- respond = new httpdByteCountOutputStream(respond,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE).length() + 2);+ respond = new httpdByteCountOutputStream(respond,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE).length() + 2,"PROXY");String host = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);String path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);