org.objectweb.perseus.persistence.lib

Class TransactionalPersistenceManagerImpl

Implemented Interfaces:
BindingController, PersistenceManager, TransactionalPersistenceManager

public class TransactionalPersistenceManagerImpl
extends java.lang.Object
implements TransactionalPersistenceManager, BindingController

This class is an implementation of the TransactionalPersistenceManager interface. It manages the persistency, the concurrency and the caching of persistent objects. To do this it uses several other components: - a cache manager, - a concurrency manager, - a storage manager, - a state manager, - a memory instance manager, - a working set manager. This implementation is compliant to fractal by implementing the BindingController interface permitting the management of bindings between components.

Author:
S.Chassande-Barrioz, P.Dechamboux, O.Lobry, Y. Bersihand

Field Summary

static String
CACHE_MANAGER_BINDING
static String
CONCURRENCY_MANAGER_BINDING
static String
MEMORY_INSTANCE_MANAGER_BINDING
static String
STATE_MANAGER_BINDING
static String
STORAGE_MANAGER_BINDING
static String
UNBIND_MANAGER_BINDING
static String
WORKINGSET_MANAGER_BINDING
protected CacheManager
cache
The cache of the persistent object.
protected ConcurrencyManager
cm
The concurrency manager
protected Logger
logger
protected MemoryInstanceManager
mim
The factory of persistent objects
protected StateManager
stateManager
The manager of state of persistent object.
protected StorageManager
storage
The storage manager in charge of the I/O to the data support, and the naming management.
protected UnbindManager
unbindManager
protected WorkingSetManager
wsManager
The manager of working set instance.

Method Summary

void
accessCompletion(WorkingSet ws, State ce)
This method can be used to mark the end of an access to a data object.
void
begin(TransactionalWorkingSet tx)
converts a context to a transaction
protected void
bindCeInWS(State state, WorkingSet ws, byte mode)
Deprecated. Attaches a state to a working Set.
void
bindFc(String s, Object o)
protected void
checkCacheEntry(CacheEntry ce)
Check if a cache entry is already referenced in the cache.
void
close(WorkingSet context)
Closes and releases a context.
void
commit(TransactionalWorkingSet tx)
commits a transactional context.
WorkingSet
createWS(Object userObject)
creates a working set
WorkingSet
createWS(Object userObject, Object workingSetType)
creates a working set
boolean
evict(WorkingSet ws, Object oid, boolean force)
The unfix action is out of date.
int
evictAll(WorkingSet ws, boolean force)
This methods permits to try the cache eviction of all persistent object
State
export(WorkingSet ws, Object obj)
Given an object, this method creates the corresponding copy in permanent support.
State
export(WorkingSet ws, Object obj, Object hints)
This method permits to given some information to build the identifier of the new persistent object.
void
flush(WorkingSet ws, State stateToFlush)
This method permits to flush entries associated to a context.
void
flush(WorkingSet ws, StateFilter statefilter)
This method permits to flush entries associated to a context.
protected CacheEntry
getCacheEntry(WorkingSet ws, Object oid)
finds or creates the CacheEntry matching to an identifier.
String[]
listFc()
Object
lookupFc(String s)
boolean
prepare(TransactionalWorkingSet tx)
Prepare the transactinal context.
State
readIntention(WorkingSet ws, CacheEntry ce)
This method records an access intention to a data object in read mode.
State
readIntention(WorkingSet ws, Object oid)
This method records an access intention to a data object in read mode.
void
refresh(WorkingSet ws, CacheEntry ce)
Forget modifications of a dirty persistent object.
void
refresh(WorkingSet ws, Object oid)
Forget modifications of a dirty persistent object.
void
rollback(TransactionalWorkingSet tx)
rollbacks a transactional context.
void
unbind(WorkingSet ws, CacheEntry ce)
Detach a persistent object from the persistent support.
void
unbind(WorkingSet ws, Object oid)
Detach a persistent object from the persistent support.
void
unbindFc(String s)
State
unexport(WorkingSet ws, CacheEntry ce)
Deletes the binding between an in main-memory object, and its corresponding copy in permanent support.
State
unexport(WorkingSet ws, Object oid)
Deletes the binding between an in main-memory object, and its corresponding copy in permanent support.
State
writeIntention(WorkingSet ws, CacheEntry ce)
This method records an access intention to a data object in write mode.
State
writeIntention(WorkingSet ws, Object oid)
This method records an access intention to a data object in write mode.

Field Details

CACHE_MANAGER_BINDING

public static final String CACHE_MANAGER_BINDING


CONCURRENCY_MANAGER_BINDING

public static final String CONCURRENCY_MANAGER_BINDING


MEMORY_INSTANCE_MANAGER_BINDING

public static final String MEMORY_INSTANCE_MANAGER_BINDING


STATE_MANAGER_BINDING

public static final String STATE_MANAGER_BINDING


STORAGE_MANAGER_BINDING

public static final String STORAGE_MANAGER_BINDING


UNBIND_MANAGER_BINDING

public static final String UNBIND_MANAGER_BINDING


