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 { ...@@ -322,8 +322,10 @@ public class ClusterManager {
} }
/** /**
* Returns true if clustering is installed and can be used by * Returns true if clustering is installed and can be used by this JVM
* this JVM to join a cluster. * 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 * @return true if clustering is installed and can be used by
* this JVM to join a cluster. * this JVM to join a cluster.
...@@ -375,10 +377,11 @@ public class ClusterManager { ...@@ -375,10 +377,11 @@ public class ClusterManager {
} }
/** /**
* Returns the maximum number of cluster members allowed. A value of 0 will * Returns the maximum number of cluster members allowed. Both values 0 and 1 mean that clustering
* be returned when clustering is not allowed. * 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() { public static int getMaxClusterNodes() {
return CacheFactory.getMaxClusterNodes(); return CacheFactory.getMaxClusterNodes();
......
...@@ -112,20 +112,16 @@ public class CacheFactory { ...@@ -112,20 +112,16 @@ public class CacheFactory {
} }
/** /**
* Returns true if clustering is installed and can be used by * Returns true if clustering is installed and can be used by this JVM
* this JVM to join a cluster. * 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 * @return true if clustering is installed and can be used by
* this JVM to join a cluster. * this JVM to join a cluster.
*/ */
public static boolean isClusteringAvailable() { public static boolean isClusteringAvailable() {
try { return getMaxClusterNodes() > 1;
Class.forName(clusteredCacheFactoryClass, true,
getClusteredCacheStrategyClassLoader("enterprise"));
} catch (ClassNotFoundException e) {
return false;
}
return true;
} }
/** /**
...@@ -204,7 +200,6 @@ public class CacheFactory { ...@@ -204,7 +200,6 @@ public class CacheFactory {
* @return the maximum number of cluster members allowed or 0 or 1 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() { public static int getMaxClusterNodes() {
if (isClusteringAvailable()) {
try { try {
CacheFactoryStrategy cacheFactory = (CacheFactoryStrategy) Class.forName( CacheFactoryStrategy cacheFactory = (CacheFactoryStrategy) Class.forName(
clusteredCacheFactoryClass, true, clusteredCacheFactoryClass, true,
...@@ -213,7 +208,6 @@ public class CacheFactory { ...@@ -213,7 +208,6 @@ public class CacheFactory {
} catch (Exception e) { } catch (Exception e) {
Log.error("Error instantiating clustered cache factory", e); Log.error("Error instantiating clustered cache factory", e);
} }
}
return 0; return 0;
} }
/** /**
......
...@@ -75,12 +75,18 @@ ...@@ -75,12 +75,18 @@
int outgoing = 0; int outgoing = 0;
for (Object stat : statistics) { for (Object stat : statistics) {
Map<String, Object> statsMap = (Map<String, Object>) stat; Map<String, Object> statsMap = (Map<String, Object>) stat;
if (statsMap == null) {
continue;
}
clients += (Integer) statsMap.get(GetBasicStatistics.CLIENT); clients += (Integer) statsMap.get(GetBasicStatistics.CLIENT);
incoming += (Integer) statsMap.get(GetBasicStatistics.INCOMING); incoming += (Integer) statsMap.get(GetBasicStatistics.INCOMING);
outgoing += (Integer) statsMap.get(GetBasicStatistics.OUTGOING); outgoing += (Integer) statsMap.get(GetBasicStatistics.OUTGOING);
} }
for (Object stat : statistics) { for (Object stat : statistics) {
Map<String, Object> statsMap = (Map<String, Object>) stat; Map<String, Object> statsMap = (Map<String, Object>) stat;
if (statsMap == null) {
continue;
}
int current = (Integer) statsMap.get(GetBasicStatistics.CLIENT); int current = (Integer) statsMap.get(GetBasicStatistics.CLIENT);
int percentage = clients == 0 ? 0 : current * 100 / clients; int percentage = clients == 0 ? 0 : current * 100 / clients;
statsMap.put(GetBasicStatistics.CLIENT, current + " (" + Math.round(percentage) + "%)"); statsMap.put(GetBasicStatistics.CLIENT, current + " (" + Math.round(percentage) + "%)");
...@@ -242,6 +248,9 @@ ...@@ -242,6 +248,9 @@
Map<String, Object> nodeStats = null; Map<String, Object> nodeStats = null;
for (Object stat : statistics) { for (Object stat : statistics) {
Map<String, Object> statsMap = (Map<String, Object>) stat; Map<String, Object> statsMap = (Map<String, Object>) stat;
if (statsMap == null) {
continue;
}
if (Arrays.equals((byte[]) statsMap.get(GetBasicStatistics.NODE), if (Arrays.equals((byte[]) statsMap.get(GetBasicStatistics.NODE),
nodeInfo.getNodeID().toByteArray())) { nodeInfo.getNodeID().toByteArray())) {
nodeStats = statsMap; 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