ca.mcgill.sel.aspectoptimaomtt.interfacing
Class AspectOPTIMAOMTT

java.lang.Object
  extended by ca.mcgill.sel.aspectoptimaomtt.interfacing.AspectOPTIMAOMTT

public class AspectOPTIMAOMTT
extends java.lang.Object


Constructor Summary
AspectOPTIMAOMTT()
           
 
Method Summary
static boolean abortTransactionOfCurrentThread()
          Aborts the transaction that is associated to the currently active thread.
static boolean abortTransactionOfForeignThread(OMTTThread thread)
          Aborts the transaction that is associated to the currently active thread.
static OMTTThread beginAndRunTransactionInNewThread(java.lang.Runnable r, java.lang.String updateStrategy, java.lang.String concurrencyControl, boolean nested)
          Begins an OpenMultithreadedTransaction in a new thread using the passed update strategy and concurrency control mechanism.
static OMTTThread beginAndRunTransactionInNewThread(java.lang.Runnable r, java.lang.String updateStrategy, java.lang.String concurrencyControl, boolean nested, int minParticipantCount, int maxParticipantCount)
          Begins an OpenMultithreadedTransaction in a new thread using the passed update strategy and concurrency control mechanism and sets the minimal and maximal number of participants to the provided values.
static boolean beginChildTransaction()
          Begins a nested OpenMultithreadedTransaction as a child of the OpenMultithreadedTransaction that is associated to the currently active thread using the configuration parameters of the parent transaction.
static boolean beginTransactionInCurrentThread(java.lang.String updateStrategy, java.lang.String concurrencyControl, boolean nested)
          Begins an OpenMultithreadedTransaction using the passed update strategy and concurrency control mechanism.
static boolean beginTransactionInCurrentThread(java.lang.String updateStrategy, java.lang.String concurrencyControl, boolean nested, int minParticipantCount, int maxParticipantCount)
          Begins an OpenMultithreadedTransaction using the passed update strategy and concurrency control mechanism
and sets the minimal and maximal number of participants to the provided values.
static OMTTThread beginTransactionInNewThread(java.lang.String updateStrategy, java.lang.String concurrencyControl, boolean nested)
          Begins an OpenMultithreadedTransaction in a new thread using the passed update strategy and concurrency control mechanism.
static OMTTThread beginTransactionInNewThread(java.lang.String updateStrategy, java.lang.String concurrencyControl, boolean nested, int minParticipantCount, int maxParticipantCount)
          Begins an OpenMultithreadedTransaction in a new thread using the passed update strategy and concurrency control mechanism and sets the minimal and maximal number of participants to the provided values.
static boolean commitTransactionOfCurrentAndSpawnedThreads()
          Commits the OpenMultithreadedTransaction that is associated to the currently active thread.
static boolean commitTransactionOfCurrentThread()
          Commits the OpenMultithreadedTransaction that is associated to the currently active thread.
static boolean commitTransactionOfForeignThread(OMTTThread thread)
          Commits the OpenMultithreadedTransaction that is associated to the thread that is passed as an argument
static
<T> OMTTThread
getThread(T key)
          Returns the thread that is mapped to the passed key.
static boolean joinAndRunTransactionWithExistingThread(java.lang.Runnable r, OMTTThread threadToJoin, OMTTThread joiningThread)
          Lets the thread that is passed as joiningThread join the OpenMultithreadedTransaction of the thread that was passed as threadToJoin.
static boolean joinCurrentTransactionWithExistingThread(OMTTThread joiningThread)
          Lets the thread that is passed as joiningThread join the OpenMultithreadedTransaction of the currently executing thread.
static boolean joinTransactionWithCurrentThread(OMTTThread threadToJoin)
          Lets the currently executing thread join the OpenMultithreadedTransaction of the thread that was passed as an argument.
static boolean joinTransactionWithExistingThread(OMTTThread threadToJoin, OMTTThread joiningThread)
          Lets the thread that is passed as joiningThread join the OpenMultithreadedTransaction of the thread that was passed as threadToJoin.
static
<T> void
mapKeyToThread(T key, OMTTThread thread)
          Maps the passed key object to the passed thread for futher reference.
