edu.vub.at.actors.net.cmd
Class VMCommand

java.lang.Object
  extended byedu.vub.at.actors.net.cmd.VMCommand
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CMDHandshake, CMDInitRequireServices, CMDJoinServices, CMDProvideService, CMDRequireService, CMDTransmitATMessage

public abstract class VMCommand
extends java.lang.Object
implements java.io.Serializable

VM Command objects are the message objects that AT/2 virtual machines send to one another. They are control objects sent by one VM and received by another. The receiving VM executes the VM Command object's uponReceiptBy method, which allows the command object to encapsulate the reception code itself. By convention, all VM Command classes are prefixed with CMD.

Author:
tvcutsem
See Also:
Serialized Form

Field Summary
static int _TRANSMISSION_TIMEOUT_
          the default transmission timeout for JGroups synchronous message communication
private  java.lang.String description_
           
 
Constructor Summary
VMCommand(java.lang.String descr)
           
 
Method Summary
protected  void sendAsyncMulticast(org.jgroups.blocks.MessageDispatcher dispatcher)
          Sends this VM Command object asynchronously to all connected VMs.
protected  void sendAsyncUnicast(org.jgroups.blocks.MessageDispatcher dispatcher, org.jgroups.Address recipientVM)
          Sends this VM Command object asynchronously to the recipient VM.
protected  java.lang.Object sendSynchronousUnicast(org.jgroups.blocks.MessageDispatcher dispatcher, org.jgroups.Address recipientVM)
          Sends this VM Command object synchronously to the recipient VM.
 java.lang.String toString()
           
abstract  java.lang.Object uponReceiptBy(ELVirtualMachine remoteHost, org.jgroups.Message wrapper)
          To be overridden by subclasses to specify the behaviour to execute upon reception and execution of the command object at the recipient VM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

description_

private final java.lang.String description_

_TRANSMISSION_TIMEOUT_

public static final int _TRANSMISSION_TIMEOUT_
the default transmission timeout for JGroups synchronous message communication

See Also:
Constant Field Values
Constructor Detail

VMCommand

public VMCommand(java.lang.String descr)
Parameters:
descr - for debugging purposes
Method Detail

toString

public java.lang.String toString()

uponReceiptBy

public abstract java.lang.Object uponReceiptBy(ELVirtualMachine remoteHost,
                                               org.jgroups.Message wrapper)
                                        throws java.lang.Exception
To be overridden by subclasses to specify the behaviour to execute upon reception and execution of the command object at the recipient VM. This code is still executed in a JGroups thread!

Parameters:
remoteHost - the host at which the command arrived and is executed
wrapper - the JGroups message wrapper that was used to transport this command object
Throws:
java.lang.Exception

sendAsyncUnicast

protected void sendAsyncUnicast(org.jgroups.blocks.MessageDispatcher dispatcher,
                                org.jgroups.Address recipientVM)
                         throws org.jgroups.TimeoutException,
                                org.jgroups.SuspectedException
Sends this VM Command object asynchronously to the recipient VM.

Throws:
org.jgroups.TimeoutException
org.jgroups.SuspectedException

sendAsyncMulticast

protected void sendAsyncMulticast(org.jgroups.blocks.MessageDispatcher dispatcher)
                           throws org.jgroups.TimeoutException,
                                  org.jgroups.SuspectedException
Sends this VM Command object asynchronously to all connected VMs.

Throws:
org.jgroups.TimeoutException
org.jgroups.SuspectedException

sendSynchronousUnicast

protected java.lang.Object sendSynchronousUnicast(org.jgroups.blocks.MessageDispatcher dispatcher,
                                                  org.jgroups.Address recipientVM)
                                           throws org.jgroups.TimeoutException,
                                                  org.jgroups.SuspectedException
Sends this VM Command object synchronously to the recipient VM. The recipient's address must be given, null is not allowed (i.e. broadcasting synchronously is not allowed)

Throws:
org.jgroups.TimeoutException
org.jgroups.SuspectedException