org.xvsm.internal
Class ContainerEngine

Package class diagram package ContainerEngine
java.lang.Object
  extended by org.xvsm.internal.ContainerEngine
All Implemented Interfaces:
IContainerEngine

public class ContainerEngine
extends java.lang.Object
implements IContainerEngine

Author:
Christian Schreiber, Michael Proestler

Constructor Summary
ContainerEngine()
          Creates a new unbounded Container.
ContainerEngine(int size)
          Creates a new unbounded Container.
 
Method Summary
 void addCoordinator(java.lang.Class<? extends Selector> s, ICoordinator c)
          Adds a coordinator to the engine.
 void commit(Transaction txn)
          Commits an existing Transaction for this container.
protected  void commitEntryLocks(Transaction tx)
          Updates the lock on all entries which have been modified in this container with tx.
 void commitSubTransaction(Transaction txn)
          Commits an existing Transaction for this container.
 int currentSize()
          Returns the current size of the container.
 java.util.List<ICoordinator> getCoordinators()
          Get a List of all Coordinators supported by this Container.
 ICoordinator getCoordTypefromSelector(java.lang.Class<? extends Selector> s)
          Returns the coordination Type for a given Selector class.
 ContainerRef getCref()
          Get the ContainerRef of the container.
 int getSize()
          Get the size.
 java.util.List<Entry> read(Transaction tx, java.util.List<Selector> selectors)
          Read Entrys that match with the Selector.
 void rollback(Transaction txn)
          Does a rollback on this Transaction.
protected  void rollbackEntryLocks(Transaction tx)
          Updates the lock on all entries which have been modified in this container with tx.
 void setCref(ContainerRef cref)
          Set the ContainerRef of the container.
 java.util.List<Entry> shift(Entry entry, Transaction tx)
          Writes the Entries into the persistent mechanism.
 java.util.List<Entry> take(Transaction tx, java.util.List<Selector> selectors)
          Take Entrys that match with the Selector.
 void write(Entry entry, Transaction tx)
          Writes the Entry into the persistent mechanism.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerEngine

public ContainerEngine()
Creates a new unbounded Container. Random Coordination type is added to the implicitCoordinationTypes.


ContainerEngine

public ContainerEngine(int size)
Creates a new unbounded Container. Random Coordination type is added to the implicitCoordinationTypes.

Parameters:
size - the size of the container.
Method Detail

commit

public void commit(Transaction txn)
            throws TransactionLockException
Commits an existing Transaction for this container..

Specified by:
commit in interface IContainerEngine
Parameters:
txn - The Transaction that should be committed.
Throws:
TransactionLockException - might be thrown if an entry or container is locked by another transaction.

commitSubTransaction

public void commitSubTransaction(Transaction txn)
                          throws TransactionLockException
Commits an existing Transaction for this container..

Specified by:
commitSubTransaction in interface IContainerEngine
Parameters:
txn - The Transaction that should be committed.
Throws:
TransactionLockException - might be thrown if an entry or container is locked by another transaction.

rollback

public void rollback(Transaction txn)
              throws TransactionLockException
Does a rollback on this Transaction..

Specified by:
rollback in interface IContainerEngine
Parameters:
txn - The Transaction that should be rollbacked.
Throws:
TransactionLockException - might be thrown if an entry or container is locked by another transaction.

getSize

public int getSize()
Get the size..

Specified by:
getSize in interface IContainerEngine
Returns:
the size of the container.

read

public java.util.List<Entry> read(Transaction tx,
                                  java.util.List<Selector> selectors)
                           throws TransactionLockException,
                                  NoSuchCoordinationTypeException,
                                  CountNotMetException
Read Entrys that match with the Selector..

Specified by:
read in interface IContainerEngine
Parameters:
tx - A Transaction under which the operation executes
selectors - A List of Selectors that must match.
Returns:
a List of all matching entries.
Throws:
TransactionLockException - might be thrown if an entry or container is locked by another transaction.
NoSuchCoordinationTypeException - thrown when there is a selector which needs a coordination type which has not been activated on the container.
CountNotMetException - thrown if there are not enough entries to fulfill the count of the selector.

write

