Java Code Examples for com.sleepycat.je.TransactionConfig

The following examples show how to use com.sleepycat.je.TransactionConfig. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: qpid-broker-j   Author: apache   File: ReplicatedEnvironmentFacadeTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testBeginTransaction() throws Exception
{
    ReplicatedEnvironmentFacade facade = createMaster();
    Transaction txn = null;
    try
    {
        TransactionConfig transactionConfig = new TransactionConfig();
        transactionConfig.setDurability(facade.getRealMessageStoreDurability());
        txn = facade.beginTransaction(transactionConfig);
        assertNotNull("Transaction is not created", txn);
        txn.commit();
        txn = null;
    }
    finally
    {
        if (txn != null)
        {
            txn.abort();
        }
    }
}
 
Example #2
Source Project: qpid-broker-j   Author: apache   File: ReplicatedEnvironmentFacadeTest.java    License: Apache License 2.0 5 votes vote down vote up
private void putRecord(final ReplicatedEnvironmentFacade master, final Database db, final int keyValue,
                       final String dataValue)
{
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();

    TransactionConfig transactionConfig = new TransactionConfig();
    transactionConfig.setDurability(master.getRealMessageStoreDurability());
    Transaction txn = master.beginTransaction(transactionConfig);
    IntegerBinding.intToEntry(keyValue, key);
    StringBinding.stringToEntry(dataValue, data);

    db.put(txn, key, data);
    txn.commit();
}
 
Example #3
Source Project: qpid-broker-j   Author: apache   File: StandardEnvironmentFacade.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Transaction beginTransaction(TransactionConfig transactionConfig)
{
    return getEnvironment().beginTransaction(null, transactionConfig);
}
 
Example #4
Source Project: qpid-broker-j   Author: apache   File: OrphanConfigurationRecordPurger.java    License: Apache License 2.0 4 votes vote down vote up
private void purge() throws Exception
{
    EnvironmentConfig config = EnvironmentConfig.DEFAULT;
    config.setAllowCreate(false);
    config.setTransactional(true);

    try (Environment env = createEnvironment(config))
    {
        final int version = getVersion(env, READ_ONLY_DB_CONFIG);
        if (!ALLOWED_VERSIONS.contains(version))
        {
            throw new IllegalStateException(String.format("Store has unexpected version. Found %d expected %s",
                                                          version, ALLOWED_VERSIONS));
        }

        final Transaction tx = env.beginTransaction(null, TransactionConfig.DEFAULT);
        boolean success = false;
        try
        {
            purgeOrphans(env, tx);
            success = true;
        }
        finally
        {
            if (!success)
            {
                System.out.println("No config or config hierarchy records purged.");
                tx.abort();
            }
            else if (_dryRun)
            {
                System.out.println("No config or config hierarchy records purged - -dryRun flag specified.");
                tx.abort();
            }
            else
            {
                tx.commit();
                System.out.format("Config records(s) and associated hierarchy records purged.");
            }
        }
    }
}
 
Example #5
Source Project: tddl5   Author: loye168   File: JE_Transaction.java    License: Apache License 2.0 4 votes vote down vote up
public JE_Transaction(com.sleepycat.je.Transaction txn, com.sleepycat.je.TransactionConfig config,
                      AtomicReference<ITHLog> historyLog){
    this.txn = txn;
    this.config = config;
    this.historyLog = historyLog;
}
 
Example #6
Source Project: tddl   Author: cpsing   File: JE_Transaction.java    License: Apache License 2.0 4 votes vote down vote up
public JE_Transaction(com.sleepycat.je.Transaction txn, com.sleepycat.je.TransactionConfig config,
                      AtomicReference<ITHLog> historyLog){
    this.txn = txn;
    this.config = config;
    this.historyLog = historyLog;
}
 
Example #7
Source Project: qpid-broker-j   Author: apache   File: EnvironmentFacade.java    License: Apache License 2.0 votes vote down vote up
Transaction beginTransaction(TransactionConfig transactionConfig);