当前位置: 首页>>代码示例>>Java>>正文


Java TransactionConfig.setDurability方法代码示例

本文整理汇总了Java中com.sleepycat.je.TransactionConfig.setDurability方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionConfig.setDurability方法的具体用法?Java TransactionConfig.setDurability怎么用?Java TransactionConfig.setDurability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sleepycat.je.TransactionConfig的用法示例。


在下文中一共展示了TransactionConfig.setDurability方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: configForNonRepDb

import com.sleepycat.je.TransactionConfig; //导入方法依赖的package包/类
/**
 * Configures a TransactionConfig for auto-commit operations on a
 * non-replicated transactional database on a replicated node. We use:
 * - default SyncPolicy for the environment
 * - ReplicaAckPolicy.NONE to avoid consistency checks on the Master
 * - Consistency.NONE to avoid consistency checks on the Replica
 */
private static void configForNonRepDb(TransactionConfig config,
                                      Durability envDurability) {
    config.setDurability(new Durability
        (envDurability.getLocalSync(), envDurability.getReplicaSync(), 
         Durability.ReplicaAckPolicy.NONE));
    config.setConsistencyPolicy
        (NoConsistencyRequiredPolicy.NO_CONSISTENCY);
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:16,代码来源:Store.java

示例3: truncateFromTail

import com.sleepycat.je.TransactionConfig; //导入方法依赖的package包/类
/**
 * Remove all information from the VLSNIndex for VLSNs >= deleteStart
 * Used by replica side syncup, when the log is truncated. Assumes that the
 * vlsnIndex is quiescent.
 * @throws DatabaseException
 */
public synchronized void truncateFromTail(VLSN deleteStart, long lastLsn)
    throws DatabaseException {

    logItemCache.clear();
    VLSNRange currentRange = tracker.getRange();
    if (currentRange.getLast().getNext().equals(deleteStart)) {

        /*
         * deleteStart directly follows what's in this range, no need to
         * delete anything.
         */
        return;
    }

    tracker.truncateFromTail(deleteStart, lastLsn);

    TransactionConfig config = new TransactionConfig();
    
    /* 
     * Be sure to commit synchronously so that changes to the vlsn index
     * are persisted before the log is truncated. There are no feeders or
     * repstream write operations at this time, so the use of COMMIT_SYNC
     * does not introduce any lock contention. [#20702]
     */
    config.setDurability(Durability.COMMIT_SYNC);
    Txn txn = Txn.createLocalTxn(envImpl, config);
    boolean success = false;
    try {
        pruneDatabaseTail(deleteStart, lastLsn, txn);
        flushToDatabase(txn);
        txn.commit();
        success = true;
    } finally {
        if (!success) {
            txn.abort();
        }
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:45,代码来源:VLSNIndex.java

示例4: getGroup

import com.sleepycat.je.TransactionConfig; //导入方法依赖的package包/类
/**
 * Returns all the members that are currently part of the replication
 * group. This method can read the database directly, and can be used when
 * the replicated environment is detached and the RepNode is null. It's for
 * the latter reason that the method reads uncommitted data. In detached
 * mode, there may be transactions on the database that were in progress
 * when the node was last shutdown. These transactions may have locks which
 * will not be released until after the node is re-attached and the
 * replication stream is resumed. Using uncommitted reads avoids use of
 * locks in this circumstance. It's safe to read these records, since the
 * database will eventually be updated with these changes.
 *
 * @param policy determines how current the information must be if it's
 * invoked on a Replica.
 *
 * @return the group object
 * @throws DatabaseException if the object could not be obtained
 */
public static RepGroupImpl getGroup(RepImpl rImpl,
                                    String groupName,
                                    ReplicaConsistencyPolicy policy)
    throws DatabaseException {

    DatabaseImpl dbImpl = null;
    try {
        dbImpl = rImpl.getGroupDb(policy);
    } catch (DatabaseNotFoundException e) {
        /* Creates a temporary placeholder group for use until the real
         * definition comes over the replication stream as part of the
         * replicated group database.
         */
        return new RepGroupImpl(groupName, true);
    }

    TransactionConfig txnConfig = new TransactionConfig();
    txnConfig.setDurability(READ_ONLY.getDurability());
    txnConfig.setConsistencyPolicy(policy);
    txnConfig.setReadUncommitted(true);

    Txn txn = null;
    try {
        txn = new ReadonlyTxn(rImpl, txnConfig);
        RepGroupImpl group = fetchGroup(groupName, dbImpl, txn);
        /* Correct summary info since we are reading uncommitted data */
        group.makeConsistent();
        txn.commit();
        txn = null;

        return group;
    } finally {
        if (txn != null) {
            txn.abort();
        }
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:56,代码来源:RepGroupDB.java

示例5: addFirstNode

import com.sleepycat.je.TransactionConfig; //导入方法依赖的package包/类
/**
 * Ensures that information about this node, the current master is in the
 * member database. If it isn't, enter it into the database. If the
 * database does not exist, create it as well.
 *
 * Note that this overloading is only used by a node that is the master.
 *
 * @throws DatabaseException
 */
public void addFirstNode()
    throws DatabaseException {

    DbConfigManager configManager = repImpl.getConfigManager();
    String groupName = configManager.get(GROUP_NAME);
    String nodeName = configManager.get(NODE_NAME);

    DatabaseImpl groupDbImpl = repImpl.createGroupDb();

    /* setup the group information as data. */
    GroupBinding groupBinding = new GroupBinding();
    RepGroupImpl repGroup =  new RepGroupImpl(groupName);
    DatabaseEntry groupEntry = new DatabaseEntry();
    groupBinding.objectToEntry(repGroup, groupEntry);

    /* Create the common group entry. */
    TransactionConfig txnConfig = new TransactionConfig();
    txnConfig.setDurability(NO_ACK.getDurability());
    txnConfig.setConsistencyPolicy(NO_CONSISTENCY);
    Txn txn = null;
    Cursor cursor = null;
    try {
        txn = new MasterTxn(repImpl,
                            txnConfig,
                            repImpl.getNameIdPair());

        cursor = makeCursor(groupDbImpl, txn, CursorConfig.DEFAULT);
        OperationStatus status = cursor.put(groupKeyEntry, groupEntry);
        if (status != OperationStatus.SUCCESS) {
            throw EnvironmentFailureException.unexpectedState
                ("Couldn't write first group entry " + status);
        }
        cursor.close();
        cursor = null;
        txn.commit();
        txn = null;
    } finally {
        if (cursor != null) {
            cursor.close();
        }

        if (txn != null) {
            txn.abort();
        }
    }

    ensureMember(new RepNodeImpl(nodeName,
                                 repImpl.getHostName(),
                                 repImpl.getPort()));
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:60,代码来源:RepGroupDB.java


注:本文中的com.sleepycat.je.TransactionConfig.setDurability方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。