protocols
Class VSAbstractProtocol

java.lang.Object
  extended by prefs.VSPrefs
      extended by prefs.VSSerializablePrefs
          extended by events.VSAbstractEvent
              extended by protocols.VSAbstractProtocol
All Implemented Interfaces:
VSSerializable
Direct Known Subclasses:
VSBasicMulticastProtocol, VSBerkelyTimeProtocol, VSBroadcastProtocol, VSDummyProtocol, VSExternalTimeSyncProtocol, VSInternalTimeSyncProtocol, VSOnePhaseCommitProtocol, VSPingPongProtocol, VSReliableMulticastProtocol, VSTwoPhaseCommitProtocol

public abstract class VSAbstractProtocol
extends VSAbstractEvent

The class VSAbstractProtocol, this class defined the basic framework of a protocol.

Author:
Paul C. Buetow

Field Summary
protected static boolean HAS_ON_CLIENT_START
          The protocol has an onClientStart method
protected static boolean HAS_ON_SERVER_START
          The protocol has an onServerStart method
 
Fields inherited from class events.VSAbstractEvent
prefs, process
 
Fields inherited from class prefs.VSPrefs
BOOLEAN_PREFIX, COLOR_PREFIX, FLOAT_PREFIX, id, INTEGER_PREFIX, LONG_PREFIX, STRING_PREFIX, VECTOR_PREFIX
 
Constructor Summary
VSAbstractProtocol(boolean hasOnServerStart)
          A simple constructor.
 
Method Summary
 void currentContextIsServer(boolean currentContextIsServer)
          Sets if the current context is server.
 void deserialize(VSSerialize serialize, java.io.ObjectInputStream objectInputStream)
          Deserializes
 int getNumProcesses()
          Gets the num processes.
 boolean hasOnServerStart()
          Checks how the protocol will start
 boolean isClient()
          Checks if is client.
 void isClient(boolean isClient)
          Sets if is client.
 boolean isRelevantMessage(VSMessage message)
          Check's if its a relevant message.
 boolean isServer()
          Checks if is server.
 void isServer(boolean isServer)
          Sets if is server.
abstract  void onClientInit()
          On client init.
abstract  void onClientRecv(VSMessage message)
          On client recv.
abstract  void onClientReset()
          On client reset.
abstract  void onClientSchedule()
          On client schedule.
 void onClientScheduleStart()
          Runs a client schedule
 void onClientStart()
          On client start.
 void onInit()
          Every event has its own initialize method.
 void onMessageRecvStart(VSMessage message)
          On message recv.
abstract  void onServerInit()
          On server init.
abstract  void onServerRecv(VSMessage message)
          On server recv.
abstract  void onServerReset()
          On server reset.
abstract  void onServerSchedule()
          On server schedule.
 void onServerScheduleStart()
          Runs a server schedule
 void onServerStart()
          On server start.
 void onStart()
          Every event can get started.
 void removeSchedules()
          Removes all schedules of the protocol (server or client)
 void reset()
          Resets the protocol.
 void scheduleAt(long time)
          Reschedules the protocol for a new time and runs onClientSchedule or onServerSchedule
 void sendMessage(VSMessage message)
          Sends a message.
 void serialize(VSSerialize serialize, java.io.ObjectOutputStream objectOutputStream)
          Serializes
 java.lang.String toString()
           
 
Methods inherited from class events.VSAbstractEvent
equals, getClassname, getCopy, getCopy, getName, getProcess, getShortname, init, init, log, setClassname, setShortname
 
Methods inherited from class prefs.VSPrefs
clear, copyBooleans, copyColors, copyFloats, copyIntegers, copyLongs, copyStrings, deserialize_, getAllFullKeys, getBoolean, getBooleanKeySet, getBooleanObj, getColor, getColorKeySet, getDescription, getFloat, getFloatKeySet, getFloatObj, getID, getInteger, getIntegerKeySet, getIntegerObj, getLong, getLongKeySet, getLongObj, getObject, getRestriction, getString, getStringKeySet, getUnit, getVector, getVectorKeySet, initBoolean, initBoolean, initBoolean, initColor, initColor, initDescription, initFloat, initFloat, initFloat, initFloat, initInteger, initInteger, initInteger, initInteger, initInteger, initInteger, initLong, initLong, initLong, initLong, initRestriction, initString, initString, initUnit, initVector, initVector, initVector, isEmpty, objectExists, removeObject, serialize_, setBoolean, setBoolean, setColor, setFloat, setFloat, setInteger, setInteger, setLong, setLong, setObject, setString, setVector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HAS_ON_SERVER_START

