com.sleepycat.je.LockConflictException Java Examples

The following examples show how to use com.sleepycat.je.LockConflictException. 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 File: TransactionContext.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
/**
 * 检查是否需要尝试
 * 
 * @return true需要尝试,false不需要尝试.
 */
boolean retry() {
    // 是否为嵌套事务
    if (count != 0) {
        return false;
    }

    if (triedTimes < annotation.tryTimes()) {
        // 如果为锁冲突异常则等待指定时间.
        if (exception instanceof LockConflictException) {
            long wait = System.currentTimeMillis() + annotation.conflictWait();
            while (wait > System.currentTimeMillis()) {
                Thread.yield();
            }
        }
        exception = null;
        triedTimes++;
        transactor = null;
        return true;
    }
    return false;
}
 
Example #2
Source File: AbstractBDBMessageStore.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
private void sleepOrThrowOnLockConflict(int attempts, String throwMessage, LockConflictException cause)
{
    if (attempts < LOCK_RETRY_ATTEMPTS)
    {
        getLogger().info("Lock conflict exception. Retrying (attempt {} of {})", attempts, LOCK_RETRY_ATTEMPTS);
        try
        {
            Thread.sleep(500l + (long)(500l * _lockConflictRandom.nextDouble()));
        }
        catch (InterruptedException ie)
        {
            Thread.currentThread().interrupt();
            throw getEnvironmentFacade().handleDatabaseException(throwMessage, cause);
        }
    }
    else
    {
        // rethrow the lock conflict exception since we could not solve by retrying
        throw getEnvironmentFacade().handleDatabaseException(throwMessage, cause);
    }
}
 
Example #3
Source File: BimserverLockConflictException.java    From BIMserver with GNU Affero General Public License v3.0 4 votes vote down vote up
public BimserverLockConflictException(LockConflictException e) {
	super(e);
}
 
Example #4
Source File: BimserverLockConflictException.java    From BIMserver with GNU Affero General Public License v3.0 4 votes vote down vote up
public LockConflictException getLockException() {
	return (LockConflictException) getCause();
}