Oberon ||
Library ||
Module Index ||
Search Engine ||
Definition ||
Module
Ulm's Oberon Library:
Transactions
NAME
Transactions - an abstraction for transactions in distributed systems
SYNOPSIS
TYPE Transaction = POINTER TO TransactionRec;
TYPE TransactionRec = RECORD (Services.ObjectRec) END;
TYPE Object = Services.Object;
TYPE AccessSpecification = PersistentDisciplines.Object;
CONST defined = 0; begun = 1; committed = 2; aborted = 3;
TYPE State = SHORTINT; (* defined..aborted *)
TYPE AttachProc = PROCEDURE (trans: Transaction; auth: Shards.Lid;
obj: Object; aspec: AccessSpecification) : BOOLEAN;
TYPE AttachedProc = PROCEDURE (trans: Transaction; auth: Shards.Lid;
obj: Object) : BOOLEAN;
TYPE GetAttachedProc = PROCEDURE (trans: Transaction;
auth: Shards.Lid;
VAR it: Iterators.Iterator) : BOOLEAN;
TYPE TransProc = PROCEDURE (trans: Transaction;
auth: Shards.Lid) : BOOLEAN;
TYPE GetStateProc = PROCEDURE (trans: Transaction; auth: Shards.Lid;
VAR state: State) : BOOLEAN;
TYPE GetNameProc = PROCEDURE (trans: Transaction; auth: Shards.Lid;
VAR name: ConstStrings.String) : BOOLEAN;
TYPE TakeInterestProc =
PROCEDURE (trans: Transaction; auth: Shards.Lid;
VAR eventType: Events.EventType) : BOOLEAN;
TYPE Interface = POINTER TO InterfaceRec;
TYPE InterfaceRec =
RECORD
(Objects.ObjectRec);
attach: AttachProc;
attachable: AttachProc;
attached: AttachedProc;
getAttached: GetAttachedProc;
begin: TransProc;
commit: TransProc;
abort: TransProc;
release: TransProc;
getState: GetStateProc;
getName: GetNameProc;
takeInterest: TakeInterestProc;
END;
TYPE Event = POINTER TO EventRec;
TYPE EventRec =
RECORD
(Events.EventRec)
state: State; (* begun, committed, or aborted *)
trans: Transaction;
END;
CONST beginFailed = 0; commitFailed = 1; abortFailed = 2;
CONST attachFailed = 4; releaseFailed = 5;
TYPE ErrorCode = SHORTINT; (* beginFailed..releaseFailed *)
TYPE ErrorEvent = POINTER TO ErrorEventRec;
TYPE ErrorEventRec =
RECORD
(Events.EventRec);
errcode: ErrorCode;
trans: Transaction;
END;
VAR error: Events.EventType;
PROCEDURE Init(trans: Transaction; if: Interface);
PROCEDURE Release(trans: Transaction; auth: Shards.Lid) : BOOLEAN;
(* defining and examining the set of attached objects *)
PROCEDURE Attach(trans: Transaction; auth: Shards.Lid;
obj: Object; aspec: AccessSpecification) : BOOLEAN;
PROCEDURE Attached(trans: Transaction; auth: Shards.Lid;
obj: Object) : BOOLEAN;
PROCEDURE Attachable(trans: Transaction; auth: Shards.Lid;
obj: Object; aspec: AccessSpecification) : BOOLEAN;
PROCEDURE GetAttached(trans: Transaction; auth: Shards.Lid;
VAR it: Iterators.Iterator) : BOOLEAN;
(* transaction primitives *)
PROCEDURE Begin(trans: Transaction; auth: Shards.Lid) : BOOLEAN;
PROCEDURE Commit(trans: Transaction; auth: Shards.Lid) : BOOLEAN;
PROCEDURE Abort(trans: Transaction; auth: Shards.Lid) : BOOLEAN;
(* further requests *)
PROCEDURE GetName(trans: Transaction; auth: Shards.Lid;
VAR name: ConstStrings.String) : BOOLEAN;
PROCEDURE GetState(trans: Transaction; auth: Shards.Lid;
VAR state: State) : BOOLEAN;
PROCEDURE TakeInterest(trans: Transaction;
auth: Shards.Lid;
VAR eventType: Events.EventType) : BOOLEAN;
DESCRIPTION
Transactions
defines an extensible abstraction for the execution of
transactions in a distributed system.
This module represents the application's view of a transaction
which regards a transaction as a frame for the execution of
an arbitrary number of operations on various objects attached to it.
From this point of view, a transaction fulfills the following properties:
- Atomicity
-
Either all operations and state changes executed on the
objects within the scope of a transaction
become valid permanently or none of them.
- Durability
-
If once successfully ended, all state changes and operations
on the attached objects remain valid regardless of subsequent
hard- or software failures.
- Isolation
-
Parallel executed transactions run independently from each other,
meaning that
none of the operations executed within the scope of one of them
may be visible outside before the transaction successfully ended.
- Consistency
-
Transactions guarantee a consistent state for all attached objects even
in cases of unpredictable termination of programs or tasks. This includes
that
all constraints defined for the objects hold true when a transaction has
finished,
regardless of its particular result.
Implementors of transactions must guarantee these properties and
provide a set of interface procedures to control the execution of
a transaction. The interface procedures passed to
Init
are expected to meet the following specifications:
- attach: PROCEDURE(trans: Transaction; auth: Shards.Lid; obj: Object; aspec: AccessSpecification) : BOOLEAN;
-
Attach object
obj
to transaction
trans. The parameter
aspec
allows to specify how an object is intended to be accessed
within the context of this transaction.
Unlimited access is indicated by NIL,
other object-specific variants may include the specification
of object parts (e.g. a subset of a container) to permit
parallel transactions, or read-only access.
This parameter should be passed to the given object
by the implementation of
trans.
- attached: PROCEDURE(trans: Transaction; auth: Shards.Lid; obj: Object) : BOOLEAN;
-
Indicate if
obj
is attached to
trans
- attachable: PROCEDURE(trans: Transaction; auth: Shards.Lid; obj: Object; aspec: AccessSpecification) : BOOLEAN;
-
Indicate if an object can be attached to the transaction
with respect to
aspec.
- getAttached: PROCEDURE(trans: Transaction; auth: Shards.Lid; VAR it: Iterators.Iterator) : BOOLEAN;
-
Return the
objects currently attached to
trans.
- trans: PROCEDURE(trans: Transaction; auth: Shards.Lid) : BOOLEAN;
-
Mark the beginning of a transaction.
Any following update operation within the scope of
trans
must not alter
the behaviour of the attached objects permanently despite a successful ending
of the transaction.
This procedure must not block the calling task.
- commit: PROCEDURE(trans: Transaction; auth: Shards.Lid) : BOOLEAN;
-
Mark the end of a transaction. Any update operation or state change
executed since the transaction began has to become permanently.
This procedure should block the calling task until all attached objects
are in a consistent state.
- abort: PROCEDURE(trans: Transaction; auth: Shards.Lid) : BOOLEAN;
-
Abort the transaction and reset the objects to a state valid before the
transaction began.
- release: PROCEDURE(trans: Transaction; auth: Shards.Lid) : BOOLEAN;
-
Release all resources associated with
trans. This includes an implicit abortion if the transaction was active
(state begun).
- getState: PROCEDURE(trans: Transaction; auth: Shards.Lid; VAR state: State) : BOOLEAN;
-
Return the current state of
trans
where
state
should be one of:
- defined
-
The transaction is defined but has not been executed yet.
- begun
-
The transaction has been begun and is still in progress.
- aborted
-
The transaction was aborted (no matter for what reason).
- committed
-
The transaction was committed successfully (i.e. all
attached objects reported success for their commit operation).
- getName: PROCEDURE(trans: Transaction; auth: Shards.Lid; VAR name: ConstStrings.String) : BOOLEAN;
-
Return a name for the transaction. The interpretation of names
is implementation-dependent.
This interface procedure may be omitted --
GetName returns NIL then.
- takeInterest: PROCEDURE(trans: Transaction; auth: Shards.Lid; VAR eventType: Events.EventType) : BOOLEAN;
-
Return the event type which is used to propagate the state changes
begun, committed, and aborted (as events
of type Event).
These events are to be raised after the state changes became effective.
Applications can control the transactions and obtain state information
about them by means of the exported
procedures which in general follow the specifications of
the corresponding interface procedures.
The transactions are free to reject the requested operation for reasons of
insufficient authorization provided as parameter
auth.
While transactions guarantee the basic properties described above,
their behaviour in detail is implementation-dependent. This affects
the following aspects:
- The interpretation of the parameter
aspec.
- The ability to attach objects of a certain type to a transaction.
- The authorization scheme.
- Multiple attachments of the same object with different
transaction parameters
aspec.
DIAGNOSTICS
All procedures return
FALSE
if the associated operation of the underlying implementation fails.
If a major operation fails
(Abort, Attach, Begin, Commit, and Release),
an event of
type
error
indicating the failed operation
(abortFailed, ...)
is raised and related to the concerned transaction.
Furthermore, the underlying implementation is expected
to generate more elaborate error events.
SEE ALSO
- ObjectTransactions
-
trivial case of transactions with one object only
- RelatedEvents
-
error handling
- RemoteTransactions
-
associated provider for the RemoteObjects service
- Services
-
type-independent definition of extensions
- Shards
-
authorization protocol
AUTHORS
Werner Stanglow (stanglow@mathematik.uni-ulm.de),
revisions due to Andreas Borchert
Edited by: borchert, last change: 1996/11/28, revision: 1.3, converted to HTML: 1997/04/28
Oberon ||
Library ||
Module Index ||
Search Engine ||
Definition ||
Module