static boolean run(java.lang.Runnable runnable)
          Runs the passed runnable in a new OMTTThread.
static void setMinParticipantCountInCurrentThread(int min)
          Sets the minimal number of participants that is required to begin a transaction to the passed value for the transaction of the current participant.
static void setMinParticipantCountInExistingThread(OMTTThread thread, int min)
           
static OMTTThread spawnAndReturnTransactionParticipantFromExistingThread(OMTTThread spawningThread)
          Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the thread that was passed as an argument.
static OMTTThread spawnAndRunTransactionParticipantFromCurrentThread(java.lang.Runnable r)
          Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the currently executing thread.
static void spawnRunAndForgetTransactionParticipantFromExistingThread(java.lang.Runnable r, OMTTThread spawningThread)
          Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the thread that was passed as an argument.
static OMTTThread spawnRunAndReturnTransactionParticipantFromExistingThread(java.lang.Runnable r, OMTTThread spawningThread)
          Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the thread that was passed as an argument.
static OMTTThread spawnTransactionParticipantFromCurrentThread()
          Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the currently executing thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AspectOPTIMAOMTT

public AspectOPTIMAOMTT()
Method Detail

abortTransactionOfCurrentThread

public static boolean abortTransactionOfCurrentThread()
Aborts the transaction that is associated to the currently active thread.

Returns:
true if the current transaction was successfully aborted, false in case of any error

abortTransactionOfForeignThread

public static boolean abortTransactionOfForeignThread(OMTTThread thread)
Aborts the transaction that is associated to the currently active thread.

Returns:
true if the current transaction was successfully aborted, false in case of any error

beginAndRunTransactionInNewThread

public static OMTTThread beginAndRunTransactionInNewThread(java.lang.Runnable r,
                                                           java.lang.String updateStrategy,
                                                           java.lang.String concurrencyControl,
                                                           boolean nested)
Begins an OpenMultithreadedTransaction in a new thread using the passed update strategy and concurrency control mechanism. Runs the passed Runnable immediately afterwards in the newly created thread. This returned new OMTTThread provides methods for enqueueing new jobs.
Allows for nested transactions if the parameter nested is true.
Note that the return value can simply be ignored if the new thread should never execute anything else than the passed Runnable.

Parameters:
updateStrategy - "CHECKPOINTING" or "DEFERRING"
concurrencyControl - "TWOPHASELOCKING" or "OPTIMISTICVALIDATION"
nested - whether nested child transactions should be allowed or not
Returns:
the new OMTTThread (extends Thread) in which the transaction was started if it was started successfully, null in case of any error

beginAndRunTransactionInNewThread

public static OMTTThread beginAndRunTransactionInNewThread(java.lang.Runnable r,
                                                           java.lang.String updateStrategy,
                                                           java.lang.String concurrencyControl,
                                                           boolean nested,
                                                           int minParticipantCount,
                                                           int maxParticipantCount)
Begins an OpenMultithreadedTransaction in a new thread using the passed update strategy and concurrency control mechanism and sets the minimal and maximal number of participants to the provided values. Runs the passed Runnable immediately afterwards in the newly created thread. This returned new OMTTThread provides methods for enqueueing new jobs.
Allows for nested transactions if the parameter nested is true.
Note that the return value can simply be ignored if the new thread should never execute anything else than the passed Runnable.

Parameters:
updateStrategy - "CHECKPOINTING" or "DEFERRING"
concurrencyControl - "TWOPHASELOCKING" or "OPTIMISTICVALIDATION"
nested - whether nested child transactions should be allowed or not
Returns:
the new OMTTThread (extends Thread) in which the transaction was started if it was started successfully, null in case of any error

beginChildTransaction

public static boolean beginChildTransaction()
Begins a nested OpenMultithreadedTransaction as a child of the OpenMultithreadedTransaction that is associated to the currently active thread using the configuration parameters of the parent transaction.

Returns:
true if the corresponding transaction was successfully started, false in case of any error

beginTransactionInCurrentThread

public static boolean beginTransactionInCurrentThread(java.lang.String updateStrategy,
                                                      java.lang.String concurrencyControl,
                                                      boolean nested)
