com.sleepycat.je.Transaction.commit()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中com.sleepycat.je.Transaction.commit()方法的一些代码示例,展示了Transaction.commit()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.commit()方法的具体详情如下:
包路径:com.sleepycat.je.Transaction
类名称:Transaction
方法名:commit

Transaction.commit介绍

[英]End the transaction. If the environment is configured for synchronous commit, the transaction will be committed synchronously to stable storage before the call returns. This means the transaction will exhibit all of the ACID (atomicity, consistency, isolation, and durability) properties.

If the environment is not configured for synchronous commit, the commit will not necessarily have been committed to stable storage before the call returns. This means the transaction will exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained, but it is possible this transaction may be undone during recovery.

All cursors opened within the transaction must be closed before the transaction is committed.

If the method encounters an error, the transaction will have been aborted when the call returns.

After this method has been called, regardless of its return, the Transaction handle may not be accessed again, with one exception: the abort method may be called any number of times to simplify error handling.

WARNING: To guard against memory leaks, the application should discard all references to the closed handle. While BDB makes an effort to discard references from closed objects to the allocated memory for an environment, this behavior is not guaranteed. The safe course of action for an application is to discard all references to closed BDB objects.
[中]结束交易。如果环境配置为同步提交,则在调用返回之前,事务将同步提交到稳定存储。这意味着事务将展示所有ACID(原子性、一致性、隔离性和持久性)属性。
如果环境未配置为同步提交,则在调用返回之前,提交不一定已提交到稳定存储。这意味着事务将展示ACI(原子性、一致性和隔离)属性,而不是D(持久性);也就是说,数据库的完整性将得到维护,但此事务可能在恢复期间被撤消。
在提交事务之前,必须关闭事务中打开的所有游标。
如果方法遇到错误,当调用返回时,事务将被中止。
调用此方法后,无论其返回结果如何,都可能无法再次访问事务句柄,但有一个例外:可以多次调用abort方法以简化错误处理。
警告:为了防止内存泄漏,应用程序应该放弃对关闭句柄的所有引用。虽然BDB努力放弃从封闭对象到环境分配内存的引用,但这种行为并不能保证。应用程序的安全操作过程是放弃对关闭的BDB对象的所有引用。

代码示例

代码示例来源:origin: yasserg/crawler4j

protected static void commit(Transaction tnx) {
  if (tnx != null) {
    tnx.commit();
  }
}

代码示例来源:origin: voldemort/voldemort

private void attemptCommit(Transaction transaction) {
  try {
    if(transaction != null)
      transaction.commit();
  } catch(DatabaseException e) {
    this.bdbEnvironmentStats.reportException(e);
    logger.error("Transaction commit failed!", e);
    attemptAbort(transaction);
    throw new PersistenceFailureException(e);
  }
}

代码示例来源:origin: thinkaurelius/titan

@Override
public synchronized void commit() throws BackendException {
  super.commit();
  if (tx == null) return;
  if (log.isTraceEnabled())
    log.trace("{} committed", this.toString(), new TransactionClose(this.toString()));
  try {
    closeOpenIterators();
    tx.commit();
    tx = null;
  } catch (DatabaseException e) {
    throw new PermanentBackendException(e);
  }
}

代码示例来源:origin: yasserg/crawler4j

public void setValue(String name, long value) {
  synchronized (mutex) {
    try {
      counterValues.put(name, value);
      if (statisticsDB != null) {
        Transaction txn = env.beginTransaction(null, null);
        statisticsDB.put(txn, new DatabaseEntry(name.getBytes()),
                 new DatabaseEntry(Util.long2ByteArray(value)));
        txn.commit();
      }
    } catch (RuntimeException e) {
      if (config.isHaltOnError()) {
        throw e;
      } else {
        logger.error("Exception setting value", e);
      }
    }
  }
}

代码示例来源:origin: yasserg/crawler4j

tnx.commit();

代码示例来源:origin: opensourceBIM/BIMserver

@Override
public void commit() throws BimserverLockConflictException, BimserverDatabaseException {
  try {
    transaction.commit();
    transactionAlive = false;
  } catch (LockConflictException e) {
    throw new BimserverLockConflictException(e);
  } catch (DatabaseException e) {
    throw new BimserverDatabaseException(e);
  }
}

代码示例来源:origin: opensourceBIM/BIMserver

