예제 #1
0
  DbTxn beginTransaction(final DbEnv dbenv, final DbTxn parent) throws DatabaseException {

    int flags = 0;
    flags |= readCommitted ? DbConstants.DB_READ_COMMITTED : 0;
    flags |= readUncommitted ? DbConstants.DB_READ_UNCOMMITTED : 0;
    flags |= noSync ? DbConstants.DB_TXN_NOSYNC : 0;
    flags |= noWait ? DbConstants.DB_TXN_NOWAIT : 0;
    flags |= snapshot ? DbConstants.DB_TXN_SNAPSHOT : 0;
    flags |= sync ? DbConstants.DB_TXN_SYNC : 0;
    flags |= wait ? DbConstants.DB_TXN_WAIT : 0;
    flags |= writeNoSync ? DbConstants.DB_TXN_WRITE_NOSYNC : 0;

    return dbenv.txn_begin(parent, flags);
  }
 /* package */
 static ReplicationStatus getStatus(
     final int errCode, final DatabaseEntry cdata, final int envid, final LogSequenceNumber lsn) {
   switch (errCode) {
     case 0:
       return SUCCESS;
     case DbConstants.DB_REP_IGNORE:
       return IGNORE;
     case DbConstants.DB_REP_ISPERM:
       return new ReplicationStatus("ISPERM", errCode, cdata, envid, lsn);
     case DbConstants.DB_REP_NEWSITE:
       return new ReplicationStatus("NEWSITE", errCode, cdata, envid, lsn);
     case DbConstants.DB_REP_NOTPERM:
       return new ReplicationStatus("NOTPERM", errCode, cdata, envid, lsn);
     default:
       throw new IllegalArgumentException("Unknown error code: " + DbEnv.strerror(errCode));
   }
 }
예제 #3
0
 /**
  * Compare two LogSequenceNumber objects.
  *
  * <p>This method returns 0 if the two LogSequenceNumber objects are equal, 1 if lsn0 is greater
  * than lsn1, and -1 if lsn0 is less than lsn1.
  *
  * <p>
  *
  * @param lsn1 The first LogSequenceNumber object to be compared.
  *     <p>
  * @param lsn2 The second LogSequenceNumber object to be compared.
  *     <p>
  * @return 0 if the two LogSequenceNumber objects are equal, 1 if lsn1 is greater than lsn2, and
  *     -1 if lsn1 is less than lsn2.
  */
 public static int compare(LogSequenceNumber lsn1, LogSequenceNumber lsn2) {
   return DbEnv.log_compare(lsn1, lsn2);
 }
예제 #4
0
 /** {@inheritDoc} */
 public String toString() {
   String s = super.toString();
   if (errno != 0) s += ": " + DbEnv.strerror(errno);
   return s;
 }