aa.core
Class CyberOrgManager

java.lang.Object
  extended byaa.core.CyberOrgManager

public class CyberOrgManager
extends java.lang.Object

Author:
xinghuizhao

Field Summary
private  java.util.Hashtable m_htActorHost
           
private  java.util.Hashtable m_htActornameThread
           
private  long m_lLargestSlice
           
private  java.util.LinkedList m_llCyberOrgs
           
private  long m_lScheduleLargest
           
private  long m_lScheduleSmallest
           
private  Platform m_pPlatform
           
private  SchedulerManager m_smSchedulerManager
           
 
Constructor Summary
CyberOrgManager(long p_lScheduleSmallest, long p_lScheduleLargest)
          Creates a new instance of CyberOrgManager
 
Method Summary
private  long accept(long p_lRateAssign)
          Called by resAlloc when it is trying to accept small request
 void afterMigrateActor(ActorName p_anActor, java.lang.Thread p_thread)
          This method is called in remote CyberOrg Migration, after migrating an actor,
we need to insert it to the destination cyberorg, reallocate resource to it through the local scheduler
private  byte[] convertAddrIP(java.lang.String p_strAddress)
          Concert texture IP address to byte array in order to get the InetAddress
 void createActor(ActorName p_anCreator, ActorName p_anNewActor)
          This method is called by the Platform, when an actor is creating another new actor.
 void disactiveCyberOrg(CyberOrg p_cybToDisactive)
          Disactivate a cyberorg when it runs out of resources
 void localMigrate(CyberOrg p_cybToMigrate, ActorName p_anDestFacilitator, Contract p_conContract)
          Local Migration
 CyberOrg lookupDestination()
          This method is called by facilitator actors before migration.
 CyberOrg lookupHost(java.lang.Object p_objFacilitator)
          This method is called after remote migration, in order to set host for the migrated facilitator
 void reactiveCyberOrg(CyberOrg p_cybToActive)
          These method are called when a cyberorg runs out of resource, and when it gets more resources and can be scheduled again.
 void registerActorCyb(java.lang.Object p_anActor, CyberOrg p_cybHost)
          Register actor-host.
 void registerCyberOrg(CyberOrg p_coToBeRegistered)
          Register a cyberorg to the current platform
 void registerThread(ActorName p_anActor, java.lang.Thread p_thread)
          The method is called by Platform in "creatActor".
 void remoteMigrate(CyberOrg p_cybToMigrate, ActorName p_anDestFacilitator, Contract p_conContract)
          Remote Migration
 void remoteMigrateChild(ActorName p_anFacilitator)
          In remote migration, only after we receive the reply message from the destination,
which means the new cyberorg is already created in the destination platform,
can we migrate actors and child cyberorgs of the migrating cyberorg
 void removeActor(ActorName p_anActor)
          Called when an actor is destroyed
 void removeCyberOrg(CyberOrg p_coToBeDeleted)
          Removes a cyberorg from the current platform
 boolean resAlloc(ActorName p_anToAlloc, long rateAssign)
          Reallocate resource for an actor
the actor already exists in the scheduler
 long returnRes(ActorName p_anActor)
          Returns the ticksRate of specific actor
called by cyberorg primitives
private  void scaleupCyberOrgs(long p_lfactor)
          Scale up the granularity control
 long updateTotalTicks()
          Called by scheduler after every scheduling cycle, for total time control
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_smSchedulerManager

private SchedulerManager m_smSchedulerManager

m_htActornameThread

private java.util.Hashtable m_htActornameThread

m_htActorHost

private java.util.Hashtable m_htActorHost

m_llCyberOrgs

private java.util.LinkedList m_llCyberOrgs

m_lLargestSlice

private long m_lLargestSlice

m_lScheduleSmallest

private long m_lScheduleSmallest

m_lScheduleLargest

private long m_lScheduleLargest

m_pPlatform

private Platform m_pPlatform
Constructor Detail

CyberOrgManager

public CyberOrgManager(long p_lScheduleSmallest,
                       long p_lScheduleLargest)
Creates a new instance of CyberOrgManager

Method Detail

returnRes

public long returnRes(ActorName p_anActor)
Returns the ticksRate of specific actor
called by cyberorg primitives

Parameters:
p_anActor - The name of the actor which returns resources
Returns:
The amountn of resources being returned

resAlloc

public boolean resAlloc(ActorName p_anToAlloc,
                        long rateAssign)
Reallocate resource for an actor
the actor already exists in the scheduler

Parameters:
p_anToAlloc - The actor name
rateAssign - The resources being allocated to the given actor
Returns:

accept

