Пример #1
0
 public JoinCursor join__wrappee__base(Cursor[] cursors, JoinConfig config)
     throws DatabaseException {
   checkEnv();
   checkRequiredDbState(OPEN, "Can't call Database.join");
   DatabaseUtil.checkForNullParam(cursors, "cursors");
   if (cursors.length == 0) {
     throw new IllegalArgumentException("At least one cursor is required.");
   }
   Locker locker = cursors[0].getCursorImpl().getLocker();
   if (!locker.isTransactional()) {
     EnvironmentImpl env = envHandle.getEnvironmentImpl();
     for (int i = 1; i < cursors.length; i += 1) {
       Locker locker2 = cursors[i].getCursorImpl().getLocker();
       if (locker2.isTransactional()) {
         throw new IllegalArgumentException("All cursors must use the same transaction.");
       }
       EnvironmentImpl env2 = cursors[i].getDatabaseImpl().getDbEnvironment();
       if (env != env2) {
         throw new IllegalArgumentException("All cursors must use the same environment.");
       }
     }
     locker = null;
   } else {
     for (int i = 1; i < cursors.length; i += 1) {
       Locker locker2 = cursors[i].getCursorImpl().getLocker();
       if (locker.getTxnLocker() != locker2.getTxnLocker()) {
         throw new IllegalArgumentException("All cursors must use the same transaction.");
       }
     }
   }
   return new JoinCursor(locker, this, cursors, config);
 }
Пример #2
0
  public OperationStatus getSearchBoth(
      Transaction txn, DatabaseEntry key, DatabaseEntry data, LockMode lockMode)
      throws DatabaseException {

    checkEnv();
    DatabaseUtil.checkForNullDbt(key, "key", true);
    DatabaseUtil.checkForNullDbt(data, "data", true);
    checkRequiredDbState(OPEN, "Can't call Database.getSearchBoth:");
    trace(Level.FINEST, "Database.getSearchBoth", txn, key, data, lockMode);

    CursorConfig cursorConfig = CursorConfig.DEFAULT;
    if (lockMode == LockMode.READ_COMMITTED) {
      cursorConfig = CursorConfig.READ_COMMITTED;
      lockMode = null;
    }

    Cursor cursor = null;
    try {
      cursor = new Cursor(this, txn, cursorConfig);
      cursor.setNonCloning(true);
      return cursor.search(key, data, lockMode, SearchMode.BOTH);
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }
  }
Пример #3
0
  public PreloadStats preload(PreloadConfig config) throws DatabaseException {

    checkEnv();
    checkRequiredDbState(OPEN, "Can't call Database.preload");
    databaseImpl.checkIsDeleted("preload");

    return databaseImpl.preload(config);
  }
Пример #4
0
 public void preload__wrappee__base(long maxBytes) throws DatabaseException {
   checkEnv();
   checkRequiredDbState(OPEN, "Can't call Database.preload");
   this.hook55();
   PreloadConfig config = new PreloadConfig();
   config.setMaxBytes(maxBytes);
   databaseImpl.preload(config);
 }
Пример #5
0
 public Sequence openSequence__wrappee__base(
     Transaction txn, DatabaseEntry key, SequenceConfig config) throws DatabaseException {
   checkEnv();
   DatabaseUtil.checkForNullDbt(key, "key", true);
   checkRequiredDbState(OPEN, "Can't call Database.openSequence:");
   checkWritable("openSequence");
   this.hook45(txn, key);
   return new Sequence(this, txn, key, config);
 }
Пример #6
0
  /*
   * @deprecated As of JE 2.0.55, replaced by
   * {@link Database#preload(PreloadConfig)}.
   */
  public void preload(long maxBytes) throws DatabaseException {

    checkEnv();
    checkRequiredDbState(OPEN, "Can't call Database.preload");
    databaseImpl.checkIsDeleted("preload");

    PreloadConfig config = new PreloadConfig();
    config.setMaxBytes(maxBytes);
    databaseImpl.preload(config);
  }
