本文整理汇总了Java中com.sleepycat.je.LockNotAvailableException类的典型用法代码示例。如果您正苦于以下问题:Java LockNotAvailableException类的具体用法?Java LockNotAvailableException怎么用?Java LockNotAvailableException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LockNotAvailableException类属于com.sleepycat.je包,在下文中一共展示了LockNotAvailableException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryLock
import com.sleepycat.je.LockNotAvailableException; //导入依赖的package包/类
public synchronized boolean tryLock() {
try {
if (readCount.get() == 0) {
// lock = getEnv().getLock(getLockerId(), true, objectId, LockRequestMode.READ);
}
if (lock != null) {
readCount.set(readCount.get() + 1);
return true;
}
else {
return false;
}
}
catch (LockNotAvailableException le) {
return false;
}
catch (DatabaseException ex) {
throw new HGException(ex);
}
}
示例2: lock
import com.sleepycat.je.LockNotAvailableException; //导入依赖的package包/类
/**
* Request a blocking or non-blocking lock of the given type on the given
* LSN.
*
* @param lsn is the node to lock.
*
* @param lockType is the type of lock to request.
*
* @param noWait is true to override the defaultNoWait setting. If true,
* or if defaultNoWait is true, throws LockNotAvailableException if the
* lock cannot be granted without waiting.
*
* @param database is the database containing lsn.
*
* @throws LockNotAvailableException if a non-blocking lock was denied.
*
* @throws LockConflictException if a blocking lock could not be acquired.
*/
public LockResult lock(long lsn,
LockType lockType,
boolean noWait,
DatabaseImpl database)
throws LockNotAvailableException, LockConflictException {
final LockResult result = lockInternal
(lsn, lockType, noWait, false /*jumpAheadOfWaiters*/, database);
if (result.getLockGrant() == LockGrantType.DENIED) {
/* DENIED can only be returned for a non-blocking lock. */
throw lockManager.newLockNotAvailableException
(this, "Non-blocking lock was denied.");
} else {
checkPreempted(closingLocker);
return result;
}
}
示例3: lockInternal
import com.sleepycat.je.LockNotAvailableException; //导入依赖的package包/类
/**
* Provides a wrapper to screen for write locks. The use of write locks is
* used to infer that an attempt is being made to modify a replicated
* database. Note that this technique misses "conditional" updates, for
* example a delete operation using a non-existent key, but we are ok with
* that since the primary intent here is to ensure the integrity of the
* replicated stream that is being played back at that replica and these
* checks prevent such mishaps.
*/
@Override
public LockResult lockInternal(long lsn,
LockType lockType,
boolean noWait,
boolean jumpAheadOfWaiters,
DatabaseImpl database)
throws LockNotAvailableException, LockConflictException,
DatabaseException {
if (lockType.isWriteLock() && !database.allowReplicaWrite()) {
disallowReplicaWrite();
}
return super.lockInternal
(lsn, lockType, noWait, jumpAheadOfWaiters, database);
}
示例4: lockInternal
import com.sleepycat.je.LockNotAvailableException; //导入依赖的package包/类
/**
* Prevent this MasterTxn from taking locks if the node becomes a
* replica. The application has a reference to this Txn, and may
* attempt to use it well after the node has transitioned from master
* to replica.
*/
@Override
public LockResult lockInternal(long lsn,
LockType lockType,
boolean noWait,
boolean jumpAheadOfWaiters,
DatabaseImpl database)
throws LockNotAvailableException, LockConflictException,
DatabaseException {
ReplicatedEnvironment.State nodeState = ((RepImpl)envImpl).getState();
if (nodeState.isMaster()) {
return super.lockInternal
(lsn, lockType, noWait, jumpAheadOfWaiters, database);
}
throwNotMaster(nodeState);
return null; /* not reached */
}
示例5: newLockNotAvailableException
import com.sleepycat.je.LockNotAvailableException; //导入依赖的package包/类
/**
* This method should always be called instead of explicitly creating
* LockNotAvailableException, to ensure that je.lock.oldLockExceptions is
* enforced.
*/
LockConflictException newLockNotAvailableException(Locker locker,
String msg) {
return oldLockExceptions ?
new LockNotGrantedException(locker, msg) :
new LockNotAvailableException(locker, msg);
}