public void write(Entry entry,
                  Transaction tx)
           throws ContainerFullException,
                  TransactionLockException,
                  NoSuchCoordinationTypeException
Writes the Entry into the persistent mechanism. Otherwise ContainerFullException can be raised..

Specified by:
write in interface IContainerEngine
Parameters:
entry - the entry to write.
tx - A Transaction under which the operation executes
Throws:
ContainerFullException - thrown when the entry can not be written because there is no free place for it (e.g. full bounded container, vector position already used, key already present).
TransactionLockException - might be thrown if an entry or container is locked by another transaction.
NoSuchCoordinationTypeException - thrown when there is a selector which needs a coordination type which has not been activated on the container

getCoordTypefromSelector

public ICoordinator getCoordTypefromSelector(java.lang.Class<? extends Selector> s)
                                      throws NoSuchCoordinationTypeException
Returns the coordination Type for a given Selector class..

Specified by:
getCoordTypefromSelector in interface IContainerEngine
Parameters:
s - the class of the selector.
Returns:
the ICoordinator matching the given selector or null if there is no matching ICoordinator.
Throws:
NoSuchCoordinationTypeException - if the no coordination type for the given selector can be found.

shift

public java.util.List<Entry> shift(Entry entry,
                                   Transaction tx)
                            throws TransactionLockException,
                                   NoSuchCoordinationTypeException
Writes the Entries into the persistent mechanism..

Specified by:
shift in interface IContainerEngine
Parameters:
entry - the entry to shift.
tx - A Transaction under which the operation executes
Returns:
the shifted entries.
Throws:
TransactionLockException - might be thrown if an entry or container is locked by another transaction.
NoSuchCoordinationTypeException - thrown when there is a selector which needs a coordination type which has not been activated on the container.

take

public java.util.List<Entry> take(Transaction tx,
                                  java.util.List<Selector> selectors)
                           throws TransactionLockException,
                                  NoSuchCoordinationTypeException,
                                  CountNotMetException
Take Entrys that match with the Selector..

Specified by:
take in interface IContainerEngine
Parameters:
tx - A Transaction under which the operation executes
selectors - A List of Selectors that must match.
Returns:
a List of all matching entries.
Throws:
TransactionLockException - might be thrown if an entry or container is locked by another transaction.
NoSuchCoordinationTypeException - thrown when there is a selector which needs a coordination type which has not been activated on the container.
CountNotMetException - thrown if there are not enough entries to fulfill the count of the selector.

getCref

public ContainerRef getCref()
Get the ContainerRef of the container.

Specified by:
getCref in interface IContainerEngine
Returns:
the ContainerRef

setCref

public void setCref(ContainerRef cref)
Set the ContainerRef of the container.

Specified by:
setCref in interface IContainerEngine
Parameters:
cref - the new ContainerRef

addCoordinator

public void addCoordinator(java.lang.Class<? extends Selector> s,
                           ICoordinator c)
Adds a coordinator to the engine. If a coordinator has been added with the same selector class the old coordinator will be replaced by the new one..

Specified by:
addCoordinator in interface IContainerEngine
Parameters:
s - the class of the selector to register the coordinator with.
c - the new coordinator.

getCoordinators

public java.util.List<ICoordinator> getCoordinators()
Get a List of all Coordinators supported by this Container.

Specified by:
getCoordinators in interface IContainerEngine
Returns:
a List of all Coordinators supported by this Container.

commitEntryLocks

protected void commitEntryLocks(Transaction tx)
                         throws TransactionLockException
Updates the lock on all entries which have been modified in this container with tx.
The locks will be set to the father transaction of tx or to null if tx has no father.

Parameters:
tx - the transaction to commit.
Throws:
TransactionLockException - thrown if the lock can not be acquired.

rollbackEntryLocks

protected void rollbackEntryLocks(Transaction tx)
                           throws TransactionLockException
Updates the lock on all entries which have been modified in this container with tx.
The locks will be null.

Parameters:
tx - the transaction to rollback.
Throws:
TransactionLockException - thrown if the lock can not be aquired.

currentSize

public int currentSize()
Returns the current size of the container..

Specified by:
currentSize in interface IContainerEngine
Returns:
the number of entries currently in the container.


Copyright © 2009. All Rights Reserved.