net.sf.jso.engine
Class JSOStorageController

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended bynet.sf.jso.engine.JSOStorageController
All Implemented Interfaces:
java.util.EventListener, LockManager, java.rmi.Remote, RemoteStorageController, SchemaManager, java.io.Serializable, StorageController, StorageListener, TransactionListener

public class JSOStorageController
extends java.rmi.server.UnicastRemoteObject
implements StorageController, RemoteStorageController, TransactionListener

Controller responsible for coordinating storage operations by several concurrent storage managers.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
JSOStorageController(java.util.Properties someProperties)
          Constructs the controller.
 
Method Summary
 void addSchemaListener(SchemaListener listener)
          Starts sending schema events to a listener.
 void addStatusListener(StatusListener listener)
          Starts sending status events to a listener.
 void addStorageListener(StorageListener listener)
          Starts sending storage events to a listener.
 ClassDescriptor createClassDescriptor(java.lang.Class aClass)
          Creates a class descriptor for a storable class.
 long createId()
          Creates an unique identification within a database.
protected  void finalize()
          Stops the controller.
 ClassDescriptor getClassDescriptor(java.lang.Class aClass)
          Returns the descriptor for a storable class.
 java.util.Properties getConfigurationProperties()
          Returns configuration properties.
 ControllerInfo getControllerInfo()
          Gets storage control information.
 int getCurrentCycle()
          Gets current garbage collection cycle.
 PID getCurrentPID()
          Gets current storage partition's identification.
 LockInfo getLockInfo()
          Gets transaction processing information.
 Status getStatus()
          Gets controller's status.
 boolean isRemote()
          Indicates if controller is running on another JVM.
 void lock(TID txid, OID oid, boolean exclusive, long timeout)
          Holds a lock for an object.
 void objectDeleted(StorageEvent event)
          Called when an object is deleted.
 void objectStored(StorageEvent event)
          Called when an object is stored.
 void registerManager(StorageManager manager)
          Register a storage manager to receive events.
 void release(TID txid, OID oid)
          Releases the lock for an object
 void removeSchemaListener(SchemaListener listener)
          Stops sending schema events to a listener.
 void removeStatusListener(StatusListener listener)
          Stops sending status events to a listener.
 void removeStorageListener(StorageListener listener)
          Stops sending storage events to a listener.
static void safellyStop(StorageController aController)
          Stops a storage controller without throwing any exceptions.
 void start()
          Starts the controller.
 void stop()
          Stops the controller.
 void transactionBegun(TransactionEvent event)
          Called immediately after transaction beginning.
 void transactionCommit(TransactionEvent event)
          Called immediately before transaction commit.
 void transactionFinished(TransactionEvent event)
          Called immediately after transaction finish.
 void transactionRollback(TransactionEvent event)
          Called immediately before transaction rollback.
 void unregisterManager(StorageManager manager)
          Unregister a storage manager to receive events.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSOStorageController

public JSOStorageController(java.util.Properties someProperties)
                     throws java.rmi.RemoteException
Constructs the controller.

Parameters:
someProperties - Properties containing parameters to the controller. The following properties can be used:
See Also:
DatabaseInterface.set(Properties)
Method Detail

start

public void start()
           throws StorageException
Starts the controller.

Specified by:
start in interface StorageController
Throws:
StorageException

stop

public void stop()
          throws StorageException
Stops the controller. Resources are kept until shutdown.

Specified by:
stop in interface StorageController
Throws:
StorageException

safellyStop

public static void safellyStop(StorageController aController)
Stops a storage controller without throwing any exceptions.

Parameters:
aController - Storage controller to be stopped.

getConfigurationProperties

public java.util.Properties getConfigurationProperties()
Returns configuration properties.

Specified by:
getConfigurationProperties in interface StorageController
Returns:
Configuration properties.

createId

public long createId()
              throws StorageException
Creates an unique identification within a database.

Specified by:
createId in interface StorageController
Returns:
An unique id.
Throws:
StorageException

getCurrentPID

public PID getCurrentPID()
                  throws StorageException
Gets current storage partition's identification.

Specified by:
getCurrentPID in interface StorageController
Returns:
Current storage partition's identification.
Throws:
StorageException

getCurrentCycle

public int getCurrentCycle()
Gets current garbage collection cycle.

Specified by:
getCurrentCycle in interface StorageController
Returns:
Current garbage collection cycle.

getControllerInfo

public ControllerInfo getControllerInfo()
Gets storage control information.

Specified by:
getControllerInfo in interface StorageController
Returns:
Information about storage control.

