ozone API

org.ozoneDB
Class ClientCacheDatabase

java.lang.Object
  extended byorg.ozoneDB.AbstractDatabase
      extended byorg.ozoneDB.ExternalDatabase
          extended byorg.ozoneDB.ClientCacheDatabase
All Implemented Interfaces:
OzoneInterface

public class ClientCacheDatabase
extends ExternalDatabase

This is an ExternalDatabase that implements a client side cache on top of another ExternalDatabase.

In contrast to LocalDatabase and RemoteDatabase which produce the exactly same results for the same code, this implementation of ExternalDatabase is not guaranteed to do so.

Note: The method parameters of type OzoneRemote are supposed to by proxy objects (of type OzoneProxy). However, it's possible to pass a database objects (of type OzoneCompatible). In this case the parameter should be substituted. Currently this is done by the invoke() method only.

Impl. Note: All interface methods are synchronized because they have to be executed as an atomar operation.

Version:
$Revision: 1.8 $Date: 2003/01/23 18:07:00 $
Author:
SMB
See Also:
OzoneInterface

Field Summary
 
Fields inherited from class org.ozoneDB.ExternalDatabase
DefaultAccessRight, PROP_DEBUG, PROP_DIR, PROP_HOST, PROP_PASSWD, PROP_PORT, PROP_USER
 
Fields inherited from interface org.ozoneDB.OzoneInterface
AllLock, AllRead, GroupLock, GroupRead, Private, Public
 
Constructor Summary
ClientCacheDatabase(ExternalDatabase _delegate)
          Constructs a new ClientCacheDatabase with the given delegate as back-end.
ClientCacheDatabase(ExternalDatabase _delegate, boolean _debug)
          Constructs a new ClientCacheDatabase with the given delegate as back-end and the given debug option.
 
Method Summary
 void beginTX(AbstractTransaction tx)
          This method is never directly called from the client code.
 void checkpointTX(AbstractTransaction tx)
          This method is never directly called from the client code.
 void close()
          Close this database.
 void commitTX(AbstractTransaction tx, boolean onePhase)
          This method is never directly called from the client code.
 OzoneProxy copyObject(OzoneRemote obj)
          Copy an object.
 OzoneProxy createObject(java.lang.String className, int access, java.lang.String name, java.lang.String sig, java.lang.Object[] args)
          Creates an object by calling the constructor with the specified signature with the specified parameters.
 ExternalDatabase delegate()
           
 void deleteObject(OzoneRemote obj)
          Deletes the specified database object.
 OzoneCompatible fetch(OzoneProxy proxy, int lockLevel)
          Returns the actual target of the given proxy if the actual implementation is able to do so.
 long freeMemory()
          Return the amount of *total* free memory in the system.
 java.lang.Object invoke(OzoneProxy proxy, int methodIndex, java.lang.Object[] args, int lockLevel)
           
 java.lang.Object invoke(OzoneProxy proxy, java.lang.String methodName, java.lang.String sig, java.lang.Object[] args, int lockLevel)
          Invokes a method on the specified object.
 boolean isOpen()
           
 void joinTX(AbstractTransaction tx)
          This method is never directly called from the client code.
 boolean leaveTX(AbstractTransaction tx)
          This method is never directly called from the client code.
 void nameObject(OzoneRemote obj, java.lang.String name)
          Assigns the specified object with the specified name.
 ExternalTransaction newTransaction()
          Create a new transaction.
 OzoneProxy objectForName(java.lang.String name)
          Returns the object for the specifies name or null if there is no such object.
 void prepareTX(AbstractTransaction tx)
          This method is never directly called from the client code.
 void reloadClasses()
          Force the database server to reload all classes which extend OzoneObject.
 void rollbackTX(AbstractTransaction tx)
          This method is never directly called from the client code.
 
Methods inherited from class org.ozoneDB.ExternalDatabase
admin, createObject, createObject, createObject, createObject, createObject, createObject, createObject, createObject, createObject, currentExternalTransaction, currentTransaction, forThread, getStatusTX, getXAResource, notifyProxyDeath, objectForHandle, objectNames, openDatabase, openDatabase, xmlForObject, xmlForObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientCacheDatabase

public ClientCacheDatabase(ExternalDatabase _delegate)
Constructs a new ClientCacheDatabase with the given delegate as back-end.

Note: The size of the client side cache can be adjusted via the heap size of the VM (parameter -Xmx). The cache uses all available heap in its VM.

Parameters:
_delegate - The back-end database.

ClientCacheDatabase

public ClientCacheDatabase(ExternalDatabase _delegate,
                           boolean _debug)
Constructs a new ClientCacheDatabase with the given delegate as back-end and the given debug option.

Note: The size of the client side cache can be adjusted via the heap size of the VM (parameter -Xmx). The cache uses all available heap in its VM.

Parameters:
_delegate - The back-end database.
_debug -
Method Detail

delegate

public ExternalDatabase delegate()

isOpen

public boolean isOpen()
               throws java.lang.Exception
Overrides:
isOpen in class ExternalDatabase
Throws:
java.lang.Exception

close

public void close()
           throws java.lang.Exception
Description copied from class: ExternalDatabase
Close this database.

Overrides:
close in class ExternalDatabase
Throws:
java.lang.Exception

newTransaction

public ExternalTransaction newTransaction()
Description copied from class: ExternalDatabase
Create a new transaction. Before using this transaction it must be started.

Overrides:
newTransaction in class ExternalDatabase
Returns:
The newly created transaction.

beginTX

public void beginTX(AbstractTransaction tx)
             throws TransactionException,
                    java.io.IOException
Description copied from class: ExternalDatabase
This method is never directly called from the client code.

Overrides:
beginTX in class ExternalDatabase
Throws:
TransactionException
java.io.IOException