Пример #7
0
  public DatabaseStats verify(VerifyConfig config) throws DatabaseException {

    checkEnv();
    checkRequiredDbState(OPEN, "Can't call Database.verify");
    databaseImpl.checkIsDeleted("verify");
    VerifyConfig useConfig = (config == null) ? VerifyConfig.DEFAULT : config;

    DatabaseStats stats = databaseImpl.getEmptyStats();
    databaseImpl.verify(useConfig, stats);
    return stats;
  }
Пример #8
0
  /** Javadoc for this public method is generated via the doc templates in the doc_src directory. */
  public Sequence openSequence(Transaction txn, DatabaseEntry key, SequenceConfig config)
      throws DatabaseException {

    checkEnv();
    DatabaseUtil.checkForNullDbt(key, "key", true);
    checkRequiredDbState(OPEN, "Can't call Database.openSequence:");
    checkWritable("openSequence");
    trace(Level.FINEST, "Database.openSequence", txn, key, null, null);

    return new Sequence(this, txn, key, config);
  }
Пример #9
0
 public OperationStatus putNoDupData__wrappee__base(
     Transaction txn, DatabaseEntry key, DatabaseEntry data) throws DatabaseException {
   checkEnv();
   DatabaseUtil.checkForNullDbt(key, "key", true);
   DatabaseUtil.checkForNullDbt(data, "data", true);
   DatabaseUtil.checkForPartialKey(key);
   checkRequiredDbState(OPEN, "Can't call Database.putNoDupData");
   checkWritable("putNoDupData");
   this.hook52(txn, key, data);
   return putInternal(txn, key, data, PutMode.NODUP);
 }
Пример #10
0
  public DatabaseStats getStats(StatsConfig config) throws DatabaseException {

    checkEnv();
    checkRequiredDbState(OPEN, "Can't call Database.stat");
    StatsConfig useConfig = (config == null) ? StatsConfig.DEFAULT : config;

    if (databaseImpl != null) {
      databaseImpl.checkIsDeleted("stat");
      return databaseImpl.stat(useConfig);
    }
    return null;
  }
Пример #11
0
  public OperationStatus putNoOverwrite(Transaction txn, DatabaseEntry key, DatabaseEntry data)
      throws DatabaseException {

    checkEnv();
    DatabaseUtil.checkForNullDbt(key, "key", true);
    DatabaseUtil.checkForNullDbt(data, "data", true);
    DatabaseUtil.checkForPartialKey(key);
    checkRequiredDbState(OPEN, "Can't call Database.putNoOverWrite");
    checkWritable("putNoOverwrite");
    trace(Level.FINEST, "Database.putNoOverwrite", txn, key, data, null);

    return putInternal(txn, key, data, PutMode.NOOVERWRITE);
  }
Пример #12
0
 public synchronized Cursor openCursor__wrappee__base(Transaction txn, CursorConfig cursorConfig)
     throws DatabaseException {
   checkEnv();
   checkRequiredDbState(OPEN, "Can't open a cursor");
   CursorConfig useConfig = (cursorConfig == null) ? CursorConfig.DEFAULT : cursorConfig;
   if (useConfig.getReadUncommitted() && useConfig.getReadCommitted()) {
     throw new IllegalArgumentException(
         "Only one may be specified: ReadCommitted or ReadUncommitted");
   }
   this.hook46(txn, cursorConfig);
   Cursor ret = newDbcInstance(txn, useConfig);
   return ret;
 }
