@Override public void abort() { checkIsFinished(); clearImmutableTrees(); doRevert(); getEnvironment().finishTransaction(this); }
private void invalidateStoreGetCache() { final int storeGetCacheSize = ec.getEnvStoreGetCacheSize(); storeGetCache = storeGetCacheSize == 0 ? null : new StoreGetCache(storeGetCacheSize, ec.getEnvStoreGetCacheMinTreeSize(), ec.getEnvStoreGetCacheMaxValueSize()); }
@NotNull public StoreImpl openStoreByStructureId(final int structureId) { checkIsFinished(); final EnvironmentImpl env = getEnvironment(); final String storeName = getMetaTree().getStoreNameByStructureId(structureId, env); return storeName == null ? new TemporaryEmptyStore(env) : env.openStoreImpl(storeName, StoreConfig.USE_EXISTING, this, getTreeMetaInfo(storeName)); }
private boolean throwCantModify() { if (getEnvironment().getEnvironmentConfig().getEnvIsReadonly()) { throw new ReadonlyTransactionException(); } throw new UnsupportedOperationException("Can't modify temporary empty store"); } }
@NotNull protected TransactionBase beginTransaction(Runnable beginHook, boolean exclusive, boolean cloneMeta) { checkIsOperative(); return ec.getEnvIsReadonly() ? new ReadonlyTransaction(this, exclusive, beginHook) : new ReadWriteTransaction(this, beginHook, exclusive, cloneMeta); }
@NotNull public ReadWriteTransaction beginGCTransaction() { if (ec.getEnvIsReadonly()) { throw new ReadonlyTransactionException("Can't start GC transaction on read-only Environment"); } return new ReadWriteTransaction(this, null, ec.getGcUseExclusiveTransaction(), true) { @Override boolean isGCTransaction() { return true; } }; }
protected void finishTransaction(@NotNull final TransactionBase txn) { releaseTransaction(txn); txns.remove(txn); txn.setIsFinished(); runTransactionSafeTasks(); }
@Override public void run() { final MetaTreeImpl currentMetaTree = env.getMetaTreeInternal(); setMetaTree(cloneMeta ? currentMetaTree.getClone() : currentMetaTree); env.registerTransaction(ReadWriteTransaction.this); if (beginHook != null) { beginHook.run(); } } };
static MetaTreeImpl create(@NotNull final EnvironmentImpl env, @NotNull final LogTip logTip, @NotNull final MetaTreePrototype prototype) { return new MetaTreeImpl( env.loadMetaTree(prototype.treeAddress(), logTip), prototype.rootAddress(), logTip ); }
@Override public <T> T computeInExclusiveTransaction(@NotNull TransactionalComputable<T> computable) { final Transaction current = getCurrentTransaction(); if (current == null) { return super.computeInExclusiveTransaction(computable); } if (!current.isExclusive()) { throw new ExodusException("Current transaction should be exclusive"); } return computable.compute(current); }
@Override public void abort() { checkIsFinished(); getEnvironment().finishTransaction(this); }
@Override public boolean commit() { checkIsFinished(); return getEnvironment().commitTransaction(this, false); }
public boolean forceFlush() { checkIsFinished(); return getEnvironment().flushTransaction(this, true); }
@Override public <T> T computeInTransaction(@NotNull TransactionalComputable<T> computable) { final Transaction current = getCurrentTransaction(); return current != null ? computable.compute(current) : super.computeInTransaction(computable); }
@Override public double getMean() { final EnvironmentStatistics statistics = (EnvironmentStatistics) getStatistics(); if (statistics == null) { return 0; } @Nullable final StoreGetCache storeGetCache = statistics.env.getStoreGetCache(); return storeGetCache == null ? 0 : storeGetCache.hitRate(); } }
@Override public void executeInTransaction(@NotNull TransactionalExecutable executable) { final Transaction current = getCurrentTransaction(); if (current != null) { executable.execute(current); } else { super.executeInTransaction(executable); } }
@Override public Transaction getReadonlySnapshot() { checkIsFinished(); return new ReadonlyTransaction(this); }
@Override public boolean commit() { if (!isExclusive()) { throw new ReadonlyTransactionException(); } return true; }
public Cursor openCursor() { return openCursor(environment.getAndCheckCurrentTransaction()); } }