org.objectweb.perseus.concurrency.pessimistic

Class PessimisticConcurrencyManager

Implemented Interfaces:
AttributeController, BindingController, ConcurrencyManager, LifeCycleController, PessimisticConcurrencyManagerAC
Known Direct Subclasses:
DistributedConcurrencyManager

public abstract class PessimisticConcurrencyManager
extends java.lang.Object
implements ConcurrencyManager, BindingController, PessimisticConcurrencyManagerAC, LifeCycleController

Author:
E. Bruneton

Nested Class Summary

protected static class
PessimisticConcurrencyManager.ContextInfo
Information associated to a context

Field Summary

static String
DEPENDENCY_GRAPH_BINDING
static short
POLICY_MUTEX
static short
POLICY_RW_FIFO
static short
POLICY_RW_PRIORITY2READERS
static short
POLICY_UNDEFINED
protected Map
contextInfos
A map associating a ContextInfo to each context.
protected DependencyGraph
dg
protected Map
locks
A map associating locks to all oids in all active contexts.
protected Logger
logger
static String[]
policyStringVal

Constructor Summary

PessimisticConcurrencyManager()
PessimisticConcurrencyManager(short policy)

Method Summary

void
abort(Object ctx)
This method allows to release the resources allocated in a given context.
void
begin(Object ctx)
This method records the start of an execution context.
void
bindFc(String s, Object o)
void
finalize(Object ctx)
This method marks the end of accesses made by the execution context.
protected PessimisticConcurrencyManager.ContextInfo
getContextInfo(Object ctxt)
String
getFcState()
protected Lock
getLock(Object oid, Object hints)
Returns the lock associated to the given oid.
String
getPolicy()
protected Object
getState(Object ctx, Object resourceId, Lock lock, Object hints)
String[]
listFc()
Object
lookupFc(String s)
Object
readIntention(Object ctx, Object resourceId, Object hints)
This method records an access intention to a data object in read mode.
void
setPolicy(String policy)
void
startFc()
void
stopFc()
void
unbindFc(String s)
boolean
validate(Object ctx)
This method requests the validation os accesses made by the context.
Object
writeIntention(Object ctx, Object resourceId, Object hints)
This method records an access intention to a data object in write mode.

Field Details

DEPENDENCY_GRAPH_BINDING

public static final String DEPENDENCY_GRAPH_BINDING


POLICY_MUTEX

public static final short POLICY_MUTEX

Field Value:
1


POLICY_RW_FIFO

public static final short POLICY_RW_FIFO

Field Value:
3


POLICY_RW_PRIORITY2READERS

public static final short POLICY_RW_PRIORITY2READERS

Field Value:
2


POLICY_UNDEFINED

public static final short POLICY_UNDEFINED

Field Value:
0


contextInfos

protected Map contextInfos
A map associating a ContextInfo to each context.


dg

protected DependencyGraph dg


locks

protected Map locks
A map associating locks to all oids in all active contexts.


logger

protected Logger logger


policyStringVal

public static final String[] policyStringVal

Constructor Details

PessimisticConcurrencyManager

public PessimisticConcurrencyManager()
            throws ConcurrencyException


PessimisticConcurrencyManager

public PessimisticConcurrencyManager(short policy)
            throws ConcurrencyException

Method Details

abort

public void abort(Object ctx)
This method allows to release the resources allocated in a given context. This method should be called when the validate method has returned false.
Specified by:
abort in interface ConcurrencyManager


begin

public void begin(Object ctx)
This method records the start of an execution context. It can be a transaction starting.
Specified by:
begin in interface ConcurrencyManager

Parameters:
ctx - is the context


bindFc

public void bindFc(String s,
                   Object o)
            throws IllegalBindingException,
                   NoSuchInterfaceException


finalize

public void finalize(Object ctx)
This method marks the end of accesses made by the execution context. This method should be called when the validate method has returned true.
Specified by:
finalize in interface ConcurrencyManager


getContextInfo

protected PessimisticConcurrencyManager.ContextInfo getContextInfo(Object ctxt)


getFcState

public String getFcState()


getLock

protected Lock getLock(Object oid,
                       Object hints)
Returns the lock associated to the given oid.

Parameters:
oid - an object identifier.

Returns:
the lock associated to the given oid.


getPolicy

public String getPolicy()
Specified by:
getPolicy in interface PessimisticConcurrencyManagerAC


getState

protected Object getState(Object ctx,
                          Object resourceId,
                          Lock lock,
                          Object hints)
            throws ConcurrencyException

Parameters:
ctx - is the context using the resource
resourceId - is the resource identifier
lock - is the lock instance matching the resource
hints - uses to give information on access

Returns:
the resource state to use


listFc

public String[] listFc()


lookupFc

public Object lookupFc(String s)
            throws NoSuchInterfaceException


readIntention

public Object readIntention(Object ctx,
                            Object resourceId,
                            Object hints)
            throws ConcurrencyException
This method records an access intention to a data object in read mode.
Specified by:
readIntention in interface ConcurrencyManager

Parameters:
ctx - is an identifier of the execution context. It can be a transaction handle.
resourceId - is the resource identifier
hints - is an object parameter permiting to some implementation to do some action at "readIntention time".

Returns:
null or an object depending on the ConcurrencyManager type

Throws:
ConcurrencyException - if the no resource are available for this resource identifer or if there is a concurrency problem. In this last case that means the context should be cancelled.


setPolicy

public void setPolicy(String policy)
            throws IllegalLifeCycleException
Specified by:
setPolicy in interface PessimisticConcurrencyManagerAC


startFc

public void startFc()
            throws IllegalLifeCycleException


stopFc

public void stopFc()
            throws IllegalLifeCycleException


unbindFc

public void unbindFc(String s)
            throws NoSuchInterfaceException


validate

public boolean validate(Object ctx)
This method requests the validation os accesses made by the context. It retrieves a boolean value to indicate if the accesses are validate or not.
Specified by:
validate in interface ConcurrencyManager


writeIntention

public Object writeIntention(Object ctx,
                             Object resourceId,
                             Object hints)
            throws ConcurrencyException
This method records an access intention to a data object in write mode. A call to the readIntention is necessary before a call to this method.
Specified by:
writeIntention in interface ConcurrencyManager

Parameters:
ctx - is an identifier of the execution context. It can be a transaction handle.
resourceId - is the resource identifier
hints - is an object parameter permiting to some implementation to do some action at "readIntention time".

Returns:
null or an object depending on the ConcurrencyManager type

Throws:
ConcurrencyException - if the no resource are available for this resource identifer or if there is a concurrency problem. In this last case that means the context should be cancelled.


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