org.xvsm.coordinators
Class GenericKeyCoordinator

Package class diagram package GenericKeyCoordinator
java.lang.Object
  extended by org.xvsm.interfaces.ICoordinator
      extended by org.xvsm.interfaces.IExplicitCoordinator
          extended by org.xvsm.coordinators.GenericKeyCoordinator
All Implemented Interfaces:
java.io.Serializable

public class GenericKeyCoordinator
extends IExplicitCoordinator

Author:
Christian Schreiber, Michael Proestler
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.xvsm.interfaces.ICoordinator
properties
 
Constructor Summary
GenericKeyCoordinator()
          Default Constructor.
 
Method Summary
 void commit(Transaction tx)
          Commits an existing Transaction for this container.
 void commitSubTransaction(Transaction tx)
          Commits an existing Transaction for this container.
 void delete(Transaction tx, Entry e)
          Deletes one specific entry.
 java.lang.Class<? extends Selector> getDefaultSelector()
          Returns the default Selector for this Coordinator.
 java.util.List<Entry> read(Transaction tx, Selector selector, java.util.List<Entry> centries)
          Read Entrys that match with the Selector.
 void rollback(Transaction tx)
          Does a rollback on this Transaction.
 void setMaxContainerSize(int size)
          Sets the maximal containersize in the coordinator.
 Entry shift(Entry e, Transaction tx, Selector s)
          Writes the Entry.
 void write(Entry e, Transaction tx, Selector s)
          Tries to write the given Entry.
 
Methods inherited from class org.xvsm.interfaces.ICoordinator
aquireLock, commitLocks, getCref, getProperties, rollbackLocks, setCref, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericKeyCoordinator

public GenericKeyCoordinator()
Default Constructor.

Method Detail

commit

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

Specified by:
commit in class ICoordinator
Parameters:
tx - The Transaction that should be commited.
Throws:
TransactionLockException - thrown if a lock can not be aquired.

commitSubTransaction

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

Specified by:
commitSubTransaction in class ICoordinator
Parameters:
tx - The Transaction that should be commited.
Throws:
TransactionLockException

delete

public void delete(Transaction tx,
                   Entry e)
            throws TransactionLockException
Deletes one specific entry..

Specified by:
delete in class ICoordinator
Parameters:
tx - A Transaction under which the operation executes
e - The entry to delete.
Throws:
TransactionLockException - thrown if a lock can not be aquired because another transaction uses it.

read

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

Specified by:
read in class ICoordinator
Parameters:
tx - A Transaction under which the operation executes
selector - The Selector that must match.
centries - A List of Entrys to operate on. Null if it should operates on all known entries.
Returns:
a List of all matching entries.
Throws:
TransactionLockException - thrown if a lock can not be aquired because another transaction uses it.
CountNotMetException - thrown if there are not enough entries to fulfill the count of the selector.

rollback

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

Specified by:
rollback in class ICoordinator
Parameters:
tx - The Transaction that should perform a rollback.
Throws:
TransactionLockException - thrown if a lock can not be aquired.

setMaxContainerSize

public void setMaxContainerSize(int size)
Sets the maximal containersize in the coordinator. Can be used to optimize internal structures, and is needed for shift decisions..

Specified by:
setMaxContainerSize in class ICoordinator
Parameters:
size - the maximal size of entries in the coordinator.

shift

public Entry shift(Entry e,
                   Transaction tx,
                   Selector s)
            throws TransactionLockException,
                   CannotShiftException
Writes the Entry. If there is no place left, another Entry will be deleted (shifted)..

Specified by:
shift in class ICoordinator
Parameters:
e - The Entry that will be written.
tx - A Transaction under which the operation executes
s - the Selector used for writing.
Returns:
The shifted Entry of null if no entry has been shifted.
Throws:
TransactionLockException - thrown if a lock can not be aquired because another transaction uses it.
CannotShiftException - thrown if the coordinator can not decide which entry has to be shifted.

write

public void write(Entry e,
                  Transaction tx,
                  Selector s)
           throws ContainerFullException,
                  TransactionLockException
Tries to write the given Entry. Otherwise ContainerFullException can be raised..

Specified by:
write in class ICoordinator
Parameters:
e - The Entry that will be written.
tx - A Transaction under which the operation executes
s - the Selector used for writing.
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 - thrown if a lock can not be aquired because another transaction uses it.

getDefaultSelector

public java.lang.Class<? extends Selector> getDefaultSelector()
Returns the default Selector for this Coordinator..

Specified by:
getDefaultSelector in class ICoordinator
Returns:
the default Selector for this Coordinator.


Copyright © 2009. All Rights Reserved.