Commit 4713e97e authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

More clustering optimizations.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10247 b35dd754-fafc-0310-a699-88a17e54d16e
parent ca948420
......@@ -37,6 +37,8 @@ public class ClientSessionInfo implements Externalizable {
private Presence presence;
private String defaultList;
private String activeList;
private int conflictCount;
private boolean offlineFloodStopped;
public ClientSessionInfo() {
}
......@@ -45,6 +47,8 @@ public class ClientSessionInfo implements Externalizable {
presence = session.getPresence();
defaultList = session.getDefaultList() != null ? session.getDefaultList().getName() : null;
activeList = session.getActiveList() != null ? session.getActiveList().getName() : null;
conflictCount = session.getConflictCount();
offlineFloodStopped = session.isOfflineFloodStopped();
}
public Presence getPresence() {
......@@ -59,6 +63,14 @@ public class ClientSessionInfo implements Externalizable {
return activeList;
}
public int getConflictCount() {
return conflictCount;
}
public boolean isOfflineFloodStopped() {
return offlineFloodStopped;
}
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSerializable(out, (DefaultElement) presence.getElement());
ExternalizableUtil.getInstance().writeBoolean(out, defaultList != null);
......@@ -69,6 +81,8 @@ public class ClientSessionInfo implements Externalizable {
if (activeList != null) {
ExternalizableUtil.getInstance().writeSafeUTF(out, activeList);
}
ExternalizableUtil.getInstance().writeInt(out, conflictCount);
ExternalizableUtil.getInstance().writeBoolean(out, offlineFloodStopped);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
......@@ -80,5 +94,7 @@ public class ClientSessionInfo implements Externalizable {
if (ExternalizableUtil.getInstance().readBoolean(in)) {
activeList = ExternalizableUtil.getInstance().readSafeUTF(in);
}
conflictCount = ExternalizableUtil.getInstance().readInt(in);
offlineFloodStopped = ExternalizableUtil.getInstance().readBoolean(in);
}
}
......@@ -640,6 +640,11 @@ public class LocalClientSession extends LocalSession implements ClientSession {
*/
public void setOfflineFloodStopped(boolean offlineFloodStopped) {
this.offlineFloodStopped = offlineFloodStopped;
if (ClusterManager.isClusteringStarted()) {
// Track information about the session and share it with other cluster nodes
Cache<String,ClientSessionInfo> cache = SessionManager.getInstance().getSessionInfoCache();
cache.put(getAddress().toString(), new ClientSessionInfo(this));
}
}
/**
......@@ -747,6 +752,11 @@ public class LocalClientSession extends LocalSession implements ClientSession {
*/
public void incrementConflictCount() {
conflictCount++;
if (ClusterManager.isClusteringStarted()) {
// Track information about the session and share it with other cluster nodes
Cache<String,ClientSessionInfo> cache = SessionManager.getInstance().getSessionInfoCache();
cache.put(getAddress().toString(), new ClientSessionInfo(this));
}
}
/**
......
......@@ -460,7 +460,7 @@ public class CacheFactory {
try {
CacheFactoryStrategy cacheFactory = (CacheFactoryStrategy) Class.forName(
clusteredCacheFactoryClass, true,
getClusteredCacheStrategyClassLoader("enterprise")).newInstance();
getClusteredCacheStrategyClassLoader()).newInstance();
return cacheFactory.getMaxClusterNodes();
} catch (ClassNotFoundException e) {
// Do nothing
......@@ -535,15 +535,18 @@ public class CacheFactory {
}
}
private static ClassLoader getClusteredCacheStrategyClassLoader(String pluginName) {
private static ClassLoader getClusteredCacheStrategyClassLoader() {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
Plugin enterprisePlugin = pluginManager.getPlugin(pluginName);
PluginClassLoader pluginLoader = pluginManager.getPluginClassloader(enterprisePlugin);
Plugin plugin = pluginManager.getPlugin("clustering");
if (plugin == null) {
plugin = pluginManager.getPlugin("enterprise");
}
PluginClassLoader pluginLoader = pluginManager.getPluginClassloader(plugin);
if (pluginLoader != null) {
return pluginLoader;
}
else {
Log.debug("Unable to find PluginClassloader for plugin: " + pluginName + " in CacheFactory.");
Log.debug("CacheFactory - Unable to find a Plugin that provides clustering support.");
return Thread.currentThread().getContextClassLoader();
}
}
......@@ -553,7 +556,7 @@ public class CacheFactory {
clusteringStarting = true;
try {
cacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(clusteredCacheFactoryClass, true,
getClusteredCacheStrategyClassLoader("enterprise"))
getClusteredCacheStrategyClassLoader())
.newInstance();
clusteringStarted = cacheFactoryStrategy.startCluster();
}
......
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