joinTX

public void joinTX(AbstractTransaction tx)
            throws TransactionException
Description copied from class: ExternalDatabase
This method is never directly called from the client code.

Overrides:
joinTX in class ExternalDatabase
Throws:
TransactionException

leaveTX

public boolean leaveTX(AbstractTransaction tx)
Description copied from class: ExternalDatabase
This method is never directly called from the client code.

Overrides:
leaveTX in class ExternalDatabase

checkpointTX

public void checkpointTX(AbstractTransaction tx)
                  throws TransactionException,
                         java.io.IOException
Description copied from class: ExternalDatabase
This method is never directly called from the client code.

Overrides:
checkpointTX in class ExternalDatabase
Throws:
TransactionException
java.io.IOException

prepareTX

public void prepareTX(AbstractTransaction tx)
               throws TransactionException,
                      java.io.IOException
Description copied from class: ExternalDatabase
This method is never directly called from the client code.

Overrides:
prepareTX in class ExternalDatabase
Throws:
TransactionException
java.io.IOException

commitTX

public void commitTX(AbstractTransaction tx,
                     boolean onePhase)
              throws TransactionException,
                     java.io.IOException
Description copied from class: ExternalDatabase
This method is never directly called from the client code.

Overrides:
commitTX in class ExternalDatabase
Throws:
TransactionException
java.io.IOException

rollbackTX

public void rollbackTX(AbstractTransaction tx)
                throws TransactionException,
                       java.io.IOException
Description copied from class: ExternalDatabase
This method is never directly called from the client code.

Overrides:
rollbackTX in class ExternalDatabase
Throws:
TransactionException
java.io.IOException

reloadClasses

public void reloadClasses()
                   throws java.lang.Exception
Force the database server to reload all classes which extend OzoneObject. This is useful while testing new classes.

Specified by:
reloadClasses in interface OzoneInterface
Overrides:
reloadClasses in class ExternalDatabase
Throws:
java.lang.Exception

createObject

public OzoneProxy createObject(java.lang.String className,
                               int access,
                               java.lang.String name,
                               java.lang.String sig,
                               java.lang.Object[] args)
                        throws java.lang.RuntimeException
Description copied from interface: OzoneInterface
Creates an object by calling the constructor with the specified signature with the specified parameters. Generated proxy objects use this method.

Specified by:
createObject in interface OzoneInterface
Overrides:
createObject in class ExternalDatabase
Throws:
java.lang.RuntimeException

deleteObject

public void deleteObject(OzoneRemote obj)
                  throws java.lang.RuntimeException
Description copied from interface: OzoneInterface
Deletes the specified database object. The specified object is an instance of OzoneProxy which you may have created by createObject().

Specified by:
deleteObject in interface OzoneInterface
Overrides:
deleteObject in class ExternalDatabase
Throws:
java.lang.RuntimeException

copyObject

public OzoneProxy copyObject(OzoneRemote obj)
                      throws java.lang.Exception
Description copied from interface: OzoneInterface
Copy an object. The new objects gets its own object ID. The specified object is an instance of OzoneProxy which you may have created by createObject().

Specified by:
copyObject in interface OzoneInterface
Overrides:
copyObject in class ExternalDatabase
Throws:
java.lang.Exception

nameObject

public void nameObject(OzoneRemote obj,
                       java.lang.String name)
                throws java.lang.Exception
Description copied from interface: OzoneInterface
Assigns the specified object with the specified name. This can also be done at object creation time. The specified object is an instance of OzoneProxy which you may have created by createObject().

Specified by:
nameObject in interface OzoneInterface
Overrides:
nameObject in class ExternalDatabase
Throws:
java.lang.Exception

objectForName

public OzoneProxy objectForName(java.lang.String name)
                         throws java.lang.Exception
Description copied from interface: OzoneInterface
Returns the object for the specifies name or null if there is no such object.

Specified by:
objectForName in interface OzoneInterface
Overrides:
objectForName in class ExternalDatabase
Throws:
java.lang.Exception

invoke

public java.lang.Object invoke(OzoneProxy proxy,
                               java.lang.String methodName,
                               java.lang.String sig,
                               java.lang.Object[] args,
                               int lockLevel)
                        throws java.lang.Exception
Description copied from interface: OzoneInterface
Invokes a method on the specified object. This method is called by proxy objects to route the call to the corresponding database object. A client will never call this method explicitly.

Specified by:
invoke in interface OzoneInterface
Overrides:
invoke in class ExternalDatabase
Throws:
java.lang.Exception

invoke

public java.lang.Object invoke(OzoneProxy proxy,
                               int methodIndex,
                               java.lang.Object[] args,
                               int lockLevel)
                        throws java.lang.Exception
Specified by:
invoke in interface OzoneInterface
Overrides:
invoke in class ExternalDatabase
Throws:
java.lang.Exception

fetch

public OzoneCompatible fetch(OzoneProxy proxy,
                             int lockLevel)
                      throws java.lang.Exception,
                             ObjectNotFoundException,
                             java.io.IOException,
                             java.lang.ClassNotFoundException,
                             TransactionException,
                             org.ozoneDB.core.TransactionError
Description copied from interface: OzoneInterface
Returns the actual target of the given proxy if the actual implementation is able to do so. A client will never call this method explicitly.

Specified by:
fetch in interface OzoneInterface
Overrides:
fetch in class ExternalDatabase
Throws:
java.lang.Exception
ObjectNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
TransactionException
org.ozoneDB.core.TransactionError

freeMemory

public long freeMemory()
Return the amount of *total* free memory in the system. The results returned by Runtime.freeMemory() may change overtime and so its useless for ozone.

Note: this will not work properly if some kind of weal references are used in this VM. In case of empty space we need to force teh GC to also free weak references.


ozone API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.