Commit e5324828 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Modified logic to calculate KBytes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4086 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1dc29d44
...@@ -43,8 +43,6 @@ public class ServerTrafficCounter { ...@@ -43,8 +43,6 @@ public class ServerTrafficCounter {
*/ */
private static final AtomicLong incomingCounter = new AtomicLong(0); private static final AtomicLong incomingCounter = new AtomicLong(0);
private static final int KBytes = 1024;
private static final String trafficStatGroup = "server_bytes"; private static final String trafficStatGroup = "server_bytes";
private static final String incomingStatKey = "server_bytes_in"; private static final String incomingStatKey = "server_bytes_in";
private static final String outgoingStatKey = "server_bytes_out"; private static final String outgoingStatKey = "server_bytes_out";
...@@ -143,7 +141,7 @@ public class ServerTrafficCounter { ...@@ -143,7 +141,7 @@ public class ServerTrafficCounter {
} }
public double sample() { public double sample() {
return outgoingCounter.getAndSet(0); return outgoingCounter.getAndSet(0)/1024;
} }
}; };
StatisticsManager.getInstance() StatisticsManager.getInstance()
...@@ -166,7 +164,7 @@ public class ServerTrafficCounter { ...@@ -166,7 +164,7 @@ public class ServerTrafficCounter {
public int read() throws IOException { public int read() throws IOException {
int readByte = originalStream.read(); int readByte = originalStream.read();
if (readByte > -1) { if (readByte > -1) {
incomingCounter.getAndAdd(1 / KBytes); incomingCounter.incrementAndGet();
} }
return readByte; return readByte;
} }
...@@ -174,7 +172,7 @@ public class ServerTrafficCounter { ...@@ -174,7 +172,7 @@ public class ServerTrafficCounter {
public int read(byte b[]) throws IOException { public int read(byte b[]) throws IOException {
int bytes = originalStream.read(b); int bytes = originalStream.read(b);
if (bytes > -1) { if (bytes > -1) {
incomingCounter.getAndAdd(bytes / KBytes); incomingCounter.getAndAdd(bytes);
} }
return bytes; return bytes;
} }
...@@ -182,7 +180,7 @@ public class ServerTrafficCounter { ...@@ -182,7 +180,7 @@ public class ServerTrafficCounter {
public int read(byte b[], int off, int len) throws IOException { public int read(byte b[], int off, int len) throws IOException {
int bytes = originalStream.read(b, off, len); int bytes = originalStream.read(b, off, len);
if (bytes > -1) { if (bytes > -1) {
incomingCounter.getAndAdd(bytes / KBytes); incomingCounter.getAndAdd(bytes);
} }
return bytes; return bytes;
} }
...@@ -229,21 +227,21 @@ public class ServerTrafficCounter { ...@@ -229,21 +227,21 @@ public class ServerTrafficCounter {
// forward request to wrapped stream // forward request to wrapped stream
originalStream.write(b); originalStream.write(b);
// update outgoingCounter // update outgoingCounter
outgoingCounter.getAndAdd(1 / KBytes); outgoingCounter.incrementAndGet();
} }
public void write(byte b[]) throws IOException { public void write(byte b[]) throws IOException {
// forward request to wrapped stream // forward request to wrapped stream
originalStream.write(b); originalStream.write(b);
// update outgoingCounter // update outgoingCounter
outgoingCounter.getAndAdd(b.length / KBytes); outgoingCounter.getAndAdd(b.length);
} }
public void write(byte b[], int off, int len) throws IOException { public void write(byte b[], int off, int len) throws IOException {
// forward request to wrapped stream // forward request to wrapped stream
originalStream.write(b, off, len); originalStream.write(b, off, len);
// update outgoingCounter // update outgoingCounter
outgoingCounter.getAndAdd(b.length / KBytes); outgoingCounter.getAndAdd(b.length);
} }
public void close() throws IOException { public void close() throws IOException {
...@@ -268,7 +266,7 @@ public class ServerTrafficCounter { ...@@ -268,7 +266,7 @@ public class ServerTrafficCounter {
public int read(ByteBuffer dst) throws IOException { public int read(ByteBuffer dst) throws IOException {
int bytes = originalChannel.read(dst); int bytes = originalChannel.read(dst);
if (bytes > -1) { if (bytes > -1) {
incomingCounter.getAndAdd(bytes / KBytes); incomingCounter.getAndAdd(bytes);
} }
return bytes; return bytes;
} }
...@@ -302,7 +300,7 @@ public class ServerTrafficCounter { ...@@ -302,7 +300,7 @@ public class ServerTrafficCounter {
public int write(ByteBuffer src) throws IOException { public int write(ByteBuffer src) throws IOException {
int bytes = originalChannel.write(src); int bytes = originalChannel.write(src);
outgoingCounter.getAndAdd(bytes / KBytes); outgoingCounter.getAndAdd(bytes);
return bytes; return bytes;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment