aa.core
Class CyberOrg

java.lang.Object
  extended byaa.core.CyberOrg
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
QuadCyber

public class CyberOrg
extends java.lang.Object
implements java.io.Serializable

This class represents a cyberorg

Author:
xinghuizhao
See Also:
Serialized Form

Field Summary
 long height
           
protected  ActorName m_anFacilitator
           
protected  boolean m_bIsActive
           
protected  Contract m_conContract
           
protected  CyberOrg m_cybParent
           
protected  long m_lECash
           
protected  java.util.LinkedList m_llActors
           
protected  java.util.LinkedList m_llChildren
           
protected  long m_lPrice
           
protected  long m_lTicks
           
protected  long m_lTicksRate
           
protected  long m_lTimesliceAssigned
           
protected  java.lang.Object[] m_objaAgs
           
protected  Platform m_pPlatform
           
protected  java.lang.String m_strFacilitatorClass
           
 
Constructor Summary
CyberOrg()
          Creates a new instance of CyberOrg
CyberOrg(Contract p_conContract, java.lang.Long p_LECash, java.util.LinkedList p_llActors)
          Constructor that is used to create a cyberorg for the one which is migrating into the current cyberorg
CyberOrg(java.lang.Long p_longTicks, java.lang.Long p_longTicksRate, java.lang.Long p_longECash, java.lang.String p_strFacilitatorClass, java.lang.Object[] p_objaAgs)
          Creates a new instance of CyberOrg with known resource specification
 
Method Summary
 void addChild(CyberOrg p_cybChild)
          Add a child cyberorg to the current child list
 CyberOrg assimilate()
          CyberOrg assimilate
 long chargeTotalTicks()
          This method is called by the scheduler after every sheduling cycle, in order to keep track of total resource inside this cyberorg if a cyberorg runs out of resource, it couldn't be scheduled until it gets resources from somewhere else
 void deleteActor(ActorName p_anActor)
          Delete an Actor when it is distroyed
 void deleteChild(CyberOrg p_cybChild)
          Delete a child cyberorg from the child list, it is called in assimilation
 CyberOrg findBestDestination()
          This method is used to look for the best desitination cyberorg in migration
 java.util.LinkedList getActors()
          Returns the actor list
 java.util.LinkedList getChildren()
          Returns the child list of the current cyberorg
 Contract getContract()
          Returns the contract
 long getECash()
          Returns the number of eCash in the current cyberorg
 ActorName getFacilitator()
          Returns the name of the facilitator actor
 long getHeight()
          Returns the height of current cyberorg
 Platform getPlatform()
          Returns to a handler of current platform
 long getPrice()
          Returns the current resource price in the current cyberorg
 void getResBack(long p_lTicks, long p_lTicksRate, long p_lECash)
          Get resource back from a child cyberorg which is assimilating
called by assimilation of child cyberorg
 long getTicks()
          Returns the amount of resources the current cyberorg has
 long getTicksRate()
          Returns the resource rate of the current cyberorg
 void insertActor(ActorName p_anToInsert)
          Insert an actor to the actors list
 CyberOrg isolate(long p_lECash, ActorName[] p_anaActors, Contract p_conContract)
          CyberOrg isolate
This method is called by the facilitator
 void migrate(ActorName p_anDestFacilitator, Contract p_conNewContract)
          CyberOrg migrate
 void printInfo()
          toString for debug
 void receiveCyberOrg(Contract p_conContract, java.lang.Long p_LECash, java.util.LinkedList p_llActors)
          Receive a CyberOrg
This method is called when remote migration happens create a cyberorg according to the parameters we recived
 void receiveCyberOrg(Contract p_conContract, java.lang.Long p_LECash, java.util.LinkedList p_llActors, CyberOrg p_cybMigrating)
          Receive a CyberOrg without creating a new instance
 void resourceAlloc(ActorName p_anNeedResource)
          Default resource allocation policy for actors in this cyberorg