@Override
public void commit(DatabaseSession databaseSession) throws BimserverLockConflictException, BimserverDatabaseException {
  Transaction bdbTransaction = getTransaction(databaseSession);
  try {
    bdbTransaction.commit();
  } catch (LockConflictException e) {
    throw new BimserverLockConflictException(e);
  } catch (DatabaseException e) {
    throw new BimserverDatabaseException("", e);
  }
}

代码示例来源:origin: edu.uci.ics/crawler4j

protected static void commit(Transaction tnx) {
  if (tnx != null) {
    tnx.commit();
  }
}

代码示例来源:origin: co.paralleluniverse/galaxy

@Override
public void commit(Object txn) {
  LOG.debug("commit");
  ((Transaction) txn).commit();
}

代码示例来源:origin: org.locationtech.geogig/geogig-bdbje

private void commit(@Nullable Transaction transaction) {
  if (transaction != null) {
    try {
      transaction.commit();
    } catch (Exception e) {
      LOGGER.error("Error committing transaction", e);
    }
  }
}

代码示例来源:origin: org.locationtech.geogig/geogig-bdbje

private void commit(@Nullable Transaction transaction) {
  if (transaction != null) {
    try {
      transaction.commit();
    } catch (Exception e) {
      LOGGER.error("Error committing transaction", e);
    }
  }
}

代码示例来源:origin: org.jboss.cache/jbosscache-core

/**
* Performs and commits a list of modifications.  The loader must be
* transactional. Commits the transaction if successful, or aborts the
* transaction and throws an exception if not successful.
*/
private void commitModifications(List<Modification> mods)
   throws Exception
{
 if (!transactional) throw new IllegalStateException();
 Transaction txn = performTransaction(mods);
 txn.commit();
}

代码示例来源:origin: com.amazon.carbonado/carbonado-sleepycat-je

void commit() throws DatabaseException {
  if (mParent == null) {
    mTxn.commit();
  } else {
    mParent.addUndo(mUndoLog);
  }
}

代码示例来源:origin: org.deephacks/graphene-core

public void commit() {
 closeCursors();
 if (tx.isValid()) {
  tx.commit();
 }
}

代码示例来源:origin: org.apache.qpid/qpid-bdbstore

private void upgradeMessages(final Environment environment, final UpgradeInteractionHandler handler)
{
  Transaction transaction = null;
  transaction = environment.beginTransaction(null, null);
  upgradeMessages(environment, handler, transaction);
  transaction.commit();
}

代码示例来源:origin: GeoWebCache/geowebcache

public Void call() throws Exception {
    final Transaction transaction =
        entityStore.getEnvironment().beginTransaction(null, null);
    try {
      createLayer(layerName, transaction);
      transaction.commit();
    } catch (RuntimeException e) {
      transaction.abort();
    }
    return null;
  }
});

代码示例来源:origin: com.thinkaurelius.titan/titan-berkeleyje-jre6

@Override
public synchronized void commit() throws StorageException {
  super.commit();
  if (tx == null) return;
  try {
    closeOpenIterators();
    tx.commit();
    tx = null;
  } catch (DatabaseException e) {
    throw new PermanentStorageException(e);
  }
}

代码示例来源:origin: GeoWebCache/geowebcache

public Void call() throws Exception {
  Transaction transaction = entityStore.getEnvironment().beginTransaction(null, null);
  try {
    call(transaction);
    transaction.commit();
  } catch (RuntimeException e) {
    transaction.abort();
    throw e;
  }
  return null;
}

代码示例来源:origin: org.apache.qpid/qpid-bdbstore

private void upgradeConfiguredObjectsAndDependencies(Environment environment, UpgradeInteractionHandler handler, String virtualHostName)
{
  Transaction transaction = null;
  transaction = environment.beginTransaction(null, null);
  upgradeConfiguredObjects(environment, handler, transaction, virtualHostName);
  upgradeQueueEntries(environment, transaction, virtualHostName);
  upgradeXidEntries(environment, transaction, virtualHostName);
  transaction.commit();
}

代码示例来源:origin: org.infinispan/infinispan-cachestore-bdbje

@Test
public void testRun() throws Exception {
 transaction.commit();
 worker.doWork();
 runner = new PreparableTransactionRunner(env);
 runner.run(worker);
}

相关文章