WORKINGSET_MANAGER_BINDING

public static final String WORKINGSET_MANAGER_BINDING


cache

protected CacheManager cache
The cache of the persistent object.


cm

protected ConcurrencyManager cm
The concurrency manager


logger

protected Logger logger


mim

protected MemoryInstanceManager mim
The factory of persistent objects


stateManager

protected StateManager stateManager
The manager of state of persistent object.


storage

protected StorageManager storage
The storage manager in charge of the I/O to the data support, and the naming management.


unbindManager

protected UnbindManager unbindManager


wsManager

protected WorkingSetManager wsManager
The manager of working set instance.

Method Details

accessCompletion

public void accessCompletion(WorkingSet ws,
                             State ce)
            throws PersistenceException
This method can be used to mark the end of an access to a data object.
Specified by:
accessCompletion in interface PersistenceManager

Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
ce - is the cache entry on which the access is finished.

Throws:
PersistenceException -


begin

public void begin(TransactionalWorkingSet tx)
            throws PersistenceException
converts a context to a transaction
Specified by:
begin in interface TransactionalPersistenceManager

Parameters:
tx - becomes transactional

Throws:
PersistenceException - if the context is already transactional.


bindCeInWS

protected void bindCeInWS(State state,
                          WorkingSet ws,
                          byte mode)
            throws PersistenceException

Deprecated. Attaches a state to a working Set.

Parameters:
state - is the state of the persistent object which must be attached to working set.
ws - is the working set to attach the state.


bindFc

public void bindFc(String s,
                   Object o)


checkCacheEntry

protected void checkCacheEntry(CacheEntry ce)
            throws PersistenceException
Check if a cache entry is already referenced in the cache. If the entry has not been found, the entry is bound in the cache.

Parameters:
ce - is the cache entry to check

Throws:
PersistenceException - if the cache is full or if another cache entry has been found in the cache with the same identifier.


close

public void close(WorkingSet context)
            throws PersistenceException
Closes and releases a context.
Specified by:
close in interface PersistenceManager

Parameters:
context - which must be closed

Throws:
PersistenceException - if the context is a transactional context which has not been commited or aborted.


commit

public void commit(TransactionalWorkingSet tx)
            throws PersistenceException
commits a transactional context. The call to the prepare method is required.
Specified by:
commit in interface TransactionalPersistenceManager

Parameters:
tx -

Throws:
PersistenceException - if an error raised during the commit operation, or if the context is not a transactional context.


createWS

public WorkingSet createWS(Object userObject)
            throws PersistenceException
creates a working set
Specified by:
createWS in interface PersistenceManager

Parameters:
userObject - can be an external user depending on the personnality.

Returns:
a new WorkingSet

Throws:
PersistenceException -


createWS

public WorkingSet createWS(Object userObject,
                           Object workingSetType)
            throws PersistenceException
creates a working set
Specified by:
createWS in interface PersistenceManager

Parameters:
userObject - can be an external user depending on the personnality.
workingSetType - is a type of the working set.

Returns:
a new WorkingSet

Throws:
PersistenceException -


evict

public boolean evict(WorkingSet ws,
                     Object oid,
                     boolean force)
            throws PersistenceException
The unfix action is out of date.
Specified by:
evict in interface PersistenceManager


evictAll

public int evictAll(WorkingSet ws,
                    boolean force)
            throws PersistenceException
This methods permits to try the cache eviction of all persistent object
Specified by:
evictAll in interface PersistenceManager

Returns:
the number of entry staying in the cache (not evicted)


export

public State export(WorkingSet ws,
                    Object obj)
            throws PersistenceException
Given an object, this method creates the corresponding copy in permanent support. At the same time, it establishes a binding between the object in main-memory and the permanent copy. Roughly, the internal tasks include: - Reserving space on permanent support, - Establishing a binding between the object in main memory and the permanent copy, - Marking the object as dirty, (internal or by the concurrency control module?) - Adding the object to the cache
Specified by:
export in interface PersistenceManager

Parameters:
obj - The object whose state is to be copied to

Throws:
PersistenceException - Whenever the object is invalid (e.g. NULL) or it has been previously bound to another oid.


export

public State export(WorkingSet ws,
                    Object obj,
                    Object hints)
            throws PersistenceException
This method permits to given some information to build the identifier of the new persistent object.
Specified by:
export in interface PersistenceManager

Parameters:
obj - The object whose state is to be copied to
hints - can be used to build the identifier of the object.


flush

public void flush(WorkingSet ws,
                  State stateToFlush)
            throws PersistenceException
This method permits to flush entries associated to a context.
Specified by:
flush in interface PersistenceManager

Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.

Throws:
PersistenceException - if the context is not valid.


flush

public void flush(WorkingSet ws,
                  StateFilter statefilter)
            throws PersistenceException
This method permits to flush entries associated to a context.
Specified by:
flush in interface PersistenceManager

Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
statefilter - is a filter of the state which must be flushed

Throws:
PersistenceException - if the context is not valid.


getCacheEntry

protected CacheEntry getCacheEntry(WorkingSet ws,
                                   Object oid)
            throws PersistenceException