User can define their own resource allocation policy by overwriting this method
 void resourceAlloc(ActorName p_anNeedResource, long p_lRate)
          Another resource allocation policy which assigns a known amount of resource to the given actor
 void resourceAllocForAll()
          Allocate resource for all actors It is called after migration (local)
 void setHeight(long p_lHeight)
          Set up the height of current cyberorg
 void setNullChild()
          it is called in remote migration.
 void setParent(CyberOrg p_cybParent)
          Set parent cyberorg for this cyberorg it is called by isolation, migration
 void setPlatform()
          Set up the current CyberOrgs platform
 void updateActors(ActorName p_anActorName)
          Update Actors List, which is called in remote migration (when actors are migraing here)
 long updatePrice()
          Oct 17th, 2005.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_lTicks

protected long m_lTicks

m_lTicksRate

protected long m_lTicksRate

m_lECash

protected long m_lECash

m_llActors

protected java.util.LinkedList m_llActors

m_llChildren

protected transient java.util.LinkedList m_llChildren

m_cybParent

protected transient CyberOrg m_cybParent

m_anFacilitator

protected ActorName m_anFacilitator

m_conContract

protected Contract m_conContract

m_pPlatform

protected transient Platform m_pPlatform

m_strFacilitatorClass

protected java.lang.String m_strFacilitatorClass

m_objaAgs

protected java.lang.Object[] m_objaAgs

m_lPrice

protected long m_lPrice

m_bIsActive

protected boolean m_bIsActive

m_lTimesliceAssigned

protected long m_lTimesliceAssigned

height

public long height
Constructor Detail

CyberOrg

public CyberOrg()
Creates a new instance of CyberOrg


CyberOrg

public CyberOrg(java.lang.Long p_longTicks,
                java.lang.Long p_longTicksRate,
                java.lang.Long p_longECash,
                java.lang.String p_strFacilitatorClass,
                java.lang.Object[] p_objaAgs)
Creates a new instance of CyberOrg with known resource specification


CyberOrg

public CyberOrg(Contract p_conContract,
                java.lang.Long p_LECash,
                java.util.LinkedList p_llActors)
Constructor that is used to create a cyberorg for the one which is migrating into the current cyberorg

Method Detail

setParent

public void setParent(CyberOrg p_cybParent)
Set parent cyberorg for this cyberorg it is called by isolation, migration

Parameters:
p_cybParent - The parent cyberorg

setPlatform

public void setPlatform()
Set up the current CyberOrgs platform


setNullChild

public void setNullChild()
it is called in remote migration. after this cyberorg migrates to another platform, we didn't bring the child list instead, we create new child list, and wait for child cyberorgs coming


getPlatform

public Platform getPlatform()
Returns to a handler of current platform

Returns:
The current CyberOrgs platform

setHeight

public void setHeight(long p_lHeight)
Set up the height of current cyberorg

Parameters:
p_lHeight - The height of current cyberorg

getHeight

public long getHeight()
Returns the height of current cyberorg

Returns:
The height of current cyberorg

isolate

public CyberOrg isolate(long p_lECash,
                        ActorName[] p_anaActors,
                        Contract p_conContract)
CyberOrg isolate
This method is called by the facilitator

Parameters:
p_lECash - The eCash that is given to the new child cyberorg
p_anaActors - A list of actors that will be isolated to the child cyberorg
p_conContract - The contract between the current cyberorg and its new child cyberorg
Returns:
The newly created child cyberorg

insertActor

public void insertActor(ActorName p_anToInsert)
Insert an actor to the actors list

Parameters:
p_anToInsert - The name of the actor which is added to the current actor list

resourceAlloc

public void resourceAlloc(ActorName p_anNeedResource)
Default resource allocation policy for actors in this cyberorg
User can define their own resource allocation policy by overwriting this method

Parameters:
p_anNeedResource - The name of the actor for which resources are allocated

resourceAlloc

public void resourceAlloc(ActorName p_anNeedResource,
                          long p_lRate)
Another resource allocation policy which assigns a known amount of resource to the given actor

Parameters:
p_anNeedResource - The name of the actor for which resources are allocated
p_lRate - Amount of resource which is assigned to the given actor

