[freenet-cvs] r13099 - trunk/freenet/src/freenet/node

toad at freenetproject.org toad at freenetproject.org
Wed May 2 16:12:45 UTC 2007


Author: toad
Date: 2007-05-02 16:12:45 +0000 (Wed, 02 May 2007)
New Revision: 13099

Modified:
   trunk/freenet/src/freenet/node/NodeStats.java
Log:
Minor refactoring, make fair liability split between different request types work for both output and input

Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java	2007-05-02 14:35:36 UTC (rev 13098)
+++ trunk/freenet/src/freenet/node/NodeStats.java	2007-05-02 16:12:45 UTC (rev 13099)
@@ -398,11 +398,16 @@
 		// Increment each running count unless it is the one we are currently processing.
 		// Purpose: Don't allow an SSK request (e.g.) unless there is space for a CHK insert *as well*.
 		
+		int numCHKRequests = node.getNumCHKRequests() + ((!isInsert) && (!isSSK) ? 0 : 1);
+		int numSSKRequests = node.getNumSSKRequests() + ((!isInsert) && isSSK ? 0 : 1);
+		int numCHKInserts = node.getNumCHKInserts() + (isInsert && (!isSSK) ? 0 : 1);
+		int numSSKInserts = node.getNumSSKInserts() + (isInsert && isSSK ? 0 : 1);
+		
 		double bandwidthLiabilityOutput =
-			successfulChkFetchBytesSentAverage.currentValue() * (node.getNumCHKRequests() + ((!isInsert) && (!isSSK) ? 0 : 1)) +
-			successfulSskFetchBytesSentAverage.currentValue() * (node.getNumSSKRequests() + ((!isInsert) && isSSK ? 0 : 1)) +
-			successfulChkInsertBytesSentAverage.currentValue() * (node.getNumCHKInserts() + (isInsert && (!isSSK) ? 0 : 1)) +
-			successfulSskInsertBytesSentAverage.currentValue() * (node.getNumSSKInserts() + (isInsert && isSSK ? 0 : 1));
+			successfulChkFetchBytesSentAverage.currentValue() * numCHKRequests +
+			successfulSskFetchBytesSentAverage.currentValue() * numSSKRequests +
+			successfulChkInsertBytesSentAverage.currentValue() * numCHKInserts +
+			successfulSskInsertBytesSentAverage.currentValue() * numSSKInserts;
 		bandwidthLiabilityOutput += getSuccessfulBytes(isSSK, isInsert, false).currentValue();
 		double bandwidthAvailableOutput =
 			node.getOutputBandwidthLimit() * 90; // 90 seconds at full power; we have to leave some time for the search as well
@@ -413,10 +418,10 @@
 		}
 		
 		double bandwidthLiabilityInput =
-			successfulChkFetchBytesReceivedAverage.currentValue() * node.getNumCHKRequests() +
-			successfulSskFetchBytesReceivedAverage.currentValue() * node.getNumSSKRequests() +
-			successfulChkInsertBytesReceivedAverage.currentValue() * node.getNumCHKInserts() +
-			successfulSskInsertBytesReceivedAverage.currentValue() * node.getNumSSKInserts();
+			successfulChkFetchBytesReceivedAverage.currentValue() * numCHKRequests +
+			successfulSskFetchBytesReceivedAverage.currentValue() * numSSKRequests +
+			successfulChkInsertBytesReceivedAverage.currentValue() * numCHKInserts +
+			successfulSskInsertBytesReceivedAverage.currentValue() * numSSKInserts;
 		bandwidthLiabilityInput += getSuccessfulBytes(isSSK, isInsert, true).currentValue();
 		double bandwidthAvailableInput =
 			node.getInputBandwidthLimit() * 90; // 90 seconds at full power




More information about the cvs mailing list