finds or creates the CacheEntry matching to an identifier. If no cache antry matching the identifier is found in the cache, an new instance is created without state.

Parameters:
ws - if the WorkingSet requiring a CacheEntry.
oid - the identifier of the expected cache entry

Returns:
a cache entry instance (never null).

Throws:
PersistenceException - if it is not possible to instanciate a persistent object


listFc

public String[] listFc()


lookupFc

public Object lookupFc(String s)


prepare

public boolean prepare(TransactionalWorkingSet tx)
            throws PersistenceException
Prepare the transactinal context.
Specified by:
prepare in interface TransactionalPersistenceManager

Parameters:
tx - the

Returns:
true if the transaction can be commit or false is the transaction must be rolled back.

Throws:
PersistenceException - if an error raised during the prepare operation, or if the context is not a transactional context.


readIntention

public State readIntention(WorkingSet ws,
                           CacheEntry ce)
            throws PersistenceException
This method records an access intention to a data object in read mode.
Specified by:
readIntention in interface PersistenceManager

Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
ce - is the cache entry

Throws:
PersistenceException -


readIntention

public State readIntention(WorkingSet ws,
                           Object oid)
            throws PersistenceException
This method records an access intention to a data object in read mode.
Specified by:
readIntention in interface PersistenceManager

Parameters:
oid - is the object identifier.

Throws:
PersistenceException -


refresh

public void refresh(WorkingSet ws,
                    CacheEntry ce)
            throws PersistenceException
Forget modifications of a dirty persistent object. The state is re-read from the cache or later from the database. Be carefull the lock for the concurrency (read | write) is kept until the end of the context.
Specified by:
refresh in interface PersistenceManager

Parameters:
ws - is the current working set
ce - is the cache entry of the persistent object

Throws:
PersistenceException -


refresh

public void refresh(WorkingSet ws,
                    Object oid)
            throws PersistenceException
Forget modifications of a dirty persistent object. The state is re-read from the cache or later from the database. Be carefull the lock for the concurrency (read | write) is kept until the end of the context.
Specified by:
refresh in interface PersistenceManager

Parameters:
ws - is the current working set
oid - is the identifier of the persistent object

Throws:
PersistenceException -


rollback

public void rollback(TransactionalWorkingSet tx)
            throws PersistenceException
rollbacks a transactional context. The call to the prepare method is required.
Specified by:
rollback in interface TransactionalPersistenceManager

Parameters:
tx -

Throws:
PersistenceException - if an error raised during the rollback operation, or if the context is not a transactional context.


unbind

public void unbind(WorkingSet ws,
                   CacheEntry ce)
            throws PersistenceException
Detach a persistent object from the persistent support. After calling this method the persistent object is no more associated to the context and this instance is no more in the cache. If the persistent object has been modified, it is flushed. Be carefull the lock for the concurrency (read | write) is kept until the end of the context.
Specified by:
unbind in interface PersistenceManager

Parameters:
ws - is the current working set
ce - is the cache entry of the persistent object

Throws:
PersistenceException -


unbind

public void unbind(WorkingSet ws,
                   Object oid)
            throws PersistenceException
Detach a persistent object from the persistent support. After calling this method the persistent object is no more associated to the context and this instance is no more in the cache. If the persistent object has been modified, it is flushed. Be carefull the lock for the concurrency (read | write) is kept until the end of the context.
Specified by:
unbind in interface PersistenceManager

Parameters:
ws - is the current working set
oid - is the identifier of the persistent object

Throws:
PersistenceException -


unbindFc

public void unbindFc(String s)


unexport

public State unexport(WorkingSet ws,
                      CacheEntry ce)
            throws PersistenceException
Deletes the binding between an in main-memory object, and its corresponding copy in permanent support. At the same time, it frees (may be) the space in the permanent support allocated to the permanent copy.
Specified by:
unexport in interface PersistenceManager

Parameters:
ce - The identifier of the corresponding object to be destroyed.

Throws:
PersistenceException -


unexport

public State unexport(WorkingSet ws,
                      Object oid)
            throws PersistenceException
Deletes the binding between an in main-memory object, and its corresponding copy in permanent support. At the same time, it frees (may be) the space in the permanent support allocated to the permanent copy.
Specified by:
unexport in interface PersistenceManager

Parameters:
oid - The identifier of the corresponding object to be destroyed.

Throws:
PersistenceException -


writeIntention

public State writeIntention(WorkingSet ws,
                            CacheEntry ce)
            throws PersistenceException
This method records an access intention to a data object in write mode.
Specified by:
writeIntention in interface PersistenceManager

Parameters:
ce - is the cache entry.

Throws:
PersistenceException -


writeIntention

public State writeIntention(WorkingSet ws,
                            Object oid)
            throws PersistenceException
This method records an access intention to a data object in write mode.
Specified by:
writeIntention in interface PersistenceManager

Parameters:
oid - is the object identifier.

Throws:
PersistenceException -


Copyright © 2000-2002 France Telecom S.A., INRIA, IMAG-LSR All Rights Reserved.