Begins an OpenMultithreadedTransaction using the passed update strategy and concurrency control mechanism.
Allows for nested transactions if the parameter nested is true.

Parameters:
updateStrategy - "CHECKPOINTING" or "DEFERRING"
concurrencyControl - "TWOPHASELOCKING" or "OPTIMISTICVALIDATION"
nested - whether nested child transactions should be allowed or not
Returns:
true if the corresponding transaction was successfully started, false in case of any error

beginTransactionInCurrentThread

public static boolean beginTransactionInCurrentThread(java.lang.String updateStrategy,
                                                      java.lang.String concurrencyControl,
                                                      boolean nested,
                                                      int minParticipantCount,
                                                      int maxParticipantCount)
Begins an OpenMultithreadedTransaction using the passed update strategy and concurrency control mechanism
and sets the minimal and maximal number of participants to the provided values. Allows for nested transactions if the parameter nested is true.

Parameters:
updateStrategy - "CHECKPOINTING" or "DEFERRING"
concurrencyControl - "TWOPHASELOCKING" or "OPTIMISTICVALIDATION"
nested - whether nested child transactions should be allowed or not
Returns:
true if the corresponding transaction was successfully started, false in case of any error

beginTransactionInNewThread

public static OMTTThread beginTransactionInNewThread(java.lang.String updateStrategy,
                                                     java.lang.String concurrencyControl,
                                                     boolean nested)
Begins an OpenMultithreadedTransaction in a new thread using the passed update strategy and concurrency control mechanism. The returned new OMTTThread provides methods for enqueueing new jobs.
Allows for nested transactions if the parameter nested is true.

Parameters:
updateStrategy - "CHECKPOINTING" or "DEFERRING"
concurrencyControl - "TWOPHASELOCKING" or "OPTIMISTICVALIDATION"
nested - whether nested child transactions should be allowed or not
Returns:
the new OMTTThread (extends Thread) in which the transaction was started if it was started successfully, null in case of any error

beginTransactionInNewThread

public static OMTTThread beginTransactionInNewThread(java.lang.String updateStrategy,
                                                     java.lang.String concurrencyControl,
                                                     boolean nested,
                                                     int minParticipantCount,
                                                     int maxParticipantCount)
Begins an OpenMultithreadedTransaction in a new thread using the passed update strategy and concurrency control mechanism and sets the minimal and maximal number of participants to the provided values. The returned new OMTTThread provides methods for enqueueing new jobs.
Allows for nested transactions if the parameter nested is true.

Parameters:
updateStrategy - "CHECKPOINTING" or "DEFERRING"
concurrencyControl - "TWOPHASELOCKING" or "OPTIMISTICVALIDATION"
nested - whether nested child transactions should be allowed or not
Returns:
the new OMTTThread (extends Thread) in which the transaction was started if it was started successfully, null in case of any error

commitTransactionOfCurrentAndSpawnedThreads

public static boolean commitTransactionOfCurrentAndSpawnedThreads()
Commits the OpenMultithreadedTransaction that is associated to the currently active thread.

Returns:
true if the current transaction was successfully committed, false in case of any error

commitTransactionOfCurrentThread

public static boolean commitTransactionOfCurrentThread()
Commits the OpenMultithreadedTransaction that is associated to the currently active thread.

Returns:
true if the current transaction was successfully committed, false in case of any error

commitTransactionOfForeignThread

public static boolean commitTransactionOfForeignThread(OMTTThread thread)
Commits the OpenMultithreadedTransaction that is associated to the thread that is passed as an argument

Returns:
true if the associated transaction was successfully committed, false in case of any error

getThread

public static <T> OMTTThread getThread(T key)
Returns the thread that is mapped to the passed key.


joinAndRunTransactionWithExistingThread

public static boolean joinAndRunTransactionWithExistingThread(java.lang.Runnable r,
                                                              OMTTThread threadToJoin,
                                                              OMTTThread joiningThread)
Lets the thread that is passed as joiningThread join the OpenMultithreadedTransaction of the thread that was passed as threadToJoin.
Runs the passed Runnable immediately afterwards in the joining thread.