protected static final boolean HAS_ON_SERVER_START
The protocol has an onServerStart method

See Also:
Constant Field Values

HAS_ON_CLIENT_START

protected static final boolean HAS_ON_CLIENT_START
The protocol has an onClientStart method

See Also:
Constant Field Values
Constructor Detail

VSAbstractProtocol

public VSAbstractProtocol(boolean hasOnServerStart)
A simple constructor.

Parameters:
hasOnServerStart - true, if the protocol uses an onServerStart method. false, if the protocol uses an onClientStart method instead.
Method Detail

sendMessage

public void sendMessage(VSMessage message)
Sends a message.

Parameters:
message - the message to send

onStart

public final void onStart()
Description copied from class: VSAbstractEvent
Every event can get started. This method get's executed if the event takes place.

Specified by:
onStart in class VSAbstractEvent

onInit

public final void onInit()
Description copied from class: VSAbstractEvent
Every event has its own initialize method.

Specified by:
onInit in class VSAbstractEvent

onClientScheduleStart

public final void onClientScheduleStart()
Runs a client schedule


onServerScheduleStart

public final void onServerScheduleStart()
Runs a server schedule


onMessageRecvStart

public final void onMessageRecvStart(VSMessage message)
On message recv.

Parameters:
message - the message

isRelevantMessage

public final boolean isRelevantMessage(VSMessage message)
Check's if its a relevant message.

Parameters:
message - the message to check
Returns:
true, if it's a relevant meessage. false if the protocol is wrong or if the server recv a server message/the client recv a client message. Clients should only recv server messages and servers should only recv client messages.

currentContextIsServer

public final void currentContextIsServer(boolean currentContextIsServer)
Sets if the current context is server.

Parameters:
currentContextIsServer - the context.

hasOnServerStart

public final boolean hasOnServerStart()
Checks how the protocol will start

Returns:
true, if this protocol uses onServerStart instead of onClientStart

isServer

public final void isServer(boolean isServer)
Sets if is server.

Parameters:
isServer - the is server

isServer

public final boolean isServer()
Checks if is server.

Returns:
true, if the protocol has activated the server part

isClient

public final void isClient(boolean isClient)
Sets if is client.

Parameters:
isClient - the is client

isClient

public final boolean isClient()
Checks if is client.

Returns:
true, if the protocol has activated the client part

reset

public void reset()
Resets the protocol.


scheduleAt

public final void scheduleAt(long time)
Reschedules the protocol for a new time and runs onClientSchedule or onServerSchedule

Parameters:
time - The process' local time to run the schedule at.

removeSchedules

public final void removeSchedules()
Removes all schedules of the protocol (server or client)


onClientInit

public abstract void onClientInit()
On client init.


onClientStart

public void onClientStart()
On client start.


onClientReset

public abstract void onClientReset()
On client reset.


onClientSchedule

public abstract void onClientSchedule()
On client schedule.


onClientRecv

public abstract void onClientRecv(VSMessage message)
On client recv.

Parameters:
message - the message

onServerInit

public abstract void onServerInit()
On server init.


onServerStart

public void onServerStart()
On server start.


onServerReset

public abstract void onServerReset()
On server reset.


onServerRecv

public abstract void onServerRecv(VSMessage message)
On server recv.

Parameters:
message - the message

onServerSchedule

public abstract void onServerSchedule()
On server schedule.


getNumProcesses

public final int getNumProcesses()
Gets the num processes.

Returns:
the num processes

toString

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

serialize

public void serialize(VSSerialize serialize,
                      java.io.ObjectOutputStream objectOutputStream)
               throws java.io.IOException
Description copied from interface: VSSerializable
Serializes

Specified by:
serialize in interface VSSerializable
Overrides:
serialize in class VSAbstractEvent
Parameters:
serialize - The serialize object
objectOutputStream - The object output stream
Throws:
java.io.IOException

deserialize

public void deserialize(VSSerialize serialize,
                        java.io.ObjectInputStream objectInputStream)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Description copied from interface: VSSerializable
Deserializes

Specified by:
deserialize in interface VSSerializable
Overrides:
deserialize in class VSAbstractEvent
Parameters:
serialize - The serialize object
objectInputStream - The object input stream
Throws:
java.io.IOException
java.lang.ClassNotFoundException