本文整理汇总了Java中com.sleepycat.je.TransactionConfig类的典型用法代码示例。如果您正苦于以下问题:Java TransactionConfig类的具体用法?Java TransactionConfig怎么用?Java TransactionConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionConfig类属于com.sleepycat.je包,在下文中一共展示了TransactionConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getConnection
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
public JEConnection getConnection(String jeRootDir,
EnvironmentConfig envConfig,
TransactionConfig transConfig)
throws JEException {
JEConnection dc = null;
JERequestInfo jeInfo =
new JERequestInfo(new File(jeRootDir), envConfig, transConfig);
try {
dc = (JEConnection) manager.allocateConnection(factory, jeInfo);
} catch (ResourceException e) {
throw new JEException("Unable to get Connection: " + e);
}
return dc;
}
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:JEConnectionFactoryImpl.java
示例2: beginTransaction
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Begins a new transaction for this environment and associates it with
* the current thread. If a transaction is already active for this
* environment and thread, a nested transaction will be created.
*
* @param config the transaction configuration used for calling
* {@link Environment#beginTransaction}, or null to use the default
* configuration.
*
* @return the new transaction.
*
* @throws DatabaseException if the transaction cannot be started, in which
* case any existing transaction is not affected.
*
* @throws IllegalStateException if a transaction is already active and
* nested transactions are not supported by the environment.
*/
public final Transaction beginTransaction(TransactionConfig config)
throws DatabaseException {
Trans trans = (Trans) localTrans.get();
if (trans != null) {
if (trans.txn != null) {
if (!DbCompat.NESTED_TRANSACTIONS) {
throw new IllegalStateException(
"Nested transactions are not supported");
}
Transaction parentTxn = trans.txn;
trans = new Trans(trans, config);
trans.txn = env.beginTransaction(parentTxn, config);
localTrans.set(trans);
} else {
trans.txn = env.beginTransaction(null, config);
trans.config = config;
}
} else {
trans = new Trans(null, config);
trans.txn = env.beginTransaction(null, config);
localTrans.set(trans);
}
return trans.txn;
}
开发者ID:nologic,项目名称:nabs,代码行数:43,代码来源:CurrentTransaction.java
示例3: flushToDatabase
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Mappings are flushed to disk at close, and at checkpoints.
*/
public void flushToDatabase(Durability useDurability) {
TransactionConfig config = new TransactionConfig();
config.setDurability(useDurability);
Txn txn = Txn.createLocalTxn(envImpl, config);
boolean success = false;
try {
flushToDatabase(txn);
txn.commit();
success = true;
} finally {
if (!success) {
txn.abort();
}
}
}
开发者ID:prat0318,项目名称:dbms,代码行数:20,代码来源:VLSNIndex.java
示例4: testReadUncommittedTransaction
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
public void testReadUncommittedTransaction()
throws Exception {
TransactionRunner runner = new TransactionRunner(env);
TransactionConfig config = new TransactionConfig();
config.setReadUncommitted(true);
runner.setTransactionConfig(config);
assertNull(currentTxn.getTransaction());
runner.run(new TransactionWorker() {
public void doWork() throws Exception {
assertNotNull(currentTxn.getTransaction());
doReadUncommitted(map);
}
});
assertNull(currentTxn.getTransaction());
}
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:TransactionTest.java
示例5: Txn
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* A non-zero mandatedId is specified only by subtypes which arbitrarily
* impose a transaction id value onto the transaction. This is done by
* implementing a version of Locker.generateId() which uses the proposed
* id.
*/
protected Txn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext,
long mandatedId)
throws DatabaseException {
/*
* Initialize using the config but don't hold a reference to it, since
* it has not been cloned.
*/
super(envImpl, config.getReadUncommitted(), config.getNoWait(),
mandatedId);
initTxn(config);
this.repContext = repContext;
}
开发者ID:prat0318,项目名称:dbms,代码行数:22,代码来源:Txn.java
示例6: createUserTxn
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
static Txn createUserTxn(EnvironmentImpl envImpl,
TransactionConfig config) {
Txn ret = null;
try {
ret = envImpl.isReplicated() ?
envImpl.createRepUserTxn(config) :
createLocalTxn(envImpl, config);
} catch (DatabaseException DE) {
if (ret != null) {
ret.close(false);
}
throw DE;
}
return ret;
}
开发者ID:prat0318,项目名称:dbms,代码行数:17,代码来源:Txn.java
示例7: openMappingDatabase
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
private void openMappingDatabase(String mappingDbName)
throws DatabaseException {
final Locker locker =
Txn.createLocalAutoTxn(envImpl, new TransactionConfig());
try {
DbTree dbTree = envImpl.getDbTree();
DatabaseImpl db = dbTree.getDb(locker,
mappingDbName,
null /* databaseHandle */);
if (db == null) {
if (envImpl.isReadOnly()) {
/* This should have been caught earlier. */
throw EnvironmentFailureException.unexpectedState
("A replicated environment can't be opened read only.");
}
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setReplicated(false);
db = dbTree.createInternalDb(locker, mappingDbName, dbConfig);
}
mappingDbImpl = db;
} finally {
locker.operationEnd(true);
}
}
开发者ID:prat0318,项目名称:dbms,代码行数:27,代码来源:VLSNIndex.java
示例8: getConnection
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
public JEConnection getConnection(String jeRootDir,
EnvironmentConfig envConfig,
TransactionConfig transConfig)
throws JEException {
JEConnection dc = null;
JERequestInfo jeInfo =
new JERequestInfo(new File(jeRootDir), envConfig, transConfig);
try {
dc = (JEConnection) manager.allocateConnection(factory, jeInfo);
} catch (ResourceException e) {
throw new JEException("Unable to get Connection: " + e);
}
return dc;
}
开发者ID:prat0318,项目名称:dbms,代码行数:17,代码来源:JEConnectionFactoryImpl.java
示例9: handlePrepare
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* The entry just read is a prepare record. Setup a PrepareTxn that will
* exempt any of its uncommitted LNs from undo. Instead, uncommitted LNs
* that belong to a PrepareTxn are redone.
* @throws DatabaseException
*/
private void handlePrepare(LNFileReader reader)
throws DatabaseException {
long prepareId = reader.getTxnPrepareId();
Long prepareIdL = Long.valueOf(prepareId);
if (!committedTxnIds.containsKey(prepareIdL) &&
!abortedTxnIds.contains(prepareIdL)) {
TransactionConfig txnConf = new TransactionConfig();
PreparedTxn preparedTxn = PreparedTxn.createPreparedTxn
(envImpl, txnConf, prepareId);
/*
* There should be no lock conflicts during recovery, but just in
* case there are, we set the locktimeout to 0.
*/
preparedTxn.setLockTimeout(0);
preparedTxns.put(prepareIdL, preparedTxn);
preparedTxn.setPrepared(true);
envImpl.getTxnManager().registerXATxn
(reader.getTxnPrepareXid(), preparedTxn, true);
LoggerUtils.logMsg(logger, envImpl, Level.INFO,
"Found unfinished prepare record: id: " +
reader.getTxnPrepareId() +
" Xid: " + reader.getTxnPrepareXid());
}
}
开发者ID:prat0318,项目名称:dbms,代码行数:33,代码来源:RecoveryManager.java
示例10: txnBeginHook
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Verifies that consistency requirements are met before allowing the
* transaction to proceed.
*/
@Override
protected void txnBeginHook(TransactionConfig config)
throws ReplicaConsistencyException, DatabaseException {
if (!envImpl.isReplicated()) {
return;
}
checkConsistency((RepImpl) envImpl, config.getConsistencyPolicy());
}
开发者ID:prat0318,项目名称:dbms,代码行数:14,代码来源:ReadonlyTxn.java
示例11: txnBegin
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Create a new transaction.
* @param parent for nested transactions, not yet supported
* @param txnConfig specifies txn attributes
* @return the new txn
*/
public Txn txnBegin(Transaction parent, TransactionConfig txnConfig)
throws DatabaseException {
if (parent != null) {
throw new DatabaseException
("Nested transactions are not supported yet.");
}
return new Txn(env, txnConfig);
}
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:TxnManager.java
示例12: Txn
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Create a transaction from Environment.txnBegin.
*/
public Txn(EnvironmentImpl envImpl, TransactionConfig config)
throws DatabaseException {
/*
* Initialize using the config but don't hold a reference to it, since
* it has not been cloned.
*/
super(envImpl, config.getReadUncommitted(), config.getNoWait());
init(envImpl, config);
}
开发者ID:nologic,项目名称:nabs,代码行数:14,代码来源:Txn.java
示例13: ReplayTxn
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Used when creating ReplayTxns at recovery. No ActiveTxns map is
* available.
*/
public ReplayTxn(EnvironmentImpl envImpl,
TransactionConfig config,
long txnId,
Logger logger)
throws DatabaseException {
super(envImpl,
config,
null, // ReplicationContext set later
txnId); // mandatedId
/* Preempt reader transactions when a lock conflict occurs. */
setImportunate(true);
this.logger = logger;
}
开发者ID:prat0318,项目名称:dbms,代码行数:19,代码来源:ReplayTxn.java
示例14: txnBeginHook
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Causes the transaction to wait until we have sufficient replicas to
* acknowledge the commit.
*/
@Override
@SuppressWarnings("unused")
protected void txnBeginHook(TransactionConfig config)
throws DatabaseException {
RepImpl repImpl = (RepImpl) envImpl;
try {
repImpl.txnBeginHook(this);
} catch (InterruptedException e) {
throw new ThreadInterruptedException(envImpl, e);
}
}
开发者ID:prat0318,项目名称:dbms,代码行数:17,代码来源:MasterTxn.java
示例15: JERequestInfo
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
public JERequestInfo(File rootDir,
EnvironmentConfig envConfig,
TransactionConfig transConfig) {
this.rootDir = rootDir;
this.envConfig = envConfig;
this.transConfig = transConfig;
}
开发者ID:nologic,项目名称:nabs,代码行数:8,代码来源:JERequestInfo.java
示例16: JELocalTransaction
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
JELocalTransaction(XAEnvironment env,
TransactionConfig transConfig,
JEManagedConnection mgdConn) {
this.env = env;
this.transConfig = transConfig;
this.mgdConn = mgdConn;
}
开发者ID:nologic,项目名称:nabs,代码行数:8,代码来源:JELocalTransaction.java
示例17: testNoWaitConfig
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
public void testNoWaitConfig()
throws Throwable {
try {
TransactionConfig defaultConfig = new TransactionConfig();
TransactionConfig noWaitConfig = new TransactionConfig();
noWaitConfig.setNoWait(true);
Transaction txn;
/* noWait=false */
assertTrue(!isNoWaitTxn(null));
txn = env.beginTransaction(null, null);
assertTrue(!isNoWaitTxn(txn));
txn.abort();
txn = env.beginTransaction(null, defaultConfig);
assertTrue(!isNoWaitTxn(txn));
txn.abort();
/* noWait=true */
txn = env.beginTransaction(null, noWaitConfig);
assertTrue(isNoWaitTxn(txn));
txn.abort();
} catch (Throwable t) {
/* print stack trace before going to teardown. */
t.printStackTrace();
throw t;
}
}
开发者ID:nologic,项目名称:nabs,代码行数:34,代码来源:TxnTest.java
示例18: testRangeInsertWaiterConflict
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Tests that when a range read/write is requested, and a range insert is
* waiting but not held, a WAIT_RESTART occurs. This requires that the
* waiter list is examined by Lock.lock().
*/
public void testRangeInsertWaiterConflict()
throws Exception {
Locker txn1 = new AutoTxn(envImpl, new TransactionConfig());
Locker txn2 = new AutoTxn(envImpl, new TransactionConfig());
Locker txn3 = new AutoTxn(envImpl, new TransactionConfig());
MemoryBudget mb = envImpl.getMemoryBudget();
try {
Lock lock = new Lock();
assertEquals(LockGrantType.NEW,
lock.lock(LockType.RANGE_READ, txn1, false, mb, 0));
assertEquals(LockGrantType.WAIT_NEW,
lock.lock(LockType.RANGE_INSERT, txn2, false, mb, 0));
assertEquals(LockGrantType.WAIT_RESTART,
lock.lock(LockType.RANGE_READ, txn3, false, mb, 0));
/* Check that 1 owner, 1 waiter exist. */
Set expectedOwners = new HashSet();
expectedOwners.add(new LockInfo(txn1, LockType.RANGE_READ));
checkOwners(expectedOwners, lock, 2);
List waiters = new ArrayList();
waiters.add(new LockInfo(txn2, LockType.RANGE_INSERT));
waiters.add(new LockInfo(txn3, LockType.RESTART));
checkWaiters(waiters, lock);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
txn1.operationEnd();
txn2.operationEnd();
txn3.operationEnd();
}
}
开发者ID:nologic,项目名称:nabs,代码行数:42,代码来源:LockTest.java
示例19: testIllegalTransactionConfig
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
public void testIllegalTransactionConfig()
throws DatabaseException, InterruptedException {
openEnv(false);
TransactionConfig config = new TransactionConfig();
config.setSerializableIsolation(true);
config.setReadUncommitted(true);
try {
Transaction txn = env.beginTransaction(null, config);
txn.abort();
fail();
} catch (IllegalArgumentException expected) {
}
closeEnv();
}
开发者ID:nologic,项目名称:nabs,代码行数:16,代码来源:PhantomTest.java
示例20: txnBegin
import com.sleepycat.je.TransactionConfig; //导入依赖的package包/类
/**
* Begin a txn if in TXN_USER mode; otherwise return null;
*/
protected Transaction txnBegin(Transaction parentTxn,
TransactionConfig config)
throws DatabaseException {
if (txnType == TXN_USER) {
return env.beginTransaction(parentTxn, config);
} else {
return null;
}
}
开发者ID:nologic,项目名称:nabs,代码行数:14,代码来源:TxnTestCase.java
注:本文中的com.sleepycat.je.TransactionConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论