Commit 9f6a9408 authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-205: Improve stats and configurability for hazelcast plugin

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/pubsub_clustering@13293 b35dd754-fafc-0310-a699-88a17e54d16e
parent c3479bdb
...@@ -45,6 +45,7 @@ public class ClusteredCache implements Cache { ...@@ -45,6 +45,7 @@ public class ClusteredCache implements Cache {
*/ */
protected IMap map; protected IMap map;
private String name; private String name;
private long numberOfGets = 0;
/** /**
* Create a new cache using the supplied named cache as the actual cache implementation * Create a new cache using the supplied named cache as the actual cache implementation
...@@ -81,6 +82,7 @@ public class ClusteredCache implements Cache { ...@@ -81,6 +82,7 @@ public class ClusteredCache implements Cache {
} }
public Object get(Object key) { public Object get(Object key) {
numberOfGets++;
return map.get(key); return map.get(key);
} }
...@@ -130,10 +132,8 @@ public class ClusteredCache implements Cache { ...@@ -130,10 +132,8 @@ public class ClusteredCache implements Cache {
} }
public long getCacheMisses() { public long getCacheMisses() {
LocalMapStats stats = map.getLocalMapStats(); long hits = map.getLocalMapStats().getHits();
long gets = stats.getOperationStats().getNumberOfGets(); return numberOfGets > hits ? numberOfGets - hits : 0;
long hits = stats.getHits();
return gets > hits ? gets - hits : 0;
} }
public int getCacheSize() { public int getCacheSize() {
......
...@@ -38,6 +38,7 @@ import java.util.concurrent.locks.Lock; ...@@ -38,6 +38,7 @@ import java.util.concurrent.locks.Lock;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.cluster.ClusterNodeInfo; import org.jivesoftware.openfire.cluster.ClusterNodeInfo;
import org.jivesoftware.openfire.cluster.NodeID; import org.jivesoftware.openfire.cluster.NodeID;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.cache.Cache; import org.jivesoftware.util.cache.Cache;
import org.jivesoftware.util.cache.CacheFactoryStrategy; import org.jivesoftware.util.cache.CacheFactoryStrategy;
import org.jivesoftware.util.cache.CacheWrapper; import org.jivesoftware.util.cache.CacheWrapper;
...@@ -62,8 +63,10 @@ import com.hazelcast.core.MultiTask; ...@@ -62,8 +63,10 @@ import com.hazelcast.core.MultiTask;
*/ */
public class ClusteredCacheFactory implements CacheFactoryStrategy { public class ClusteredCacheFactory implements CacheFactoryStrategy {
// TODO: make this a configurable setting private static final long MAX_CLUSTER_EXECUTION_TIME =
private static final long MAX_CLUSTER_EXECUTION_TIME = 30; JiveGlobals.getLongProperty("hazelcast.max.execution.seconds", 30);
private static final String HAZELCAST_CONFIG_FILE =
JiveGlobals.getProperty("hazelcast.config.xml.filename", "hazelcast-cache-config.xml");
private static Logger logger = LoggerFactory.getLogger(ClusteredCacheFactory.class); private static Logger logger = LoggerFactory.getLogger(ClusteredCacheFactory.class);
...@@ -90,7 +93,7 @@ public class ClusteredCacheFactory implements CacheFactoryStrategy { ...@@ -90,7 +93,7 @@ public class ClusteredCacheFactory implements CacheFactoryStrategy {
oldLoader = Thread.currentThread().getContextClassLoader(); oldLoader = Thread.currentThread().getContextClassLoader();
ClassLoader loader = new ClusterClassLoader(); ClassLoader loader = new ClusterClassLoader();
Thread.currentThread().setContextClassLoader(loader); Thread.currentThread().setContextClassLoader(loader);
Config config = new ClasspathXmlConfig("hazelcast-cache-config.xml"); Config config = new ClasspathXmlConfig(HAZELCAST_CONFIG_FILE);
config.setInstanceName("openfire"); config.setInstanceName("openfire");
hazelcast = Hazelcast.newHazelcastInstance(config); hazelcast = Hazelcast.newHazelcastInstance(config);
cluster = hazelcast.getCluster(); cluster = hazelcast.getCluster();
......
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