orca.shirako.plugins.db
Class MySqlDatabase

java.lang.Object
  extended by orca.util.db.MySqlBase
      extended by orca.shirako.plugins.db.MySqlDatabase
All Implemented Interfaces:
IDatabase, IInitialize, IRecover, ISerialize
Direct Known Subclasses:
MySqlClientDatabase

public class MySqlDatabase
extends MySqlBase
implements IDatabase


Field Summary
protected  java.lang.String actorId
           
protected  java.lang.String actorName
          Cache the Actor Name and unique ID
static java.lang.String DefaultConfigUrl
          Default Mapping file
static java.lang.String DefaultType
           
static java.lang.String PropertyReservationID
           
protected  java.util.HashSet<IStateChangeListener> reservationListeners
          Listeners for database reservation update events
 
Fields inherited from class orca.util.db.MySqlBase
create, db, DefaultSchema, driverPath, joclFileLocation, logger, mapFile, mapper, mySqlPasswd, mySqlServer, mySqlServerPort, mySqlUser, pool, PropertyMySqlDb, PropertyMySqlPassword, PropertyMySqlPool, PropertyMySqlServer, PropertyMySqlServerPort, PropertyMySqlUser, resetState, schemaFile, source, TypeDefault
 
Constructor Summary
MySqlDatabase()
           
MySqlDatabase(java.lang.String configFile)
           
 
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.
protected  java.util.Vector<java.util.Properties> createSearchResults(java.sql.ResultSet rs, java.lang.String prefix)
           
protected  java.util.Vector<java.util.Properties> createSearchResultsTyped(java.sql.ResultSet rs, java.lang.String type)
          Create a Properties list from a ResultSet obtained from a query
protected  java.lang.String getActorIdFromName(java.lang.String name)
           
protected  java.lang.String getActorIdFromName(java.lang.String name, java.sql.Connection connection)
           
 java.util.Vector<java.util.Properties> getAgentReservations()
          Retrieves all reservations for which this actor acts as a broker.
 java.util.Vector<java.util.Properties> getAuthorityReservations()
          Retrieves all reservations for which this actor acts as a site.
 java.util.Vector<java.util.Properties> getBrokers()
          Retrieves all broker proxies.
 java.util.Vector<java.util.Properties> getClientReservations()
          Retrieves all reservations that represent clients of this actor.
 java.util.Vector<java.util.Properties> getClientSlices()
          Retrieves all client slice records.
 java.util.Vector<java.util.Properties> getConfigurationMapping(java.lang.String key)
          Retrieves the specified configuration mapping record.
 java.util.Vector<java.util.Properties> getConfigurationMappings()
          Retrieves all configuration mapping records.
 java.util.Vector<java.util.Properties> getHoldings()
          Retrieves all reservations representing resources held by this actor Broker/service manager.
 java.util.Vector<java.util.Properties> getInventorySlices()
          Retrieves all inventory slice records.
 java.util.Vector<java.util.Properties> getReservation(ReservationID rid)
          Retrieves the specified reservation record.
 java.util.Vector<java.util.Properties> getReservations()
          Retrieves all reservation records.
 java.util.Vector<java.util.Properties> 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<java.util.Properties> getSlice(SliceID sliceID)
          Retrieves the specified slice record.
protected  java.lang.String getSliceIdFromGuid(SliceID guid)
          Get the auto-generated key from the Slice Name
protected  java.lang.String getSliceIdFromGuid(SliceID guid, java.sql.Connection connection)
           
 java.util.Vector<java.util.Properties> getSlices()
          Retrieves all slice records.
 void initialize()
          Initializes the object.