private long accept(long p_lRateAssign)
Called by resAlloc when it is trying to accept small request

Parameters:
p_lRateAssign - The small request
Returns:
The factor that is used to enlarge the control granularity

registerCyberOrg

public void registerCyberOrg(CyberOrg p_coToBeRegistered)
Register a cyberorg to the current platform

Parameters:
p_coToBeRegistered - The cyberorg being registered

removeCyberOrg

public void removeCyberOrg(CyberOrg p_coToBeDeleted)
Removes a cyberorg from the current platform

Parameters:
p_coToBeDeleted - The cyberorg being removed

scaleupCyberOrgs

private void scaleupCyberOrgs(long p_lfactor)
Scale up the granularity control

Parameters:
p_lfactor - The factor by which the granularity is scaled up

createActor

public void createActor(ActorName p_anCreator,
                        ActorName p_anNewActor)
This method is called by the Platform, when an actor is creating another new actor.
After the creation, this method is called in order to put the new actor into the cyberorg that the creator is in,
and assign resource to it according to the local resource distribution policy of the specific cyberorg

Parameters:
p_anCreator - The name of the creator
p_anNewActor - The name of the new actor

registerThread

public void registerThread(ActorName p_anActor,
                           java.lang.Thread p_thread)
The method is called by Platform in "creatActor".
when an actor is created, we map the actor name to the thread
we may look up this hashtable to get thread according to ActorName, and change resource allocatioin in scheduler which only knows threads.

Parameters:
p_anActor - The name of the actor being registered
p_thread - The thread representing the actor

localMigrate

public void localMigrate(CyberOrg p_cybToMigrate,
                         ActorName p_anDestFacilitator,
                         Contract p_conContract)
Local Migration

Parameters:
p_cybToMigrate - The cyberorg which is migrating
p_anDestFacilitator - The facilitator actor of the destination cyberorg
p_conContract - The new contract

remoteMigrate

public void remoteMigrate(CyberOrg p_cybToMigrate,
                          ActorName p_anDestFacilitator,
                          Contract p_conContract)
Remote Migration

Parameters:
p_cybToMigrate - The cyberorg which is migrating
p_anDestFacilitator - The destination (on another CyberOrgs platform)
p_conContract - The new contract

remoteMigrateChild

public void remoteMigrateChild(ActorName p_anFacilitator)
In remote migration, only after we receive the reply message from the destination,
which means the new cyberorg is already created in the destination platform,
can we migrate actors and child cyberorgs of the migrating cyberorg

Parameters:
p_anFacilitator - The facilitator of the migrating cyberorg

convertAddrIP

private byte[] convertAddrIP(java.lang.String p_strAddress)
Concert texture IP address to byte array in order to get the InetAddress

Parameters:
p_strAddress - The IP address
Returns:
The corresponding InetAddress

registerActorCyb

public void registerActorCyb(java.lang.Object p_anActor,
                             CyberOrg p_cybHost)
Register actor-host. p_anActor is ActorName if it is created locally, but if it is migrated here through CyberOrg migration, we use String

Parameters:
p_anActor - Actor name or string of actor name being registered
p_cybHost - The host cyberorg

afterMigrateActor

public void afterMigrateActor(ActorName p_anActor,
                              java.lang.Thread p_thread)
This method is called in remote CyberOrg Migration, after migrating an actor,
we need to insert it to the destination cyberorg, reallocate resource to it through the local scheduler

Parameters:
p_anActor - Actor name
p_thread - Actor thread

lookupHost

public CyberOrg lookupHost(java.lang.Object p_objFacilitator)
This method is called after remote migration, in order to set host for the migrated facilitator

Parameters:
p_objFacilitator - The facilitator actor
Returns:
The host cyberorg

removeActor

public void removeActor(ActorName p_anActor)
Called when an actor is destroyed

Parameters:
p_anActor - The actor being destroyed

updateTotalTicks

public long updateTotalTicks()
Called by scheduler after every scheduling cycle, for total time control

Returns:
The updated total ticks

reactiveCyberOrg

public void reactiveCyberOrg(CyberOrg p_cybToActive)
These method are called when a cyberorg runs out of resource, and when it gets more resources and can be scheduled again.

Parameters:
p_cybToActive - The cyberorg being reactivated

disactiveCyberOrg

public void disactiveCyberOrg(CyberOrg p_cybToDisactive)
Disactivate a cyberorg when it runs out of resources

Parameters:
p_cybToDisactive - The cyberorg being disactivated

lookupDestination

public CyberOrg lookupDestination()
This method is called by facilitator actors before migration. It is used to pick up a best destination cyberorg (according to the price)

Returns:
The potential destination cyberorg