aa.core
Class MigrationManager

java.lang.Object
  extended byjava.lang.Thread
      extended byaa.tool.SystemThread
          extended byaa.core.MigrationManager
All Implemented Interfaces:
java.lang.Runnable

public class MigrationManager
extends SystemThread

This class specifies a Migration Manger to handle mobile actors.

History:

Version:
$Date: 2008/01/01 00:23:47 $ $Revision: 1.1 $
Author:
Myeong-Wuk Jang

Field Summary
private  ActorManager m_amActorManager
          The reference to the Actor Manager of this actor platform.
private  ActorName m_anPlatform
          The actor name of this actor platform.
private  DelayedMessageManager m_dmmDelayedMessageManager
          The reference to the Delayed Message Manager of this actor platform.
private  MessageManager m_mmMessageManager
          The reference to the Message Manager of this actor platform.
private  Platform m_pPlatform
          The reference to this actor platform.
private  java.lang.String m_strHostAddressOfPlatform
          The host address of this platform.
private  java.util.TreeMap m_tmMobileActorClasses
          The class data repository for mobile actors.
 
Fields inherited from class aa.tool.SystemThread
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MigrationManager(Platform p_pPlatform, ActorManager p_amActorManager)
          Creates a Migration Manager.
 
Method Summary
private  java.lang.Object deserialize(java.lang.String p_strClassName, byte[] pp_baClass, byte[] p_baStream)
          Deserialize a byte stream into an object.
private  byte[] fetchClassFile(java.lang.String p_strClassName)
          Fetches the byte array of the specified class.
protected  void informMigrationEnd(ActorName p_anActor, java.lang.String p_strHostAddress)
          Informs that migration of a mobile actor ends.
protected  void informMigrationStart(ActorName p_anActor, java.lang.String p_strHostAddress)
          Informs that migration of a mobile actor starts.
protected  void init()
          Processes some necessay routines before entering the main loop in the 'run' method.
protected  void migrateActor(ActorName p_anActor, java.net.InetAddress p_iaDestHost)
          Moves the specified actor to another host.
protected  void processMessage(ActorMessage p_amMsg)
          Processes a communication messages.
private  void reactivateActor(ActorThread p_athread)
          Reactivates a mobile actor.
protected  void receiveActor(java.lang.String p_strClassName, byte[] p_baClass, byte[] p_baActor, ActorName p_anPlatform)
          Receives an actor.
private  void sendErrorMessage(ActorName p_anReceiver, java.lang.String p_strMsg)
          Sends an error message.
private  byte[] serialize(java.io.Serializable p_serObj)
          Serializes an object into a byte stream.
protected  void setDelayedMessageManager(DelayedMessageManager p_dmm)
          Sets the reference to the Delayed Message Manager.
protected  void setMessageManager(MessageManager p_mm)
          Sets the reference to the Message Manager.
protected  void uninit()
          Uninitializes this component.
 
Methods inherited from class aa.tool.SystemThread
deliverMessage, run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_strHostAddressOfPlatform

private java.lang.String m_strHostAddressOfPlatform
The host address of this platform.


m_anPlatform

private ActorName m_anPlatform
The actor name of this actor platform.


m_tmMobileActorClasses

private java.util.TreeMap m_tmMobileActorClasses
The class data repository for mobile actors.


m_pPlatform

private Platform m_pPlatform
The reference to this actor platform.


m_amActorManager

private ActorManager m_amActorManager
The reference to the Actor Manager of this actor platform.


m_mmMessageManager

private MessageManager m_mmMessageManager
The reference to the Message Manager of this actor platform.


m_dmmDelayedMessageManager

private DelayedMessageManager m_dmmDelayedMessageManager
The reference to the Delayed Message Manager of this actor platform.

Constructor Detail

MigrationManager

public MigrationManager(Platform p_pPlatform,
                        ActorManager p_amActorManager)
Creates a Migration Manager.

