jrunx.cluster
Class AbstractBuddyAlgorithm

java.lang.Object
  |
  +--jrunx.cluster.ClusterAlgorithm
        |
        +--jrunx.cluster.AbstractBuddyAlgorithm
All Implemented Interfaces:
ClusterConstants, java.io.Serializable
Direct Known Subclasses:
BuddyAlgorithm, StatefulBuddyAlgorithm

public abstract class AbstractBuddyAlgorithm
extends ClusterAlgorithm
implements java.io.Serializable

This algorithm treats one ClusterableService as the primary service, and invokes all methods on it. It also maintains a secondary stub, which will become the primary in the event of a primary RemoteException on the original primary.
Stateful session EJBObjects make use of this algorithm in conjunction with a container interceptor that ensures instance information is transferred from the primary to the secondary upon every method invocation. If the secondary has become the primary, then the interceptor also chooses a new secondary, if possible. The interceptor must choose the secondary because only it can transfer enough the state information.
A new instance is NOT created in the secondary container, ever. Should the secondary become the primary, then the interceptor creates a new instance for that new primary based on the stored instance state snapshot it has received.
If the instance is involved in a transaction when it passes through the interceptor, the transfer of state does NOT occur. In this case, failing over to a secondary will be similar to suffering a rollback, in that any uncommitted changes to a primary instance will not be available.

Author:
PS Neville
See Also:
Serialized Form

Field Summary
 ClusterableService primary
           
 ClusterableService secondary
           
 
Fields inherited from class jrunx.cluster.ClusterAlgorithm
rand
 
Fields inherited from interface jrunx.cluster.ClusterConstants
AVAILABLE_SERVICES, CLUSTER_MANAGER_JNDI, DEFAULT_CLUSTER_DOMAIN, DEFAULT_ENABLED, JINI_CODE_BASE_JAR, PRIMARY_SERVICE, SECONDARY_SERVICE
 
Constructor Summary
AbstractBuddyAlgorithm()
           
AbstractBuddyAlgorithm(java.util.ArrayList services)
           
AbstractBuddyAlgorithm(ClusterableService primary, java.util.ArrayList services)
           
 
Method Summary
abstract  ClusterableService getBuddy(java.util.ArrayList services, ClusterableService primary)
           
 ClusterableService selectService(java.util.ArrayList services)
           
 
Methods inherited from class jrunx.cluster.ClusterAlgorithm
chooseRandom, chooseRandom, chooseStub, getPrefered, invokeService, invokeService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

primary

public ClusterableService primary

secondary

public ClusterableService secondary
Constructor Detail

AbstractBuddyAlgorithm

public AbstractBuddyAlgorithm()

AbstractBuddyAlgorithm

public AbstractBuddyAlgorithm(java.util.ArrayList services)

AbstractBuddyAlgorithm

public AbstractBuddyAlgorithm(ClusterableService primary,
                              java.util.ArrayList services)
Method Detail

selectService

public ClusterableService selectService(java.util.ArrayList services)
                                 throws java.rmi.RemoteException
Overrides:
selectService in class ClusterAlgorithm

getBuddy

public abstract ClusterableService getBuddy(java.util.ArrayList services,
                                            ClusterableService primary)


Copyright © 2002 Macromedia Corporation. All Rights Reserved.