Parameters:
threadToJoin - the thread that is associated to the OpenMultithreadedTransaction that should be joined
joiningThread - the thread that should join the OpenMultithreadedTransaction of threadToJoin
Returns:
true if the corresponding transaction was successfully joined, false in case of any error

joinCurrentTransactionWithExistingThread

public static boolean joinCurrentTransactionWithExistingThread(OMTTThread joiningThread)
Lets the thread that is passed as joiningThread join the OpenMultithreadedTransaction of the currently executing thread.

Parameters:
joiningThread - the thread that should join the OpenMultithreadedTransaction of threadToJoin
Returns:
true if the corresponding transaction was successfully joined, false in case of any error

joinTransactionWithCurrentThread

public static boolean joinTransactionWithCurrentThread(OMTTThread threadToJoin)
Lets the currently executing thread join the OpenMultithreadedTransaction of the thread that was passed as an argument.

Parameters:
threadToJoin - the thread that is associated to the OpenMultithreadedTransaction that should be joined
Returns:
true if the corresponding transaction was successfully joined, false in case of any error

joinTransactionWithExistingThread

public static boolean joinTransactionWithExistingThread(OMTTThread threadToJoin,
                                                        OMTTThread joiningThread)
Lets the thread that is passed as joiningThread join the OpenMultithreadedTransaction of the thread that was passed as threadToJoin.

Parameters:
threadToJoin - the thread that is associated to the OpenMultithreadedTransaction that should be joined
joiningThread - the thread that should join the OpenMultithreadedTransaction of threadToJoin
Returns:
true if the corresponding transaction was successfully joined, false in case of any error

mapKeyToThread

public static <T> void mapKeyToThread(T key,
                                      OMTTThread thread)
Maps the passed key object to the passed thread for futher reference.


run

public static boolean run(java.lang.Runnable runnable)
Runs the passed runnable in a new OMTTThread.
This method is the entry point to the OMTT framework and every code that uses OMTT features must have been passed to his method in a runnable or it must have been executed by the framework itself through spawned threads.

Parameters:
runnable -
Returns:
true if the code was successfully run in a new OMTTThread, false in case of any error

setMinParticipantCountInCurrentThread

public static void setMinParticipantCountInCurrentThread(int min)
Sets the minimal number of participants that is required to begin a transaction to the passed value for the transaction of the current participant.


setMinParticipantCountInExistingThread

public static void setMinParticipantCountInExistingThread(OMTTThread thread,
                                                          int min)

spawnAndReturnTransactionParticipantFromExistingThread

public static OMTTThread spawnAndReturnTransactionParticipantFromExistingThread(OMTTThread spawningThread)
Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the thread that was passed as an argument.

Returns:
the new OMTTThread (extends Thread) that is associated to the spawned participant if it was started successfully, null in case of any error

spawnAndRunTransactionParticipantFromCurrentThread

public static OMTTThread spawnAndRunTransactionParticipantFromCurrentThread(java.lang.Runnable r)
Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the currently executing thread. Runs the passed Runnable in the newly spawned thread.

Returns:
the new OMTTThread (extends Thread) that is associated to the spawned participant if it was started successfully, null in case of any error

spawnRunAndForgetTransactionParticipantFromExistingThread

public static void spawnRunAndForgetTransactionParticipantFromExistingThread(java.lang.Runnable r,
                                                                             OMTTThread spawningThread)
Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the thread that was passed as an argument. Runs the passed Runnable in the newly spawned thread but doesn't wait for the newly spawned thread to return it.


spawnRunAndReturnTransactionParticipantFromExistingThread

public static OMTTThread spawnRunAndReturnTransactionParticipantFromExistingThread(java.lang.Runnable r,
                                                                                   OMTTThread spawningThread)
Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the thread that was passed as an argument. Runs the passed Runnable in the newly spawned thread.

Returns:
the new OMTTThread (extends Thread) that is associated to the spawned participant if it was started successfully, null in case of any error

spawnTransactionParticipantFromCurrentThread

public static OMTTThread spawnTransactionParticipantFromCurrentThread()
Spawns a participant of an OpenMultithreadedTransaction using the transaction that is associated to the currently executing thread.

Returns:
the new OMTTThread (extends Thread) that is associated to the spawned participant if it was started successfully, null in case of any error