|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mega.gasp.platform.impl.IDManagerImpl
IDManager provide a management of the temporary IDs: the MasterApplicationID(MAID), ApplicationInstanceID(AIID), SessionID (SID) and ActorSessionID (ASID). These ID must be unique on the platform. For all type of IDs, there is a vector of released ID sort by ID and a meter to insure unicity. A max is set to limit the size of the IDs to improve the length of the message communications, in this version of the platform the type short is used. The algorithm to generate a new ID: the meter is incremented for a new ID attribution if the vector of released ID is empty, else the first ID of the vector is attributed and removed from the vector. The algorithm to release an ID: the meter is decremented if the ID is the max attributed ID and a purge of the vector is done, else the ID is released in the vector and insert at the right place (growing order).
Field Summary | |
private int |
AIID
|
private int |
ASID
|
private org.apache.log4j.Category |
cat
|
private java.util.Vector |
freeAIID
|
private java.util.Vector |
freeASID
|
private java.util.Vector |
freeMAID
|
private java.util.Vector |
freeSID
|
private int |
MAID
|
private int |
max
|
private java.util.Vector |
maxFreeIDs
|
private int |
SID
|
Constructor Summary | |
IDManagerImpl()
|
Method Summary | |
private void |
decrementMaxFreeID(int idType)
Decrements the max free id of ID type. |
int |
generateAIID()
Generate an unique ApplicationInstance ID . |
int |
generateASID()
Generate an unique ActorSession ID. |
private int |
generateID(java.util.Vector releasedIdVector,
int index)
Generate a unique ID. |
int |
generateMAID()
Generate an unique MasterApplication ID. |
int |
generateSID()
Generate an unique Session ID. |
private int |
getMaxFreeID(int idType)
Returns the max free ID for ID type. |
private void |
incrementMaxFreeID(int idType)
Increments the max free id of ID type. |
private void |
indexID(java.util.Vector releasedIdVector,
int tempID)
Place the ID at his place in the vector, increase order. |
private void |
purgeVector(java.util.Vector releasedIdVector,
int index)
Purge the vector with the alogorithm above: -> if the released ID is the max used ID then search in the vector releasedID-1, if it is in remove it, set to max Free ID and replay the algorithm. |
void |
releaseAIID(int tempID)
Release an ApplicationInstance ID. |
void |
releaseASID(int tempID)
Release an ActorSession ID. |
private void |
releaseID(java.util.Vector releasedIdVector,
int index,
int tempID)
|
void |
releaseMAID(int tempID)
Release a MasterApplication ID. |
void |
releaseSID(int tempID)
Release a Session ID. |
private void |
setMaxFreeID(int idType,
int value)
Sets the max free ID to value of ID type. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int max
private java.util.Vector maxFreeIDs
private java.util.Vector freeASID
private java.util.Vector freeSID
private java.util.Vector freeAIID
private java.util.Vector freeMAID
private org.apache.log4j.Category cat
private final int MAID
private final int AIID
private final int SID
private final int ASID
Constructor Detail |
public IDManagerImpl()
Method Detail |
private int getMaxFreeID(int idType)
idType
-
private void setMaxFreeID(int idType, int value)
idType
- value
- private void incrementMaxFreeID(int idType)
idType
- private void decrementMaxFreeID(int idType)
idType
- public int generateMAID()
generateMAID
in interface IDManager
public int generateAIID()
generateAIID
in interface IDManager
public int generateSID()
generateSID
in interface IDManager
public int generateASID()
generateASID
in interface IDManager
public void releaseMAID(int tempID)
releaseMAID
in interface IDManager
tempID
- the MAIDpublic void releaseAIID(int tempID)
releaseAIID
in interface IDManager
tempID
- the AIIDpublic void releaseSID(int tempID)
releaseSID
in interface IDManager
tempID
- the SIDpublic void releaseASID(int tempID)
releaseASID
in interface IDManager
tempID
- the ASIDprivate int generateID(java.util.Vector releasedIdVector, int index)
releasedIdVector
- the corresponding vectorindex
- the index of the max free IDs table
private void releaseID(java.util.Vector releasedIdVector, int index, int tempID)
releasedIdVector
- index
- the index of the max free IDs tabletempID
- private void indexID(java.util.Vector releasedIdVector, int tempID)
releasedIdVector
- the vector of released IDtempID
- the tempID to placeprivate void purgeVector(java.util.Vector releasedIdVector, int index)
releasedIdVector
- index
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |