orca.shirako.plugins.db
Class MemoryDatabase

java.lang.Object
  extended by orca.shirako.plugins.db.MemoryDatabase
All Implemented Interfaces:
IDatabase, IInitialize, IRecover, ISerialize
Direct Known Subclasses:
MemoryClientDatabase

public class MemoryDatabase
extends java.lang.Object
implements IDatabase


Nested Class Summary
protected  class MemoryDatabase.SliceData
           
 
Field Summary
protected  java.lang.String actorName
           
protected  java.util.Hashtable inventorySlices
           
protected  LoggingTool logger
           
protected  boolean resetState
           
protected  java.util.Hashtable slices
           
 
Constructor Summary
MemoryDatabase()
           
 
Method Summary
 void actorAdded()
          Performs initialization actions as a result of the actor being added to the container.
 void addBroker(IBrokerProxy broker)
          Adds a new broker proxy record.
 void addConfigurationMapping(java.lang.String key, ConfigurationMapping map)
          Adds a new configuration mapping record.
 void addReservation(ResourceReservation reservation)
          Adds a new record to the database representing this reservation object.
 void addSlice(Slice slice)
          Adds a new record to the database representing this slice object.
 java.util.Vector getAgentReservations()
          Retrieves all reservations for which this actor acts as a broker.
 java.util.Vector getAuthorityReservations()
          Retrieves all reservations for which this actor acts as a site.
 java.util.Vector getBrokers()
          Retrieves all broker proxies.
 java.util.Vector getClientReservations()
          Retrieves all reservations that represent clients of this actor.
 java.util.Vector getClientSlices()
          Retrieves all client slice records.
 java.util.Vector getConfigurationMapping(java.lang.String key)
          Retrieves the specified configuration mapping record.
 java.util.Vector getConfigurationMappings()
          Retrieves all configuration mapping records.
 java.util.Vector getHoldings()
          Retrieves all reservations representing resources held by this actor Broker/service manager.
 java.util.Vector getInventorySlices()
          Retrieves all inventory slice records.
 LoggingTool getLogger()
          Obtains the logger object used by the database layer implementation.
 java.util.Vector getReservation(ReservationID rid)
          Retrieves the specified reservation record.
 java.util.Vector getReservation(java.lang.String sliceName, ReservationID rid)
           
 java.util.Vector getReservations()
          Retrieves all reservation records.
 java.util.Vector getReservations(Slice slice)
           
 java.util.Vector getReservations(SliceID sliceID)
          Retrieves all reservation records that belong to the specified slice.
 java.util.Vector<java.util.Properties> getSlice(ResourceType type)
          Retrieves the specified slice record.
 java.util.Vector getSlice(SliceID sliceID)
          Retrieves the specified slice record.
protected  MemoryDatabase.SliceData getSliceData(Slice slice)
           
protected  MemoryDatabase.SliceData getSliceData(java.lang.String sliceName)
           
 java.util.Vector getSlices()
          Retrieves all slice records.
 void initialize()
          Initializes the object.
 void registerReservationListener(IStateChangeListener listener)
          Registers a state change listener
 void removeBroker(IBrokerProxy broker)
          Removes the specified broker proxy record.
 void removeConfigurationMapping(java.lang.String key)
          Removes the specified configuration mapping record.
 void removeReservation(ReservationID rid)
          Removes the corresponding reservation object.
 void removeReservation(ResourceReservation reservation)
           
 void removeSlice(SliceID sliceID)
          Removes the corresponding database slice record.
 void reset(java.util.Properties p)
          De-serializes the object from the given properties list.
 void revisit(IActor actor, java.util.Properties p)
          Recovers state of the component using a previously saved properties list and a references to the actor this component belongs to.
 java.util.Properties save()
          Serializes the object into a properties list.
 void save(java.util.Properties p)
          Serializes the object into the given properties list.
 void setActorName(java.lang.String actorName)
          Sets the name of the actor this database belongs to.
 void setLogger(LoggingTool logger)
          Sets the logger object to be used by the database layer implementation.
 void setResetState(boolean value)
          Indicates whether the database class should erase any previous database state.
 void unregisterReservationListener(IStateChangeListener listener)
          Unregisters the state change listener
 void updateBroker(IBrokerProxy broker)
          Updates the specified broker proxy record.
 void updateConfigurationMapping(java.lang.String key, ConfigurationMapping map)
          Updates the specified configuration mapping record.
 void updateReservation(ResourceReservation reservation)
          Updates the corresponding reservation object.
 void updateSlice(Slice slice)
          Updates the corresponding database slice record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actorName

protected java.lang.String actorName

slices

protected java.util.Hashtable slices

inventorySlices

protected java.util.Hashtable inventorySlices

logger

protected LoggingTool logger

resetState

protected boolean resetState
Constructor Detail

MemoryDatabase

public MemoryDatabase()
Method Detail

setLogger

public void setLogger(LoggingTool logger)
Description copied from interface: IDatabase
Sets the logger object to be used by the database layer implementation.

Specified by:
setLogger in interface IDatabase
Parameters:
logger - logger object

getLogger

public LoggingTool getLogger()
Description copied from interface: IDatabase
Obtains the logger object used by the database layer implementation.

Specified by:
getLogger in interface IDatabase
Returns:
logger object

initialize

public void initialize()
                throws java.lang.Exception
Description copied from interface: IInitialize
Initializes the object.

Specified by:
initialize in interface IInitialize
Throws:
java.lang.Exception

actorAdded

public void actorAdded()
                throws java.lang.Exception
Description copied from interface: IDatabase
Performs initialization actions as a result of the actor being added to the container.

Specified by:
actorAdded in interface IDatabase
Throws:
java.lang.Exception

addSlice

public void addSlice(Slice slice)
              throws java.lang.Exception
Description copied from interface: IDatabase
Adds a new record to the database representing this slice object.

Specified by:
addSlice in interface IDatabase
Parameters:
slice - Slice object
Throws:
java.lang.Exception

updateSlice

public void updateSlice(Slice slice)
                 throws java.lang.Exception
Description copied from interface: IDatabase
Updates the corresponding database slice record.

Specified by:
updateSlice in interface IDatabase
Parameters:
slice - slice object
Throws:
java.lang.Exception

getSlice

public java.util.Vector getSlice(SliceID sliceID)
                          throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves the specified slice record.

Specified by:
getSlice in interface IDatabase
Parameters:
sliceID - slice name
Returns:
a vector containing a properties list
Throws:
java.lang.Exception

getSlices

public java.util.Vector getSlices()
                           throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all slice records.

Specified by:
getSlices in interface IDatabase
Returns:
a vector containing one or more properties lists representing serialized slices
Throws:
java.lang.Exception

getInventorySlices

public java.util.Vector getInventorySlices()
                                    throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all inventory slice records.

Specified by:
getInventorySlices in interface IDatabase
Returns:
a vector containing one or more properties lists representing serialized inventory slices *
Throws:
java.lang.Exception

removeSlice

public void removeSlice(SliceID sliceID)
                 throws java.lang.Exception
Description copied from interface: IDatabase
Removes the corresponding database slice record.

Specified by:
removeSlice in interface IDatabase
Parameters:
sliceID - slice name
Throws:
java.lang.Exception

getSliceData

protected MemoryDatabase.SliceData getSliceData(Slice slice)

getSliceData

protected MemoryDatabase.SliceData getSliceData(java.lang.String sliceName)

addReservation

public void addReservation(ResourceReservation reservation)
                    throws java.lang.Exception
Description copied from interface: IDatabase
Adds a new record to the database representing this reservation object.

Specified by:
addReservation in interface IDatabase
Throws:
java.lang.Exception

getReservation

