org.sapia.ubik.rmi.replication
Class ReplicatedCommand

java.lang.Object
  extended by org.sapia.ubik.rmi.server.command.Command
      extended by org.sapia.ubik.rmi.server.RMICommand
          extended by org.sapia.ubik.rmi.server.invocation.InvokeCommand
              extended by org.sapia.ubik.rmi.replication.ReplicatedCommand
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, Executable
Direct Known Subclasses:
ReplicatedCommandEx

public abstract class ReplicatedCommand
extends InvokeCommand

Wraps an InvokeCommand that is intented to be replicated to the different servers in a domain or cluster.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2004 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site
See Also:
#getReplicationContext(), Serialized Form

Field Summary
 
Fields inherited from class org.sapia.ubik.rmi.server.RMICommand
_config, _vmId
 
Constructor Summary
ReplicatedCommand()
          Do not call; used for externalization only.
ReplicatedCommand(InvokeCommand cmd, java.util.Set targets, ReplicatedInvoker invoker, boolean synchronous)
           
 
Method Summary
 void disable()
          Disables replication behavior (this command will execute as a normal InvokeCommand).
 java.lang.Object execute()
          This method's implementation internally calls the getReplicationContext() method.
 ReplicatedInvoker getReplicatedInvoker()
           
protected  java.util.Set getTargetAddresses()
           
protected  java.util.Set getVisitedAddresses()
           
 void readExternal(java.io.ObjectInput in)
           
protected  java.lang.Object send(ServerAddress next)
          This method synchronously or asynchronously sends this instance to the server at the given address.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.sapia.ubik.rmi.server.invocation.InvokeCommand
convertParams, getMethodName, getOID, getParameterTypes, getParams, setParams, usesMarshalledObjects
 
Methods inherited from class org.sapia.ubik.rmi.server.RMICommand
getConnection, getServerAddress, getVmId, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicatedCommand

public ReplicatedCommand()
Do not call; used for externalization only.


ReplicatedCommand

public ReplicatedCommand(InvokeCommand cmd,
                         java.util.Set targets,
                         ReplicatedInvoker invoker,
                         boolean synchronous)
Parameters:
cmd - the InvokeCommand to replicate.
targets - the Set of ServerAddresses that are targeted by the command. If null, then all siblings will be targeted.
invoker - the ReplicatedInvoker implementation in charge of performing replicated method invocations.
Method Detail

execute

public java.lang.Object execute()
                         throws java.lang.Throwable
This method's implementation internally calls the getReplicationContext() method. The returned ReplicationContext is used as a hook to the server in which this command is executed. Internally, the method selects the next server to which this instance should be dispatched, and executes the command that this instance wraps.

If the execution is successful, this instance is dispatched by means of the ReplicationContext.

Specified by:
execute in interface Executable
Overrides:
execute in class InvokeCommand
Returns:
any value returned by this method.
Throws:
java.lang.Throwable - if an error occurs while executing this command
See Also:
#getReplicationContext(), RMICommand.execute()

getReplicatedInvoker

public ReplicatedInvoker getReplicatedInvoker()
Returns:
the ReplicatedInvoker that this instance holds.

disable

public void disable()
Disables replication behavior (this command will execute as a normal InvokeCommand).


readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class InvokeCommand
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
InvokeCommand.readExternal(java.io.ObjectInput)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class InvokeCommand
Throws:
java.io.IOException
See Also:
InvokeCommand.writeExternal(java.io.ObjectOutput)

send

protected java.lang.Object send(ServerAddress next)
                         throws java.rmi.RemoteException
This method synchronously or asynchronously sends this instance to the server at the given address.

Parameters:
next - the ServerAddress of the "next" server to which this instance should be sent.
Returns:
the result of the invocation.
Throws:
java.rmi.RemoteException - if a problem occurs sending this instance.

getVisitedAddresses

protected java.util.Set getVisitedAddresses()

getTargetAddresses

protected java.util.Set getTargetAddresses()


Copyright © 2010 Sapia OSS. All Rights Reserved.