protected  void notifyReservationListeners(IReservation r, ReservationState from, ReservationState to)
          Notifies the reservation listeners about the fact that a state change was successfully committed to the database
 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 removeSlice(SliceID sliceID)
          Removes the corresponding database slice record.
 void revisit(IActor a, 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.
 void setActorName(java.lang.String actorName)
          Sets the name of the actor this database belongs to.
 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 orca.util.db.MySqlBase
checkDb, checkDrivers, configure, constructQueryPartial, getConnection, getDb, getLogger, getMySqlPasswd, getMySqlServer, getMySqlServerPort, getMySqlUser, getPoolConfigLocation, getSchemaString, getServerConnection, loadDrivers, reset, resetDB, returnConnection, save, save, setDb, setLogger, setMySqlPasswd, setMySqlServer, setMySqlServerPort, setMySqlUser, setPoolConfigLocation, setResetState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface orca.shirako.api.IDatabase
getLogger, setLogger, setResetState
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 

Field Detail

DefaultConfigUrl

public static final java.lang.String DefaultConfigUrl
Default Mapping file

See Also:
Constant Field Values

PropertyReservationID

public static final java.lang.String PropertyReservationID
See Also:
Constant Field Values

DefaultType

public static final java.lang.String DefaultType
See Also:
Constant Field Values

actorName

protected java.lang.String actorName
Cache the Actor Name and unique ID


actorId

protected java.lang.String actorId

reservationListeners

protected java.util.HashSet<IStateChangeListener> reservationListeners
Listeners for database reservation update events

Constructor Detail

MySqlDatabase

public MySqlDatabase()

MySqlDatabase

public MySqlDatabase(java.lang.String configFile)
Method Detail

initialize

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

Specified by:
initialize in interface IInitialize
Overrides:
initialize in class MySqlBase
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

revisit

public void revisit(IActor a,
                    java.util.Properties p)
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:
a - actor object the component belongs to
p - properties list containing configuration data about the component

getActorIdFromName

protected java.lang.String getActorIdFromName(java.lang.String name,
                                              java.sql.Connection connection)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

getActorIdFromName

protected java.lang.String getActorIdFromName(java.lang.String name)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

getSliceIdFromGuid

protected java.lang.String getSliceIdFromGuid(SliceID guid)
                                       throws java.lang.Exception
Get the auto-generated key from the Slice Name

Parameters:
sliceName -
Returns:
key
Throws:
java.lang.Exception

getSliceIdFromGuid

protected java.lang.String getSliceIdFromGuid(SliceID guid,
                                              java.sql.Connection connection)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

createSearchResults

protected java.util.Vector<java.util.Properties> createSearchResults(java.sql.ResultSet rs,
                                                                     java.lang.String prefix)
                                                              throws java.lang.Exception
Throws:
java.lang.Exception

createSearchResultsTyped

protected java.util.Vector<java.util.Properties> createSearchResultsTyped(java.sql.ResultSet rs,
                                                                          java.lang.String type)
                                                                   throws java.lang.Exception
Create a Properties list from a ResultSet obtained from a query

Parameters:
rs - The ResultSet
type - Object type (node, machine, etc)
Returns:
Translated properties list
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

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

getSlices

public java.util.Vector<java.util.Properties> 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<java.util.Properties> 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

getClientSlices

public java.util.Vector<java.util.Properties> 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

getSlice

public java.util.Vector<java.util.Properties> 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

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

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

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(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<java.util.Properties> 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

getClientReservations

public java.util.Vector<java.util.Properties> 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<java.util.Properties> 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

getAgentReservations

public java.util.Vector<java.util.Properties> 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<java.util.Properties> 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

getReservations

public java.util.Vector<java.util.Properties> 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

getReservation

public java.util.Vector<java.util.Properties> 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

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<java.util.Properties> 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

getConfigurationMappings

public java.util.Vector<java.util.Properties> 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<java.util.Properties> 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

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

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

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 -

notifyReservationListeners

protected void notifyReservationListeners(IReservation r,
                                          ReservationState from,
                                          ReservationState to)
                                   throws java.lang.Exception
Notifies the reservation listeners about the fact that a state change was successfully committed to the database

Parameters:
r - reservation
from - state before
to - state after
Throws:
java.lang.Exception


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