Пример #13
0
  /**
   * @deprecated It has not been possible to implement this method with correct transactional
   *     semantics without incurring a performance penalty on all Database operations. Truncate
   *     functionality has been moved to Environment.truncateDatabase(), which requires that all
   *     Database handles on the database are closed before the truncate operation can execute.
   */
  public int truncate(Transaction txn, boolean countRecords) throws DatabaseException {

    checkEnv();
    checkRequiredDbState(OPEN, "Can't call Database.truncate");
    checkWritable("truncate");
    Tracer.trace(
        Level.FINEST,
        envHandle.getEnvironmentImpl(),
        "Database.truncate" + ": txnId=" + ((txn == null) ? "null" : Long.toString(txn.getId())));

    Locker locker = null;
    boolean triggerLock = false;
    boolean operationOk = false;

    try {
      locker =
          LockerFactory.getWritableLocker(
              envHandle, txn, isTransactional(), true /*retainLocks*/, null);

      /*
       * Pass true to always get a read lock on the triggers, so we are
       * sure that no secondaries are added during truncation.
       */
      acquireTriggerListReadLock();
      triggerLock = true;

      /* Truncate primary. */
      int count = truncateInternal(locker, countRecords);

      /* Truncate secondaries. */
      for (int i = 0; i < triggerList.size(); i += 1) {
        Object obj = triggerList.get(i);
        if (obj instanceof SecondaryTrigger) {
          SecondaryDatabase secDb = ((SecondaryTrigger) obj).getDb();
          secDb.truncateInternal(locker, false);
        }
      }

      operationOk = true;
      return count;
    } finally {
      if (locker != null) {
        locker.operationEnd(operationOk);
      }
      if (triggerLock) {
        releaseTriggerListReadLock();
      }
    }
  }
Пример #14
0
 public OperationStatus delete__wrappee__base(Transaction txn, DatabaseEntry key)
     throws DatabaseException {
   checkEnv();
   DatabaseUtil.checkForNullDbt(key, "key", true);
   checkRequiredDbState(OPEN, "Can't call Database.delete:");
   checkWritable("delete");
   this.hook47(txn, key);
   OperationStatus commitStatus = OperationStatus.NOTFOUND;
   Locker locker = null;
   try {
     locker = LockerFactory.getWritableLocker(envHandle, txn, isTransactional());
     commitStatus = deleteInternal(locker, key);
     return commitStatus;
   } finally {
     if (locker != null) {
       locker.operationEnd(commitStatus);
     }
   }
 }
Пример #15
0
  public JoinCursor join(Cursor[] cursors, JoinConfig config) throws DatabaseException {

    checkEnv();
    checkRequiredDbState(OPEN, "Can't call Database.join");
    DatabaseUtil.checkForNullParam(cursors, "cursors");
    if (cursors.length == 0) {
      throw new IllegalArgumentException("At least one cursor is required.");
    }

    /*
     * Check that all cursors use the same locker, if any cursor is
     * transactional.  And if non-transactional, that all databases are in
     * the same environment.
     */
    Locker locker = cursors[0].getCursorImpl().getLocker();
    if (!locker.isTransactional()) {
      EnvironmentImpl env = envHandle.getEnvironmentImpl();
      for (int i = 1; i < cursors.length; i += 1) {
        Locker locker2 = cursors[i].getCursorImpl().getLocker();
        if (locker2.isTransactional()) {
          throw new IllegalArgumentException("All cursors must use the same transaction.");
        }
        EnvironmentImpl env2 = cursors[i].getDatabaseImpl().getDbEnvironment();
        if (env != env2) {
          throw new IllegalArgumentException("All cursors must use the same environment.");
        }
      }
      locker = null; /* Don't reuse a non-transactional locker. */
    } else {
      for (int i = 1; i < cursors.length; i += 1) {
        Locker locker2 = cursors[i].getCursorImpl().getLocker();
        if (locker.getTxnLocker() != locker2.getTxnLocker()) {
          throw new IllegalArgumentException("All cursors must use the same transaction.");
        }
      }
    }

    /* Create the join cursor. */
    return new JoinCursor(locker, this, cursors, config);
  }
Пример #16
0
 public PreloadStats preload__wrappee__base(PreloadConfig config) throws DatabaseException {
   checkEnv();
   checkRequiredDbState(OPEN, "Can't call Database.preload");
   this.hook57();
   return databaseImpl.preload(config);
 }