public java.util.Vector getReservation(java.lang.String sliceName,
                                       ReservationID rid)
                                throws java.lang.Exception
Throws:
java.lang.Exception

getReservation

public java.util.Vector getReservation(ReservationID rid)
                                throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves the specified reservation record.

Specified by:
getReservation in interface IDatabase
Parameters:
rid - Reservation identifier
Returns:
Throws:
java.lang.Exception

updateReservation

public void updateReservation(ResourceReservation reservation)
                       throws java.lang.Exception
Description copied from interface: IDatabase
Updates the corresponding reservation object.

Specified by:
updateReservation in interface IDatabase
Throws:
java.lang.Exception

removeReservation

public void removeReservation(ResourceReservation reservation)
                       throws java.lang.Exception
Throws:
java.lang.Exception

removeReservation

public void removeReservation(ReservationID rid)
                       throws java.lang.Exception
Description copied from interface: IDatabase
Removes the corresponding reservation object.

Specified by:
removeReservation in interface IDatabase
Throws:
java.lang.Exception

getReservations

public java.util.Vector getReservations(Slice slice)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

addBroker

public void addBroker(IBrokerProxy broker)
               throws java.lang.Exception
Description copied from interface: IDatabase
Adds a new broker proxy record.

Specified by:
addBroker in interface IDatabase
Throws:
java.lang.Exception

removeBroker

public void removeBroker(IBrokerProxy broker)
                  throws java.lang.Exception
Description copied from interface: IDatabase
Removes the specified broker proxy record.

Specified by:
removeBroker in interface IDatabase
Throws:
java.lang.Exception

updateBroker

public void updateBroker(IBrokerProxy broker)
                  throws java.lang.Exception
Description copied from interface: IDatabase
Updates the specified broker proxy record.

Specified by:
updateBroker in interface IDatabase
Throws:
java.lang.Exception

getBrokers

public java.util.Vector getBrokers()
                            throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all broker proxies.

Specified by:
getBrokers in interface IDatabase
Returns:
Throws:
java.lang.Exception

save

public java.util.Properties save()
                          throws java.lang.Exception
Description copied from interface: ISerialize
Serializes the object into a properties list.

Specified by:
save in interface ISerialize
Returns:
properties list representing this object
Throws:
java.lang.Exception

save

public void save(java.util.Properties p)
          throws java.lang.Exception
Description copied from interface: ISerialize
Serializes the object into the given properties list.

Specified by:
save in interface ISerialize
Parameters:
p - properties list to serialize the object into
Throws:
java.lang.Exception

reset

public void reset(java.util.Properties p)
           throws java.lang.Exception
Description copied from interface: ISerialize
De-serializes the object from the given properties list.

Specified by:
reset in interface ISerialize
Parameters:
p - properties list containing the serialized version of the object
Throws:
java.lang.Exception

revisit

public void revisit(IActor actor,
                    java.util.Properties p)
             throws java.lang.Exception
Description copied from interface: IRecover
Recovers state of the component using a previously saved properties list and a references to the actor this component belongs to. The component can use the actor object to access other objects necessary for its complete recovery.

Specified by:
revisit in interface IRecover
Parameters:
actor - actor object the component belongs to
p - properties list containing configuration data about the component
Throws:
java.lang.Exception

getClientSlices

public java.util.Vector getClientSlices()
                                 throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all client slice records.

Specified by:
getClientSlices in interface IDatabase
Returns:
a vector containing one or more properties lists representing serialized client slices
Throws:
java.lang.Exception

getReservations

public java.util.Vector getReservations(SliceID sliceID)
                                 throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all reservation records that belong to the specified slice.

Specified by:
getReservations in interface IDatabase
Returns:
Throws:
java.lang.Exception

addConfigurationMapping

public void addConfigurationMapping(java.lang.String key,
                                    ConfigurationMapping map)
                             throws java.lang.Exception
