edu.upc.dama.dex.core
Class Session

java.lang.Object
  extended by edu.upc.dama.dex.core.Session
All Implemented Interfaces:
java.io.Closeable

public final class Session
extends java.lang.Object
implements java.io.Closeable

A Session is a stateful period of activity of a user with the database engine.

Session

It is established when the user connects to the GraphPool (GraphPool.newSession()), and it is closed later by the user when the connection to the GraphPool is no longer required (Session.close()).

All temporary data obtained within a Session (such as Objects, or Values, etc) can only be used within that Session, thus they become invalid if they are used when the Session has been closed.

Specifically, transient attributes just exist whereas the Session where they were created remain active, that is transient attributes are automatically removed when the Session is closed (see Graph.newTransientAttribute(int, short, short)).

Moreover, a Session is exclusive for a thread, thus if it is shared among threads results may be fatal or unexpected.

Transactions

Sessions allow for the management of transactions (Session.beginTx() and Session.commitTx()). A transaction defines a granurality level for concurrent execution of Sessions. Thus all operations within a transaction are considered an execution unit.

By default, if no transactions are defined by the user, all operations behave as autocommit, that is a transaction is created just before each method and closed when the method finishes.

For the moment, transactions has a partial support of the ACID properties.

Transaction type

There are two types of transactions: Read or Shared, and Write or Exclusive. DEX's concurrency model is based in a N-readers 1-writer model, thus read transactions can be executed concurrently whereas write transactions are executed exclusively.

The type of a transaction is defined for the operations it contains. Initially, a transaction starts as a read transaction and just when a method which updates the persistent graph database is found it automatically becomes a write transaction. Obviously, to become a write transaction this must wait until all other read transactions have finished.

Author:
Sparsity Technologies

Method Summary
 void beginTx()
          Begins a transaction.
 void close()
          Closes a Session.
 void commitTx()
          Ends a transaction.
 DbGraph getDbGraph()
          Gets the DbGraph instance.
 GraphPool getGraphPool()
          Gets the parent GraphPool instance.
 boolean isOpen()
          Gets if the Session is open.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isOpen

public boolean isOpen()
Gets if the Session is open.

Returns:
true if the Session is open, false otherwise.

close

public void close()
Closes a Session.

Specified by:
close in interface java.io.Closeable

getGraphPool

public GraphPool getGraphPool()
Gets the parent GraphPool instance.

Returns:
The parent GraphPool instance.

getDbGraph

public DbGraph getDbGraph()
Gets the DbGraph instance.

Returns:
The DbGraph instance.

beginTx

public void beginTx()
Begins a transaction.


commitTx

public void commitTx()
Ends a transaction.