Commit 797491d0 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Modified Statistic interface to indicate if sample value hold value of cluster...

Modified Statistic interface to indicate if sample value hold value of cluster node only or entire cluster.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9135 b35dd754-fafc-0310-a699-88a17e54d16e
parent e443def0
......@@ -10,22 +10,23 @@
*/
package org.jivesoftware.openfire.filetransfer.proxy;
import org.jivesoftware.util.*;
import org.jivesoftware.util.cache.Cache;
import org.jivesoftware.util.cache.DefaultCache;
import org.jivesoftware.util.cache.CacheFactory;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.filetransfer.FileTransferManager;
import org.jivesoftware.openfire.filetransfer.FileTransferRejectedException;
import org.jivesoftware.openfire.stats.Statistic;
import org.jivesoftware.openfire.stats.StatisticsManager;
import org.jivesoftware.openfire.stats.i18nStatistic;
import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.util.cache.CacheFactory;
import org.xmpp.packet.JID;
import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.InetAddress;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -359,5 +360,9 @@ public class ProxyConnectionManager {
public double sample() {
return (ProxyOutputStream.amountTransfered.getAndSet(0) / 1000);
}
public boolean isPartialSample() {
return true;
}
}
}
\ No newline at end of file
......@@ -1388,6 +1388,10 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
public double sample() {
return getNumberChatRooms();
}
public boolean isPartialSample() {
return false;
}
};
StatisticsManager.getInstance().addStatistic(roomsStatKey, statistic);
}
......@@ -1414,6 +1418,10 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
public double sample() {
return getNumberRoomOccupants();
}
public boolean isPartialSample() {
return false;
}
};
StatisticsManager.getInstance().addStatistic(occupantsStatKey, statistic);
}
......@@ -1440,6 +1448,10 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
public double sample() {
return getNumberConnectedUsers(false);
}
public boolean isPartialSample() {
return false;
}
};
StatisticsManager.getInstance().addStatistic(usersStatKey, statistic);
}
......@@ -1464,9 +1476,13 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
}
public double sample() {
// TODO Get these value from the other cluster nodes
return inMessages.getAndSet(0);
}
public boolean isPartialSample() {
// Get this value from the other cluster nodes
return true;
}
};
StatisticsManager.getInstance().addMultiStatistic(incomingStatKey, trafficStatGroup, statistic);
}
......@@ -1493,6 +1509,11 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
public double sample() {
return outMessages.getAndSet(0);
}
public boolean isPartialSample() {
// Each cluster node knows the total across the cluster
return false;
}
};
StatisticsManager.getInstance().addMultiStatistic(outgoingStatKey, trafficStatGroup, statistic);
}
......
......@@ -136,6 +136,10 @@ public class ServerTrafficCounter {
// Divide result by 1024 so that we return the result in Kb.
return incomingCounter.getAndSet(0)/1024;
}
public boolean isPartialSample() {
return true;
}
};
StatisticsManager.getInstance()
.addMultiStatistic(incomingStatKey, trafficStatGroup, statistic);
......@@ -163,6 +167,10 @@ public class ServerTrafficCounter {
public double sample() {
return outgoingCounter.getAndSet(0)/1024;
}
public boolean isPartialSample() {
return true;
}
};
StatisticsManager.getInstance()
.addMultiStatistic(outgoingStatKey, trafficStatGroup, statistic);
......
......@@ -53,6 +53,24 @@ public interface Statistic {
*/
public double sample();
/**
* Returns true if the sample value represents only the value of the cluster node
* or otherwise it represents the value of the entire cluster. Statistics that keep
* only a sample of the local node will need to get added up with the value of the
* other cluster nodes. On the other hand, statistics that hold the value of the
* entire cluster can be sampled in any cluster node and they don't need to get
* added up.<p>
*
* An example of a partial sample statistic would be network traffic. Each node keeps
* track of its own network traffic information. Whilst an example of a total sample
* statistic would be user sessions since every cluster node knows the total number of
* connected users across the cluster.
*
* @return true if the sample value represents only the value of the cluster node
* or otherwise it represents the value of the entire cluster.
*/
public boolean isPartialSample();
/**
* The type of statistic.
*/
......
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