resourceAllocForAll

public void resourceAllocForAll()
Allocate resource for all actors It is called after migration (local)


assimilate

public CyberOrg assimilate()
CyberOrg assimilate

Returns:
The parent cyberorg

getResBack

public void getResBack(long p_lTicks,
                       long p_lTicksRate,
                       long p_lECash)
Get resource back from a child cyberorg which is assimilating
called by assimilation of child cyberorg

Parameters:
p_lTicks - Resources that are returned to the current cyberorg
p_lTicksRate - Resource rate that is returned to the current cyberorg
p_lECash - eCash that is returned to the current cyberorg

deleteChild

public void deleteChild(CyberOrg p_cybChild)
Delete a child cyberorg from the child list, it is called in assimilation

Parameters:
p_cybChild - The child cyberorg which is assimilating

addChild

public void addChild(CyberOrg p_cybChild)
Add a child cyberorg to the current child list

Parameters:
p_cybChild - The new child cyberorg

deleteActor

public void deleteActor(ActorName p_anActor)
Delete an Actor when it is distroyed

Parameters:
p_anActor - The name of the actor to be deleted

migrate

public void migrate(ActorName p_anDestFacilitator,
                    Contract p_conNewContract)
CyberOrg migrate

Parameters:
p_anDestFacilitator - The ficilitator actor of the destination parent cyberorg
p_conNewContract - The new contract between the current cyberorg and its new parent

getFacilitator

public ActorName getFacilitator()
Returns the name of the facilitator actor

Returns:
The name of the facilitator actor

getECash

public long getECash()
Returns the number of eCash in the current cyberorg

Returns:
the number of eCash in the current cyberorg

getActors

public java.util.LinkedList getActors()
Returns the actor list

Returns:
The actor list of the current cyberorg

getChildren

public java.util.LinkedList getChildren()
Returns the child list of the current cyberorg

Returns:
The child list

getContract

public Contract getContract()
Returns the contract

Returns:
The contract between the current cyberorg and its parent

getTicks

public long getTicks()
Returns the amount of resources the current cyberorg has

Returns:
The amount of resources

getTicksRate

public long getTicksRate()
Returns the resource rate of the current cyberorg

Returns:
Resource rate

getPrice

public long getPrice()
Returns the current resource price in the current cyberorg

Returns:
Price of its resources

receiveCyberOrg

public void receiveCyberOrg(Contract p_conContract,
                            java.lang.Long p_LECash,
                            java.util.LinkedList p_llActors)
Receive a CyberOrg
This method is called when remote migration happens create a cyberorg according to the parameters we recived

Parameters:
p_conContract - The contract in the cyberorg that is being received
p_LECash - Number of eCash
p_llActors - Actor list

receiveCyberOrg

public void receiveCyberOrg(Contract p_conContract,
                            java.lang.Long p_LECash,
                            java.util.LinkedList p_llActors,
                            CyberOrg p_cybMigrating)
Receive a CyberOrg without creating a new instance

Parameters:
p_conContract - Contract in the cyberorg being received
p_LECash - Number of eCash
p_llActors - Actor list
p_cybMigrating - A handler to the cyberorg in migration

updateActors

public void updateActors(ActorName p_anActorName)
Update Actors List, which is called in remote migration (when actors are migraing here)

Parameters:
p_anActorName - The name of the actor being added to the current cyberorg

printInfo

public void printInfo()
toString for debug


updatePrice

public long updatePrice()
Oct 17th, 2005. Update system to adapt dynamic prices. Later on, resource discovery will be based on the price of resource (market evaluation) This method is used to make a local decision about the price of the resource It is called whenever a change in resource allocation happens in this cyberorg


chargeTotalTicks

public long chargeTotalTicks()
This method is called by the scheduler after every sheduling cycle, in order to keep track of total resource inside this cyberorg if a cyberorg runs out of resource, it couldn't be scheduled until it gets resources from somewhere else


findBestDestination

public CyberOrg findBestDestination()
This method is used to look for the best desitination cyberorg in migration

Returns:
A handler to the potential parent cyberorg