示例#1
0
文件: LN.java 项目: bungaca/abstools
 /**
  * Log this LN. Whether its logged as a transactional entry or not depends on the type of locker.
  *
  * @param env the environment.
  * @param dbId database id of this node. (Not stored in LN)
  * @param key key of this node. (Not stored in LN)
  * @param oldLsn is the LSN of the previous version or null.
  * @param locker owning locker.
  */
 private long log(
     EnvironmentImpl env,
     DatabaseId dbId,
     byte[] key,
     long oldLsn,
     Locker locker,
     boolean isProvisional)
     throws DatabaseException {
   LogEntryType entryType;
   long logAbortLsn;
   boolean logAbortKnownDeleted;
   Txn logTxn;
   if (locker != null && locker.isTransactional()) {
     entryType = getTransactionalLogType();
     WriteLockInfo info = locker.getWriteLockInfo(getNodeId());
     logAbortLsn = info.getAbortLsn();
     logAbortKnownDeleted = info.getAbortKnownDeleted();
     logTxn = locker.getTxnLocker();
     assert logTxn != null;
   } else {
     entryType = getLogType();
     logAbortLsn = DbLsn.NULL_LSN;
     logAbortKnownDeleted = false;
     logTxn = null;
   }
   if (oldLsn == logAbortLsn) {
     oldLsn = DbLsn.NULL_LSN;
   }
   LNLogEntry logEntry =
       new LNLogEntry(entryType, this, dbId, key, logAbortLsn, logAbortKnownDeleted, logTxn);
   LogManager logManager = env.getLogManager();
   return logManager.log(logEntry, isProvisional, oldLsn);
 }
示例#2
0
文件: LN.java 项目: bungaca/abstools
 /** Delete this LN's data and log the new version. */
 public long delete(DatabaseImpl database, byte[] lnKey, byte[] dupKey, long oldLsn, Locker locker)
     throws DatabaseException {
   makeDeleted();
   EnvironmentImpl env = database.getDbEnvironment();
   long newLsn = DbLsn.NULL_LSN;
   if (dupKey != null) {
     LogEntryType entryType;
     long logAbortLsn;
     boolean logAbortKnownDeleted;
     Txn logTxn;
     if (locker.isTransactional()) {
       entryType = LogEntryType.LOG_DEL_DUPLN_TRANSACTIONAL;
       WriteLockInfo info = locker.getWriteLockInfo(getNodeId());
       logAbortLsn = info.getAbortLsn();
       logAbortKnownDeleted = info.getAbortKnownDeleted();
       logTxn = locker.getTxnLocker();
     } else {
       entryType = LogEntryType.LOG_DEL_DUPLN;
       logAbortLsn = DbLsn.NULL_LSN;
       logAbortKnownDeleted = true;
       logTxn = null;
     }
     if (oldLsn == logAbortLsn) {
       oldLsn = DbLsn.NULL_LSN;
     }
     DeletedDupLNLogEntry logEntry =
         new DeletedDupLNLogEntry(
             entryType,
             this,
             database.getId(),
             dupKey,
             lnKey,
             logAbortLsn,
             logAbortKnownDeleted,
             logTxn);
     LogManager logManager = env.getLogManager();
     newLsn = logManager.log(logEntry, false, oldLsn);
   } else {
     newLsn = log(env, database.getId(), lnKey, oldLsn, locker);
   }
   return newLsn;
 }