Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
research:dsal:kala [2009/02/12 16:15] – jfabry | research:dsal:kala [2009/02/13 12:14] (current) – jfabry | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | ===== KALA ===== | ||
+ | |||
+ | (Internal classification: | ||
+ | |||
+ | Reference paper: **" | ||
+ | |||
+ | ===== Domain of the language ===== | ||
+ | |||
+ | Advanced transaction management | ||
+ | |||
+ | Transactions are the cornerstone of concurrency management in | ||
+ | multi-tier distributed systems. Originally designed to provide | ||
+ | concurrency management for short and unstructured data accesses to databases, they | ||
+ | are however now used outside of this domain. This observation is not | ||
+ | new, and significant research has been performed to address the | ||
+ | shortcomings of classical transactions through the use of advanced | ||
+ | transaction models (ATMS). There are many such advanced models, each specifically tailored to address one shortcoming. To achieve this, ATMS typically relax some of the ACID properties associated with classical transactions, | ||
+ | |||
+ | |||
+ | The major issue with using an ATMS in an application is how these extra properties can be specified. In other words, how programmer attaches the extra transactional properties to parts of the application code that are ment to run within a transaction. | ||
+ | |||
+ | ===== Intent of the language ===== | ||
+ | |||
+ | A KALA program declares transactional properties for | ||
+ | a number of transactions in a Java program, based on the life-cycle of a given | ||
+ | transaction. As is usual in OO programs that use transactions, | ||
+ | life-cycle of every transaction coincides with the life-cycle of a | ||
+ | method. The transaction begins when the method | ||
+ | begins, commits when the method ends normally, and aborts if the | ||
+ | method ends with a specific type of exception. | ||
+ | |||
+ | Transactional properties | ||
+ | take effect at given times in the life-cycle of the transaction: | ||
+ | properties can be declared to apply at begin time, commit time and | ||
+ | abort time. This is done by placing these declarations, | ||
+ | statements, in a '' | ||
+ | Outside of these blocks, a number of statements can be placed in the preliminaries. | ||
+ | |||
+ | Transactional properties are taken from the ACTA formal | ||
+ | model: '' | ||
+ | these properties is reified as a statement in KALA, respectively '' | ||
+ | |||
+ | ===== Join Point Model and Advice Model ===== | ||
+ | |||
+ | * JPM: Domain-Specific: | ||
+ | * AM: Domain-Specific: | ||
+ | |||
+ | ===== Anatomy of the language ===== | ||
+ | |||
+ | We provide the SDF definition from the ReLAx ((**" | ||
+ | Johan Fabry, Eric Tanter, Theo D’Hondt, In //IET Software//, To Appear)) paper: | ||
+ | |||
+ | KDecl* -> CompilationUnit \\ | ||
+ | FQMPattern KBody -> KDecl | ||
+ | " | ||
+ | PrelimStm* | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | AStartStm | ||
+ | NamingStm | ||
+ | NamingStm | ||
+ | DepStm | ||
+ | ViewStm | ||
+ | DelStm | ||
+ | TermStm | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | JavaId JavaExpr | ||
+ | |||
+ | |||
+ | A KALA declaration | ||
+ | consists of a signature and body. The | ||
+ | join-point model contains method executions, the signatures are the | ||
+ | pointcut expressions, | ||
+ | specifies the transactional properties of a set of methods, specified | ||
+ | by the pointcut expressions. Furthermore, | ||
+ | and writes to objects that implement the '' | ||
+ | |||
+ | |||
+ | Dependencies, | ||
+ | two transactions they affect; therefore there is a need for a variable | ||
+ | binding mechanism. Within KALA code, such a binding is known as an | ||
+ | '' | ||
+ | service, which is declared using the '' | ||
+ | statement. This statement takes as argument the alias | ||
+ | for a transaction, | ||
+ | Java expression that evaluates to a key that is used to look up the | ||
+ | transaction reference in the name service. This expression, as | ||
+ | all expressions in KALA, has | ||
+ | access to the actual parameters of the method and to aliases which | ||
+ | have already been resolved. Special cases are the alias '' | ||
+ | which is always bound to the currently running transaction, | ||
+ | '' | ||
+ | statements which have as an argument the null transaction fail | ||
+ | silently. Adding transactions to the naming service is performed using the | ||
+ | '' | ||
+ | expression that evaluates to the key for the naming service. | ||
+ | |||
+ | When placed in the preliminaries, | ||
+ | registered immediately before the transaction starts. Aliases placed | ||
+ | in begin, commit and abort blocks are looked up at that particular | ||
+ | moment in the life-cycle of the transaction. | ||
+ | The scope of aliases within a KALA declaration follows the usual | ||
+ | lexical scoping rules: aliases obtained in the preliminaries of a | ||
+ | declaration are accessible thoughout the remainder of the KALA code | ||
+ | for that declaration; | ||
+ | are only accessible there. | ||
+ | |||
+ | KALA provides support for named groups of transactions. A transaction | ||
+ | can be added to a group using the '' | ||
+ | behavior for groups, e.g. setting a view from a transaction to a group | ||
+ | of transactions implies setting the view to each member of the group. | ||
+ | The only non-obvious case is when a group is a destination of a | ||
+ | delegation statement. As semantically this has no sense --delegating | ||
+ | some changes to a group of transactions--, | ||
+ | |||
+ | Because dependencies may refer to transactions which have | ||
+ | already ended, it is impossible to perform automatic garbage | ||
+ | collection of names and dependency relationships when transactions | ||
+ | have ended. Instead the KALA programmer is made responsible for such | ||
+ | cleanup operations. This is performed through the '' | ||
+ | statement, which takes as argument a Java expression. This expression | ||
+ | is resolved to a name of the transaction or group of transactions to | ||
+ | be collected. Termination of transactions can be performed within a | ||
+ | '' | ||
+ | terminated when it has not yet ended, it is immediately forced to | ||
+ | rollback. | ||
+ | |||
+ | ===== Typical Example: Nested Transactions ===== | ||
+ | |||
+ | This model is one of the oldest and arguably the best-known | ||
+ | ATMS. It enables a running transaction '' | ||
+ | number of child transactions '' | ||
+ | '' | ||
+ | '' | ||
+ | a number of children '' | ||
+ | When a child transaction '' | ||
+ | written to the database, but instead it is delegated to its | ||
+ | parent '' | ||
+ | '' | ||
+ | data is committed to the database when it commits. Another | ||
+ | characteristic of this model is that if a child transaction '' | ||
+ | aborts, the parent '' | ||
+ | ends it may choose to either commit or abort. | ||
+ | |||
+ | util.strategy.Hierarchical.child*() { | ||
+ | alias(parent Thread.currentThread() ); | ||
+ | name(self Thread.currentThread()); | ||
+ | groupAdd(self " | ||
+ | begin { dep(self wd parent); dep(parent cd self); view(self parent); } | ||
+ | commit { del(self parent); | ||
+ | name(parent Thread.currentThread()); | ||
+ | terminate(" | ||
+ | abort { name(parent Thread.currentThread()); | ||
+ | | ||
+ | |||
+ | The first line of the KALA code above is the KALA signature, which identifies the | ||
+ | transactional methods. As a result, all data accesses to shared data | ||
+ | within these methods (and within methods called by these methods) are | ||
+ | included in the transaction. | ||
+ | |||
+ | The view property declared in the code above states | ||
+ | that the current transaction, | ||
+ | the data of its parent transaction. This property is established when | ||
+ | the transaction begins. The delegation property ('' | ||
+ | states that upon commit, the child transaction delegates its data | ||
+ | changes to its parent transaction. The dependency '' | ||
+ | transaction ends, then this transaction will be forced to also abort. | ||
+ | '' | ||
+ | to wait until this transaction has ended. | ||
+ | |||
+ | The current thread is first used as a key to | ||
+ | lookup the parent transaction, | ||
+ | transaction (overriding the binding), and finally, upon | ||
+ | commit or abort, the parent binding is restored. Also, the code adds the current transaction to the group of children of | ||
+ | the '' | ||
+ | transaction finishes (by commit or abort), it terminates | ||
+ | the group of its child transactions. | ||
+ | |||
+ | ===== Enforced Restrictions ===== | ||
+ | |||
+ | The language only allows for specific kinds of transactional semantics to be declared at specific life-cycle moments of the transaction. However, expressions used in naming statements run unchecked: any Java expression can be evaluated here. Although these expressions do not have any access to KALA internal state, they can break the program by throwing an exception. | ||
+ | |||
+ | |||
+ | ===== Implementation description ===== | ||
+ | |||
+ | The first implementation of KALA was done in an ad-hoc way, by performing source-code transformation. A second implementation, | ||
+ | Johan Fabry, Eric Tanter, Theo D’Hondt, In //IET Software//, To Appear)). In summary: the syntax of KALA is described in SDF, as we have shown above. This specification is used to generates a parser that produces an object representation of the parsed KALA program. The KALA signature determines where to weave the KALA implementation logic, which is generic. The objectified version of the KALA body is treated as configuration parameters by the implementation logic, resulting in the specified properties being ensured at runtime. | ||