com.caucho.server.cluster
Class ClusterPod

java.lang.Object
  extended by com.caucho.server.cluster.ClusterPod

public abstract class ClusterPod
extends java.lang.Object

The ClusterPod is a reliable triplicate for clustered data. For small clusters, the triad may only have 1 or 2 servers, so server B and server C may return null.


Nested Class Summary
static class ClusterPod.Owner
          For any object, assigns an owner and backup in the triad.
 
Field Summary
static ClusterPod.Owner[] OWNER_VALUES
           
 
Constructor Summary
protected ClusterPod(Cluster cluster, int index)
          Creates a new triad for the cluster.
 
Method Summary
 void addDynamicServer(java.lang.String serverId, java.lang.String address, int port)
          Adds a dynamic server
 void addServer(ClusterServer server)
          Adds cluster server
 void close()
          Closes the servers in the triad.
abstract  ClusterServer createServer()
          Creates a cluster server
 ClusterServer findServer(int index)
          Finds the matching server.
 ClusterServer findServer(java.lang.String id)
          Finds the first server with the given id
 ClusterServer findServer(java.lang.String address, int port)
          Finds the first server with the given address and port
 ClusterServer findServerByPrefix(java.lang.String id)
          Finds the first server with the given id
 ClusterServer getActiveOrSelfServer(ClusterPod.Owner owner, ClusterServer oldServer)
          Returns the best primary or secondary triad server.
 ClusterServer getActiveServer(ClusterPod.Owner owner, ClusterServer oldServer)
          Returns the best primary or secondary triad server.
 Cluster getCluster()
          Returns the triad's cluster
 java.lang.String getId()
          Returns the triad id.
 int getIndex()
          Returns the triad index.
static ClusterPod.Owner getOwner(long index)
          Returns the owner for an index
abstract  OwnerServerTriad getOwnerServerTriad(ClusterPod.Owner owner)
          Returns the OwnerServerTriad for the given owner.
 ClusterServer getPrimary(ClusterPod.Owner owner)
          Returns the primary server given an ownership tag.
 ClusterServer getSecondary(ClusterPod.Owner owner)
          Returns the secondary server given an ownership tag.
abstract  ClusterServer getServerA()
          Returns the triad's first server
abstract  ClusterServer getServerB()
          Returns the triad's second server
abstract  ClusterServer getServerC()
          Returns the triad's third server
abstract  ClusterServer[] getServerList()
          Return the servers statically configured in the triad
abstract  java.util.ArrayList<ClusterServer> getStaticServerList()
          Return the servers statically configured in the triad
 ClusterServer getTertiary(ClusterPod.Owner owner)
          Returns the tertiary server given an ownership tag.
 void init()
          Initializes the servers in the triad.
 boolean isTriad(ClusterServer server)
          Returns true for any of the triad servers.
 void removeDynamicServer(java.lang.String serverId, java.lang.String address, int port)
          Remove a dynamic server
 ClusterServer setActiveDynamicServer(java.lang.String serverId, java.lang.String address, int port, int index)
          Sets the active dynamic server
 void start()
           
 java.lang.String toString()
           
 void update()
          Update for dynamic server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OWNER_VALUES

public static final ClusterPod.Owner[] OWNER_VALUES
Constructor Detail

ClusterPod

protected ClusterPod(Cluster cluster,
                     int index)
Creates a new triad for the cluster.

Parameters:
cluster - the owning cluster
index - the triad index
Method Detail

getId

public java.lang.String getId()
Returns the triad id.


getIndex

public int getIndex()
Returns the triad index.


getCluster

public Cluster getCluster()
Returns the triad's cluster


getServerList

public abstract ClusterServer[] getServerList()
Return the servers statically configured in the triad


getStaticServerList

public abstract java.util.ArrayList<ClusterServer> getStaticServerList()
Return the servers statically configured in the triad


getServerA

public abstract ClusterServer getServerA()
Returns the triad's first server

Returns:
the first server.

getServerB

public abstract ClusterServer getServerB()
Returns the triad's second server

Returns:
the second server.

getServerC

public abstract ClusterServer getServerC()
Returns the triad's third server

Returns:
the third server.

isTriad

public boolean isTriad(ClusterServer server)
Returns true for any of the triad servers.


findServer

public ClusterServer findServer(int index)
Finds the matching server.


createServer

public abstract ClusterServer createServer()
Creates a cluster server


addServer

public void addServer(ClusterServer server)
Adds cluster server


addDynamicServer

public void addDynamicServer(java.lang.String serverId,
                             java.lang.String address,
                             int port)
                      throws ConfigException
Adds a dynamic server

Throws:
ConfigException

removeDynamicServer

public void removeDynamicServer(java.lang.String serverId,
                                java.lang.String address,
                                int port)
                         throws ConfigException
Remove a dynamic server

Throws:
ConfigException

setActiveDynamicServer

public ClusterServer setActiveDynamicServer(java.lang.String serverId,
                                            java.lang.String address,
                                            int port,
                                            int index)
                                     throws ConfigException
Sets the active dynamic server

Throws:
ConfigException

init

public void init()
Initializes the servers in the triad.


start

public void start()

update

public void update()
Update for dynamic server


close

public void close()
Closes the servers in the triad.


findServer

public ClusterServer findServer(java.lang.String id)
Finds the first server with the given id


findServerByPrefix

public ClusterServer findServerByPrefix(java.lang.String id)
Finds the first server with the given id


findServer

public ClusterServer findServer(java.lang.String address,
                                int port)
Finds the first server with the given address and port


getOwnerServerTriad

public abstract OwnerServerTriad getOwnerServerTriad(ClusterPod.Owner owner)
Returns the OwnerServerTriad for the given owner.


getPrimary

public ClusterServer getPrimary(ClusterPod.Owner owner)
Returns the primary server given an ownership tag.


getSecondary

public ClusterServer getSecondary(ClusterPod.Owner owner)
Returns the secondary server given an ownership tag. If the triad has only one server, return null.


getTertiary

public ClusterServer getTertiary(ClusterPod.Owner owner)
Returns the tertiary server given an ownership tag. If the server has only 2 servers, return null.


getActiveServer

public ClusterServer getActiveServer(ClusterPod.Owner owner,
                                     ClusterServer oldServer)
Returns the best primary or secondary triad server.


getActiveOrSelfServer

public ClusterServer getActiveOrSelfServer(ClusterPod.Owner owner,
                                           ClusterServer oldServer)
Returns the best primary or secondary triad server.


getOwner

public static ClusterPod.Owner getOwner(long index)
Returns the owner for an index


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object