registerManager

public void registerManager(StorageManager manager)
Register a storage manager to receive events.

Specified by:
registerManager in interface StorageController
Parameters:
manager - Manager to be registered.

unregisterManager

public void unregisterManager(StorageManager manager)
Unregister a storage manager to receive events.

Specified by:
unregisterManager in interface StorageController
Parameters:
manager - Manager to be unregistered.

objectStored

public void objectStored(StorageEvent event)
Called when an object is stored.

Specified by:
objectStored in interface StorageListener

objectDeleted

public void objectDeleted(StorageEvent event)
Called when an object is deleted.

Specified by:
objectDeleted in interface StorageListener

addStorageListener

public void addStorageListener(StorageListener listener)
Starts sending storage events to a listener.

Specified by:
addStorageListener in interface StorageController
Parameters:
listener - Listener to receive storage events.

removeStorageListener

public void removeStorageListener(StorageListener listener)
Stops sending storage events to a listener.

Specified by:
removeStorageListener in interface StorageController
Parameters:
listener - Listener to stop receiving storage events.

getStatus

public Status getStatus()
Gets controller's status.

Specified by:
getStatus in interface StorageController
Returns:
Controller's current status.

isRemote

public boolean isRemote()
Indicates if controller is running on another JVM.

Specified by:
isRemote in interface StorageController
Returns:
true if controller is running on another JVM; false otherwise.

addStatusListener

public void addStatusListener(StatusListener listener)
Starts sending status events to a listener.

Specified by:
addStatusListener in interface StorageController
Parameters:
listener - Listener to receive status events.

removeStatusListener

public void removeStatusListener(StatusListener listener)
Stops sending status events to a listener.

Specified by:
removeStatusListener in interface StorageController
Parameters:
listener - Listener to stop receiving status events.

addSchemaListener

public void addSchemaListener(SchemaListener listener)
Starts sending schema events to a listener.

Specified by:
addSchemaListener in interface SchemaManager
Parameters:
listener - Listener to receive schema events.

removeSchemaListener

public void removeSchemaListener(SchemaListener listener)
Stops sending schema events to a listener.

Specified by:
removeSchemaListener in interface SchemaManager
Parameters:
listener - Listener to stop receiving schema events.

getClassDescriptor

public ClassDescriptor getClassDescriptor(java.lang.Class aClass)
                                   throws StorageException
Returns the descriptor for a storable class.

Specified by:
getClassDescriptor in interface SchemaManager
Parameters:
aClass - The class to which the descriptot should be returned.
Returns:
The class descriptor.
Throws:
StorageException

createClassDescriptor

public ClassDescriptor createClassDescriptor(java.lang.Class aClass)
                                      throws StorageException
Creates a class descriptor for a storable class.

Specified by:
createClassDescriptor in interface SchemaManager
Parameters:
aClass - The class to which the descriptot should be created.
Returns:
The class descriptor.
Throws:
StorageException

transactionBegun

public void transactionBegun(TransactionEvent event)
Called immediately after transaction beginning.

Specified by:
transactionBegun in interface TransactionListener

transactionCommit

public void transactionCommit(TransactionEvent event)
Called immediately before transaction commit.

Specified by:
transactionCommit in interface TransactionListener

transactionRollback

public void transactionRollback(TransactionEvent event)
Called immediately before transaction rollback.

Specified by:
transactionRollback in interface TransactionListener

transactionFinished

public void transactionFinished(TransactionEvent event)
Called immediately after transaction finish.

Specified by:
transactionFinished in interface TransactionListener

lock

public void lock(TID txid,
                 OID oid,
                 boolean exclusive,
                 long timeout)
          throws TransactionTimeoutException
Holds a lock for an object. All locks are released when transaction finishes.

Specified by:
lock in interface LockManager
Parameters:
oid - The OID of the object to be locked.
exclusive - Informs if the lock should be exclusive.
timeout - Number of milliseconds for timeout. Values lesser than 1 millisecond mean no timeout should be used.
Throws:
TransactionTimeoutException

release

public void release(TID txid,
                    OID oid)
             throws StorageException
Releases the lock for an object

Specified by:
release in interface LockManager
Parameters:
oid - The OID of the object to be released.
Throws:
StorageException

getLockInfo

public LockInfo getLockInfo()
Gets transaction processing information.

Specified by:
getLockInfo in interface LockManager
Returns:
Information about transaction processing.

finalize

protected void finalize()
                 throws java.lang.Throwable
Stops the controller.

Throws:
java.lang.Throwable