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

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

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

Transaction.abort介绍

[英]Cause an abnormal termination of the transaction.

The log is played backward, and any necessary undo operations are done. Before Transaction.abort returns, any locks held by the transaction will have been released.

In the case of nested transactions, aborting a parent transaction causes all children (unresolved or not) of the parent transaction to be aborted.

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

After this method has been called, regardless of its return, the Transaction handle may not be accessed again, with one exception: the abort method itself 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.
[中]导致交易异常终止。
日志将向后播放,并执行任何必要的撤消操作。交易前。中止返回时,事务持有的所有锁都将被释放。
对于嵌套事务,中止父事务会导致父事务的所有子事务(未解析或未解析)中止。
在事务中止之前,必须关闭事务中打开的所有游标。
调用此方法后,无论其返回结果如何,都可能无法再次访问事务句柄,但有一个例外:可以多次调用abort方法本身,以简化错误处理。
警告:为了防止内存泄漏,应用程序应该放弃对关闭句柄的所有引用。虽然BDB努力放弃从封闭对象到环境分配内存的引用,但这种行为并不能保证。应用程序的安全操作过程是放弃对关闭的BDB对象的所有引用。

代码示例

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

private void attemptAbort(Transaction transaction) {
  try {
    if(transaction != null)
      transaction.abort();
  } catch(DatabaseException e) {
    this.bdbEnvironmentStats.reportException(e);
    logger.error("Abort failed!", e);
  }
}

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

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

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

@Override
public void rollback() {
  try {
    transaction.abort();
    transactionAlive = false;
  } catch (DatabaseException e) {
    LOGGER.error("", e);
  }
}

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

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

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

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

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

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

代码示例来源:origin: jpos/jPOS

private void abort (Transaction txn) throws SpaceError {
  try {
    txn.abort();
  } catch (DatabaseException e) {
    throw new SpaceError (e);
  }
}

代码示例来源:origin: itisaid/Doris

private void rollback(Transaction transaction) {
  try {
    if (transaction != null) {
      transaction.abort();
    }
  } catch (Exception e) {
    throw new BDBStorageException(e.getMessage(), e);
  }
}

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

void abort() throws DatabaseException {
  if (mParent == null) {
    mTxn.abort();
  } else {
    UndoAction undo = mUndoLog;
    if (undo != null) {
      undo.apply();
    }
  }
}

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

public void rollback() {
 closeCursors();
 tx.abort();
}

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

@Override
  public void close() {
    sortedIds = null;
    Cursor cursor = this.cursor;
    this.cursor = null;
    if (cursor != null) {
      cursor.close();
    }
    if (transaction != null) {
      transaction.abort();
      transaction = null;
    }
  }
}

代码示例来源:origin: HuygensING/timbuctoo

public void close() {
 if (transaction != null) {
  transaction.abort();
 }
 for (Map.Entry<Cursor, String> cursor : cursors.entrySet()) {
  cursor.getKey().close();
  LOG.error("Cursor was not closed. It was opened at: \n" + cursor.getValue());
 }
 database.close();
}

代码示例来源:origin: io.permazen/permazen-kv-bdb

@Override
public synchronized void rollback() {
  if (this.closed)
    return;
  this.close();
  try {
    this.tx.abort();
  } catch (DatabaseException e) {
    throw this.wrapException(e);
  }
}

代码示例来源:origin: org.jsimpledb/jsimpledb-kv-bdb

@Override
public synchronized void rollback() {
  if (this.closed)
    return;
  this.close();
  try {
    this.tx.abort();
  } catch (DatabaseException e) {
    throw this.wrapException(e);
  }
}

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

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

代码示例来源: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

@Override
public synchronized void rollback() throws BackendException {
  super.rollback();
  if (tx == null) return;
  if (log.isTraceEnabled())
    log.trace("{} rolled back", this.toString(), new TransactionClose(this.toString()));
  try {
    closeOpenIterators();
    tx.abort();
    tx = null;
  } catch (DatabaseException e) {
    throw new PermanentBackendException(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.jsimpledb/jsimpledb-kv-bdb

@Override
public synchronized void commit() {
  if (this.closed)
    throw new StaleTransactionException(this);
  this.close();
  try {
    if (this.readOnly)
      this.tx.abort();
    else
      this.tx.commit();
  } catch (DatabaseException e) {
    throw this.wrapException(e);
  }
}

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

public void testThrowableDuringAbort() throws Exception {
   doThrow(new RuntimeException()).when(transaction).abort();
   runner = new PreparableTransactionRunner(env);
   CurrentTransaction.getInstance(env).beginTransaction(null);
   int max = runner.abortOverflowingCurrentTriesOnError(transaction, 2);
   assert max == Integer.MAX_VALUE : "should have overflowed max tries, but got " + max;
  }
}

相关文章