Commit 69bf3eec 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@9200 b35dd754-fafc-0310-a699-88a17e54d16e
parent a71409d3
......@@ -20,6 +20,7 @@ import org.jivesoftware.util.lock.LocalLockFactory;
import org.jivesoftware.util.lock.LockManager;
import java.util.Queue;
import java.util.Collection;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -288,8 +289,17 @@ public class ClusterManager {
* @param enabled if clustering support is enabled.
*/
public static void setClusteringEnabled(boolean enabled) {
if (enabled == isClusteringEnabled()) {
return;
if (enabled) {
// Check that clustering is not already enabled and we are already in a cluster
if (isClusteringEnabled() && isClusteringStarted()) {
return;
}
}
else {
// Check that clustering is disabled
if (!isClusteringEnabled()) {
return;
}
}
JiveGlobals.setXMLProperty(CLUSTER_PROPERTY_NAME, Boolean.toString(enabled));
if (!enabled) {
......@@ -334,6 +344,17 @@ public class ClusterManager {
return CacheFactory.isSeniorClusterMember();
}
/**
* Returns basic information about the current members of the cluster or an empty
* collection if not running in a cluster.
*
* @return information about the current members of the cluster or an empty
* collection if not running in a cluster.
*/
public static Collection<ClusterNodeInfo> getNodesInfo() {
return CacheFactory.getClusterNodesInfo();
}
/**
* Returns the id of the node that is the senior cluster member. When not in a cluster the returned
* node id will be the {@link XMPPServer#getNodeID()}.
......
/**
* $RCSfile: $
* $Revision: $
* $Date: $
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.openfire.cluster;
/**
* Basic information about a cluster node.
*
* @author Gaston Dombiak
*/
public interface ClusterNodeInfo {
/**
* Returns the hostname where the cluster node is running.
*
* @return the hostname where the cluster node is running.
*/
String getHostName();
/**
* Returns the ID that uniquely identifies this node.
*
* @return the ID that uniquely identifies this node.
*/
NodeID getNodeID();
/**
* Return the date/time value (in cluster time) that the Member joined.
*
* @return the date/time value (in cluster time) that the Member joined.
*/
long getJoinedTime();
/**
* Returns true if this member is the senior member in the cluster.
*
* @return true if this cluster member is the senior.
*/
boolean isSeniorMember();
}
......@@ -9,6 +9,7 @@ package org.jivesoftware.util.cache;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.XMPPServerListener;
import org.jivesoftware.openfire.cluster.ClusterNodeInfo;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginClassLoader;
import org.jivesoftware.openfire.container.PluginManager;
......@@ -155,6 +156,17 @@ public class CacheFactory {
return cacheFactoryStrategy.isSeniorClusterMember();
}
/**
* Returns basic information about the current members of the cluster or an empty
* collection if not running in a cluster.
*
* @return information about the current members of the cluster or an empty
* collection if not running in a cluster.
*/
public static Collection<ClusterNodeInfo> getClusterNodesInfo() {
return cacheFactoryStrategy.getClusterNodesInfo();
}
/**
* Invokes a task on other cluster members in an asynchronous fashion. The task will not be
* executed on the local cluster member. If clustering is not enabled, this method
......
......@@ -7,6 +7,8 @@
*/
package org.jivesoftware.util.cache;
import org.jivesoftware.openfire.cluster.ClusterNodeInfo;
import java.util.Collection;
import java.util.Map;
......@@ -52,6 +54,15 @@ public interface CacheFactoryStrategy {
*/
boolean isSeniorClusterMember();
/**
* Returns basic information about the current members of the cluster or an empty
* collection if not running in a cluster.
*
* @return information about the current members of the cluster or an empty
* collection if not running in a cluster.
*/
Collection<ClusterNodeInfo> getClusterNodesInfo();
/**
* Returns a byte[] that uniquely identifies this senior cluster member or <tt>null</tt>
* when not in a cluster.
......
......@@ -10,6 +10,7 @@ package org.jivesoftware.util.cache;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.cluster.ClusterNodeInfo;
import java.util.Collection;
import java.util.Collections;
......@@ -159,6 +160,10 @@ public class DefaultLocalCacheStrategy implements CacheFactoryStrategy {
return true;
}
public Collection<ClusterNodeInfo> getClusterNodesInfo() {
return Collections.emptyList();
}
public byte[] getSeniorClusterMemberID() {
return null;
}
......
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