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

More clustering work.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9229 b35dd754-fafc-0310-a699-88a17e54d16e
parent be7b6729
......@@ -322,8 +322,10 @@ public class ClusterManager {
}
/**
* Returns true if clustering is installed and can be used by
* this JVM to join a cluster.
* Returns true if clustering is installed and can be used by this JVM
* to join a cluster. A false value could mean that either clustering
* support is not available or the license does not allow to have more
* than 1 cluster node.
*
* @return true if clustering is installed and can be used by
* this JVM to join a cluster.
......@@ -375,10 +377,11 @@ public class ClusterManager {
}
/**
* Returns the maximum number of cluster members allowed. A value of 0 will
* be returned when clustering is not allowed.
* Returns the maximum number of cluster members allowed. Both values 0 and 1 mean that clustering
* is not available. However, a value of 1 means that it's a license problem rather than not having
* the ability to do clustering as defined with value 0.
*
* @return the maximum number of cluster members allowed or 0 if clustering is not allowed.
* @return the maximum number of cluster members allowed or 0 or 1 if clustering is not allowed.
*/
public static int getMaxClusterNodes() {
return CacheFactory.getMaxClusterNodes();
......
......@@ -112,20 +112,16 @@ public class CacheFactory {
}
/**
* Returns true if clustering is installed and can be used by
* this JVM to join a cluster.
* Returns true if clustering is installed and can be used by this JVM
* to join a cluster. A false value could mean that either clustering
* support is not available or the license does not allow to have more
* than 1 cluster node.
*
* @return true if clustering is installed and can be used by
* this JVM to join a cluster.
*/
public static boolean isClusteringAvailable() {
try {
Class.forName(clusteredCacheFactoryClass, true,
getClusteredCacheStrategyClassLoader("enterprise"));
} catch (ClassNotFoundException e) {
return false;
}
return true;
return getMaxClusterNodes() > 1;
}
/**
......@@ -204,15 +200,13 @@ public class CacheFactory {
* @return the maximum number of cluster members allowed or 0 or 1 if clustering is not allowed.
*/
public static int getMaxClusterNodes() {
if (isClusteringAvailable()) {
try {
CacheFactoryStrategy cacheFactory = (CacheFactoryStrategy) Class.forName(
clusteredCacheFactoryClass, true,
getClusteredCacheStrategyClassLoader("enterprise")).newInstance();
return cacheFactory.getMaxClusterNodes();
} catch (Exception e) {
Log.error("Error instantiating clustered cache factory", e);
}
try {
CacheFactoryStrategy cacheFactory = (CacheFactoryStrategy) Class.forName(
clusteredCacheFactoryClass, true,
getClusteredCacheStrategyClassLoader("enterprise")).newInstance();
return cacheFactory.getMaxClusterNodes();
} catch (Exception e) {
Log.error("Error instantiating clustered cache factory", e);
}
return 0;
}
......
......@@ -75,12 +75,18 @@
int outgoing = 0;
for (Object stat : statistics) {
Map<String, Object> statsMap = (Map<String, Object>) stat;
if (statsMap == null) {
continue;
}
clients += (Integer) statsMap.get(GetBasicStatistics.CLIENT);
incoming += (Integer) statsMap.get(GetBasicStatistics.INCOMING);
outgoing += (Integer) statsMap.get(GetBasicStatistics.OUTGOING);
}
for (Object stat : statistics) {
Map<String, Object> statsMap = (Map<String, Object>) stat;
if (statsMap == null) {
continue;
}
int current = (Integer) statsMap.get(GetBasicStatistics.CLIENT);
int percentage = clients == 0 ? 0 : current * 100 / clients;
statsMap.put(GetBasicStatistics.CLIENT, current + " (" + Math.round(percentage) + "%)");
......@@ -242,6 +248,9 @@
Map<String, Object> nodeStats = null;
for (Object stat : statistics) {
Map<String, Object> statsMap = (Map<String, Object>) stat;
if (statsMap == null) {
continue;
}
if (Arrays.equals((byte[]) statsMap.get(GetBasicStatistics.NODE),
nodeInfo.getNodeID().toByteArray())) {
nodeStats = statsMap;
......
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