Esempio n. 1
0
  /**
   * Acquires a repository lock and begins a matching MDR transaction (shared lock for read, or
   * exclusive lock for write). Typical usage is start of SQL statement preparation (e.g.
   * readOnly=true for DML or query, false for DDL).
   *
   * @param readOnly if true, a shared lock is acquired on the catalog; otherwise, an exclusive lock
   *     is acquired
   */
  public void beginLockedTxn(boolean readOnly) {
    int level = (readOnly) ? 1 : 2;

    // TODO jvs 24-Jan-2007:  Get rid of downcast here and below by
    // making all creation of FarragoReposTxnContext go through
    // factory method interface on FarragoRepos.

    ((FarragoReposImpl) repos).lockRepos(level);

    // Don't set lockLevel until we've successfully acquired the lock
    lockLevel = level;

    if (readOnly) {
      beginReadTxn();
    } else {
      beginWriteTxn();
    }
  }
Esempio n. 2
0
 /** Ends exclusive access mode for the repository. */
 public void endExclusiveAccess() {
   ((FarragoReposImpl) repos).endExclusiveAccess();
 }
Esempio n. 3
0
 /**
  * Puts the repository in exclusive access mode. When in this mode, subsequent attempts to lock
  * the repository will return an exception immediately rather than wait for a required repository
  * lock to become available.
  */
 public void beginExclusiveAccess() {
   ((FarragoReposImpl) repos).beginExclusiveAccess();
 }
Esempio n. 4
0
 /**
  * Releases lock acquired by beginLockedTxn. Caller should already have ended transaction with
  * either commit or rollback.
  */
 public void unlockAfterTxn() {
   if (lockLevel != 0) {
     ((FarragoReposImpl) repos).unlockRepos(lockLevel);
     lockLevel = 0;
   }
 }