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(); } } }
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); }
public synchronized void close__wrappee__base() throws DatabaseException { StringBuffer errors = null; checkEnv(); checkProhibitedDbState(CLOSED, "Can't close Database:"); this.hook44(); removeAllTriggers(); envHandle.removeReferringHandle(this); if (cursors.size() > 0) { errors = new StringBuffer("There are open cursors against the database.\n"); errors.append("They will be closed.\n"); Iterator iter = cursors.copy().iterator(); while (iter.hasNext()) { Cursor dbc = (Cursor) iter.next(); try { dbc.close(); } catch (DatabaseException DBE) { errors.append("Exception while closing cursors:\n"); errors.append(DBE.toString()); } } } if (databaseImpl != null) { databaseImpl.removeReferringHandle(this); databaseImpl = null; handleLocker.setHandleLockOwner(true, this, true); handleLocker.operationEnd(true); state = CLOSED; } if (errors != null) { throw new DatabaseException(errors.toString()); } }
public String getDatabaseName__wrappee__base() throws DatabaseException { checkEnv(); if (databaseImpl != null) { return databaseImpl.getName(); } else { return null; } }
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); }
public PreloadStats preload(PreloadConfig config) throws DatabaseException { checkEnv(); checkRequiredDbState(OPEN, "Can't call Database.preload"); databaseImpl.checkIsDeleted("preload"); return databaseImpl.preload(config); }
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); }
/* * @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); }
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); }
/** 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); }
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; }
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; }
public synchronized void close() throws DatabaseException { StringBuffer errors = null; checkEnv(); checkProhibitedDbState(CLOSED, "Can't close Database:"); trace(Level.FINEST, "Database.close: ", null, null); /* Disassociate triggers before closing. */ removeAllTriggers(); envHandle.removeReferringHandle(this); if (cursors.size() > 0) { errors = new StringBuffer("There are open cursors against the database.\n"); errors.append("They will be closed.\n"); /* * Copy the cursors set before iterating since the dbc.close() * mutates the set. */ Iterator iter = cursors.copy().iterator(); while (iter.hasNext()) { Cursor dbc = (Cursor) iter.next(); try { dbc.close(); } catch (DatabaseException DBE) { errors.append("Exception while closing cursors:\n"); errors.append(DBE.toString()); } } } if (databaseImpl != null) { databaseImpl.removeReferringHandle(this); databaseImpl = null; /* * Tell our protecting txn that we're closing. If this type * of transaction doesn't live beyond the life of the handle, * it will release the db handle lock. */ handleLocker.setHandleLockOwner(true, this, true); handleLocker.operationEnd(true); state = CLOSED; } if (errors != null) { throw new DatabaseException(errors.toString()); } }
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; }
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); }
/** * @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(); } } }
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); } } }
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); }
public PreloadStats preload__wrappee__base(PreloadConfig config) throws DatabaseException { checkEnv(); checkRequiredDbState(OPEN, "Can't call Database.preload"); this.hook57(); return databaseImpl.preload(config); }