net.sf.farrago.ddl
Interface DdlMultipleTransactionStmt

All Superinterfaces:
FarragoSessionDdlStmt
All Known Implementing Classes:
DdlAlterTableStructureStmt, DdlAnalyzeStmt, DdlRebuildTableStmt, DdlReloadTableStmt, DdlTruncateStmt

public interface DdlMultipleTransactionStmt
extends FarragoSessionDdlStmt

DdlMultipleTransactionStmt represents a DdlStmt that requires its work to divided among multiple repository transactions to avoid holding the repository transaction lock for excessive periods of time (and thereby blocking other statements).

NOTE jvs 11-Dec-2008: the implementations of executeUnlocked and completeAfterExecuteUnlocked should not reuse references to repository objects obtained during the initial repository transaction, as they may be stale. Instead, MOFID's should be used to reload references as needed.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/ddl/DdlMultipleTransactionStmt.java#8 $
Author:
Stephan Zuercher

Method Summary
 void completeAfterExecuteUnlocked(FarragoSessionDdlValidator ddlValidator, FarragoSession session, boolean success)
          Provides access to the repository after execution of the DDL.
 boolean completeRequiresWriteTxn()
          Checks whether the completeAfterExecuteUnlocked( FarragoSessionDdlValidator, FarragoSession, boolean) method requires a repository write transaction.
 void executeUnlocked(FarragoSessionDdlValidator ddlValidator, FarragoSession session)
          Executes long-running DDL actions.
 void prepForExecuteUnlocked(FarragoSessionDdlValidator ddlValidator, FarragoSession session)
          Provides access to the repository in preparation for the execution of DdlStmt.
 
Methods inherited from interface net.sf.farrago.session.FarragoSessionDdlStmt
getModelElement, isDropRestricted, postCommit, postExecute, preExecute, preValidate, requiresCommit, runsAsDml
 

Method Detail

prepForExecuteUnlocked

void prepForExecuteUnlocked(FarragoSessionDdlValidator ddlValidator,
                            FarragoSession session)
Provides access to the repository in preparation for the execution of DdlStmt. This method is invoked within the context the original repository transaction for the DDL statement. Whether that transaction is a write transaction depends on the DDL statement being executed.

Parameters:
ddlValidator - DDL validator for this statement
See Also:
FarragoReposTxnContext

executeUnlocked

void executeUnlocked(FarragoSessionDdlValidator ddlValidator,
                     FarragoSession session)
Executes long-running DDL actions. This method is invoked outside the context of any repository transaction.

Parameters:
ddlValidator - DDL validator for this statement
session - reentrant Farrago session which may be used to execute DML statements

completeRequiresWriteTxn

boolean completeRequiresWriteTxn()
Checks whether the completeAfterExecuteUnlocked( FarragoSessionDdlValidator, FarragoSession, boolean) method requires a repository write transaction.

Returns:
true if a write txn must be started before executing the completion step, false if a read txn is sufficient

completeAfterExecuteUnlocked

void completeAfterExecuteUnlocked(FarragoSessionDdlValidator ddlValidator,
                                  FarragoSession session,
                                  boolean success)
Provides access to the repository after execution of the DDL. Typically implementations of this method modify the repository to store the results of executeUnlocked(FarragoSessionDdlValidator, FarragoSession). This method is invoked in a locked repository transaction. The method completeRequiresWriteTxn() controls whether the transaction read-only or not. This method may not access and/or modify repository objects loaded in a previous transaction unless they are reloaded by MOF ID. Be aware that objects may have been modified by another session unless some external mechanism (for instance, the "table-in-use" collection) guarantees that they have not been modified by another statement.

Note that any repository modifications made during the execution of this method will not be post-processed by DdlValidator. For instance, DdlValidator.checkJmiConstraints(RefObject) is not called, and therefore any mandatory default primitives are not automatically set, which will cause errors later if the attributes have not been explicitly initialized. See JmiObjUtil.setMandatoryPrimitiveDefaults(javax.jmi.reflect.RefObject).

Parameters:
ddlValidator - DDL validator for this statement
session - reentrant Farrago session which may be used to execute DML statements
success - whether the execution succeeded; detection of failure can be used to recover