org.objectweb.carol.cmi
Class Distributor

java.lang.Object
  extended byorg.objectweb.carol.cmi.Distributor
Direct Known Subclasses:
DistributorHome, DistributorSfsbHome, DistributorSfsbRemote, DistributorSlsbRemote

public abstract class Distributor
extends java.lang.Object

Each clustered server object has to be accompanied by a class which extends this one to specify configuration information. It specifies how the replicates will be accessed by the clients, and how replicates are recognized in the cluster.

For CMI to load this configuration, the class has to be named under the form : full.ServerClass_Cmi

It must provide a constructor without parameter. The results should be constant in the cluster so that each server and client uses the same configuration.

Author:
Simon Nieuviarts, Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es), Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es)

Constructor Summary
Distributor()
          Default constructor
 
Method Summary
 StubData choose(java.lang.reflect.Method method, java.lang.Object[] parameters)
          Choose a stub among the stub list Default algorithm : round robin The application deployer can override this method to make its own choices.
 StubData chooseLocalFirst(java.lang.reflect.Method method, java.lang.Object[] parameters)
          Choose a stub among the stub list with a local preference The application deployer can override this method to make its own choices.
abstract  boolean equivAtBind()
          To be overriden
abstract  boolean equivAtExport()
          To be overriden
protected  java.util.Set getCurrentState()
          Get the current state of the stubs
 ClusterId getMyServerId()
          Get the local server id
 ServerStubList getStubList()
          Get the stub list
 Decision onException(java.lang.reflect.Method method, java.lang.Object[] parameters, StubData sd, java.lang.Exception ex)
          Decision on Exception - retry on ConnectException or ConnectIOException or NoSuchObjectException The application deployer can override this method to make its own choices.
 Decision onReturn(java.lang.reflect.Method method, java.lang.Object[] parameters, StubData sd, java.lang.Object retVal)
          Decision on return - do nothing The application deployer can override this method to make its own choices.
 void preInvoke(java.lang.reflect.Method method, java.lang.Object[] parameters)
          Callback invoked just before the method call The application deployer can override this method
 void read(java.io.ObjectInput in)
          Read the specific distributor data
protected  void removeStub(ClusterId serverId)
          Remove a stub in the list by its serverId
protected  void removeStub(StubData sd)
          Remove a stub in the list
 java.lang.String toContentsString()
          Build a readable view of the stub list
 java.lang.String toString()
           
 void write(java.io.ObjectOutput out)
          Write the specific distributor data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Distributor

public Distributor()
Default constructor

Method Detail

getCurrentState

protected java.util.Set getCurrentState()
Get the current state of the stubs

Returns:
set of stubs

removeStub

protected void removeStub(StubData sd)
Remove a stub in the list

Parameters:
sd - stub

removeStub

protected void removeStub(ClusterId serverId)
Remove a stub in the list by its serverId


getStubList

public ServerStubList getStubList()
Get the stub list

Returns:
stub list

getMyServerId

public ClusterId getMyServerId()
Get the local server id

Returns:
ClusterId local server id

equivAtBind

public abstract boolean equivAtBind()
To be overriden

Returns:
true if the bound object have to be clustered

equivAtExport

public abstract boolean equivAtExport()
To be overriden

Returns:
true if the export object have to be clustered

preInvoke

public void preInvoke(java.lang.reflect.Method method,
                      java.lang.Object[] parameters)
Callback invoked just before the method call The application deployer can override this method

Parameters:
method - calling method
parameters - parameters of the calling method

choose

public StubData choose(java.lang.reflect.Method method,
                       java.lang.Object[] parameters)
                throws NoServerException
Choose a stub among the stub list Default algorithm : round robin The application deployer can override this method to make its own choices.

Parameters:
method - calling method
parameters - parameters of the calling method
Returns:
StubData the chosen stub
Throws:
NoServerException - if no server available

chooseLocalFirst

public StubData chooseLocalFirst(java.lang.reflect.Method method,
                                 java.lang.Object[] parameters)
                          throws NoServerException
Choose a stub among the stub list with a local preference The application deployer can override this method to make its own choices.

Parameters:
method - calling method
parameters - parameters of the calling method
Returns:
StubData the chosen stub
Throws:
NoServerException - if no server available

onException

public Decision onException(java.lang.reflect.Method method,
                            java.lang.Object[] parameters,
                            StubData sd,
                            java.lang.Exception ex)
Decision on Exception - retry on ConnectException or ConnectIOException or NoSuchObjectException The application deployer can override this method to make its own choices.

Parameters:
method - calling method
parameters - parameters of the calling method
sd - stub data
ex - exception
Returns:
decision

onReturn

public Decision onReturn(java.lang.reflect.Method method,
                         java.lang.Object[] parameters,
                         StubData sd,
                         java.lang.Object retVal)
Decision on return - do nothing The application deployer can override this method to make its own choices.

Parameters:
method - calling method
parameters - parameters of the calling method
sd - stub data
retVal - return value
Returns:
decision

toContentsString

public java.lang.String toContentsString()
Build a readable view of the stub list

Returns:
string

toString

public java.lang.String toString()
Returns:
readable view of the stub list

write

public void write(java.io.ObjectOutput out)
           throws java.io.IOException
Write the specific distributor data

Parameters:
out - output
Throws:
java.io.IOException - if an I/O error occurs

read

public void read(java.io.ObjectInput in)
          throws java.io.IOException,
                 java.lang.ClassNotFoundException
Read the specific distributor data

Parameters:
in - input
Returns:
ClusterStub server stub list
Throws:
java.io.IOException - if an I/O error occurs
java.lang.ClassNotFoundException - if the expected class can not be created