Parameters:
p_pPlatform - the reference to this platform.
p_amActorManager - the reference to an Actor Manager.
Method Detail

init

protected void init()
Processes some necessay routines before entering the main loop in the 'run' method.
This is called by the 'run' method of the super-class (SystemThread).

Specified by:
init in class SystemThread

uninit

protected void uninit()
Uninitializes this component.
This method is called by the Actor Manager.


setMessageManager

protected void setMessageManager(MessageManager p_mm)
Sets the reference to the Message Manager.
This method is called by the Message Manager.

Parameters:
p_mm - the reference to the Message Manager.

setDelayedMessageManager

protected void setDelayedMessageManager(DelayedMessageManager p_dmm)
Sets the reference to the Delayed Message Manager.
This method is called by the Delayed Message Manager.

Parameters:
p_dmm - the reference to the Delayed Message Manager.

processMessage

protected void processMessage(ActorMessage p_amMsg)
Processes a communication messages.
The messages for the Migration Manager are delivered from the Actor Manager of this actor platform.

Specified by:
processMessage in class SystemThread
Parameters:
p_amMsg - an actor communication message.

sendErrorMessage

private void sendErrorMessage(ActorName p_anReceiver,
                              java.lang.String p_strMsg)
Sends an error message.

Parameters:
p_anReceiver - the name of the receiver actor.
p_strMsg - an error message.

fetchClassFile

private byte[] fetchClassFile(java.lang.String p_strClassName)
                       throws java.lang.ClassNotFoundException
Fetches the byte array of the specified class.

Parameters:
p_strClassName - the name of the specified class.
Returns:
the bytes of the class.
Throws:
java.lang.ClassNotFoundException - throw when the system cannot find the class.

serialize

private byte[] serialize(java.io.Serializable p_serObj)
                  throws java.io.IOException
Serializes an object into a byte stream.

Parameters:
p_serObj - the input serializable object.
Returns:
a byte stream corresponding to the specified object.
Throws:
java.io.IOException

deserialize

private java.lang.Object deserialize(java.lang.String p_strClassName,
                                     byte[] pp_baClass,
                                     byte[] p_baStream)
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
Deserialize a byte stream into an object.

Parameters:
p_strClassName - the name of the specified class.
pp_baClass - the input byte stream for the class information.
p_baStream - the input byte stream for an instance of the class.
Returns:
an object corresponding to the specified byte stream.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

reactivateActor

private void reactivateActor(ActorThread p_athread)
Reactivates a mobile actor.

Parameters:
p_athread - the reference to an Actor class.

migrateActor

protected void migrateActor(ActorName p_anActor,
                            java.net.InetAddress p_iaDestHost)
                     throws MigrateActorException
Moves the specified actor to another host.
This method is controlled by an actor thread.

Parameters:
p_anActor - the name of an actor to be moved.
p_iaDestHost - the Internet address of the destination host.
Throws:
MigrateActorException - it occurs when an exception happens during the actor migration.

receiveActor

protected void receiveActor(java.lang.String p_strClassName,
                            byte[] p_baClass,
                            byte[] p_baActor,
                            ActorName p_anPlatform)
Receives an actor.
This method is controlled by the Platform class.

Parameters:
p_strClassName - the class name of a mobile actor.
p_baClass - an input byte stream of the class.
p_baActor - an input byte stream of the actor.
p_anPlatform - the actor name of this platform.

informMigrationStart

protected void informMigrationStart(ActorName p_anActor,
                                    java.lang.String p_strHostAddress)
Informs that migration of a mobile actor starts.
This method is controlled by the Platform class.

Parameters:
p_anActor - the name of a mobile actor.

informMigrationEnd

protected void informMigrationEnd(ActorName p_anActor,
                                  java.lang.String p_strHostAddress)
Informs that migration of a mobile actor ends.
This method is controlled by the Platform class.

Parameters:
p_anActor - the name of a mobile actor.