Description copied from interface: IDatabase
Adds a new configuration mapping record.

Specified by:
addConfigurationMapping in interface IDatabase
Parameters:
key - key for the record
map - mapping object
Throws:
java.lang.Exception

updateConfigurationMapping

public void updateConfigurationMapping(java.lang.String key,
                                       ConfigurationMapping map)
                                throws java.lang.Exception
Description copied from interface: IDatabase
Updates the specified configuration mapping record.

Specified by:
updateConfigurationMapping in interface IDatabase
Parameters:
key - record key
map - mapping object
Throws:
java.lang.Exception

getConfigurationMappings

public java.util.Vector getConfigurationMappings()
                                          throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all configuration mapping records.

Specified by:
getConfigurationMappings in interface IDatabase
Returns:
a vector containing one or more properties lists representing configuration mapping records
Throws:
java.lang.Exception

getConfigurationMapping

public java.util.Vector getConfigurationMapping(java.lang.String key)
                                         throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves the specified configuration mapping record.

Specified by:
getConfigurationMapping in interface IDatabase
Parameters:
key - record key
Returns:
a vector containing a properties list
Throws:
java.lang.Exception

removeConfigurationMapping

public void removeConfigurationMapping(java.lang.String key)
                                throws java.lang.Exception
Description copied from interface: IDatabase
Removes the specified configuration mapping record.

Specified by:
removeConfigurationMapping in interface IDatabase
Parameters:
key - key
Throws:
java.lang.Exception

setActorName

public void setActorName(java.lang.String actorName)
Description copied from interface: IDatabase
Sets the name of the actor this database belongs to.

Specified by:
setActorName in interface IDatabase
Parameters:
actorName - actor name

getClientReservations

public java.util.Vector getClientReservations()
                                       throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all reservations that represent clients of this actor. For a broker, should return only agent reservations. For a site, should return both agent and authority reservations.

Specified by:
getClientReservations in interface IDatabase
Returns:
Throws:
java.lang.Exception

getHoldings

public java.util.Vector getHoldings()
                             throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all reservations representing resources held by this actor Broker/service manager.

Specified by:
getHoldings in interface IDatabase
Returns:
Throws:
java.lang.Exception

getReservations

public java.util.Vector getReservations()
                                 throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all reservation records.

Specified by:
getReservations in interface IDatabase
Returns:
Throws:
java.lang.Exception

getAgentReservations

public java.util.Vector getAgentReservations()
                                      throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all reservations for which this actor acts as a broker.

Specified by:
getAgentReservations in interface IDatabase
Returns:
Throws:
java.lang.Exception

getAuthorityReservations

public java.util.Vector getAuthorityReservations()
                                          throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves all reservations for which this actor acts as a site.

Specified by:
getAuthorityReservations in interface IDatabase
Returns:
Throws:
java.lang.Exception

setResetState

public void setResetState(boolean value)
Description copied from interface: IDatabase
Indicates whether the database class should erase any previous database state. If true, when the database class starts it will clean any state in the database. Default: false.

Specified by:
setResetState in interface IDatabase

registerReservationListener

public void registerReservationListener(IStateChangeListener listener)
Registers a state change listener

Specified by:
registerReservationListener in interface IDatabase
Parameters:
listener -

unregisterReservationListener

public void unregisterReservationListener(IStateChangeListener listener)
Unregisters the state change listener

Specified by:
unregisterReservationListener in interface IDatabase
Parameters:
listener -

getSlice

public java.util.Vector<java.util.Properties> getSlice(ResourceType type)
                                                throws java.lang.Exception
Description copied from interface: IDatabase
Retrieves the specified slice record.

Specified by:
getSlice in interface IDatabase
Parameters:
type - resource type associated with the slice
Returns:
a vector containing a properties list
Throws:
java.lang.Exception


Copyright © 2007 Network/Internet Computing Lab. All Rights Reserved.