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


Java DeadlockException类代码示例

本文整理汇总了Java中com.sleepycat.je.DeadlockException的典型用法代码示例。如果您正苦于以下问题:Java DeadlockException类的具体用法?Java DeadlockException怎么用?Java DeadlockException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: makeTimeoutMsg

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
    * @see LockManager#makeTimeoutMsg
    */
   protected DeadlockException makeTimeoutMsg(String lockOrTxn,
				       Locker locker,
				       long nodeId,
				       LockType type,
				       LockGrantType grantType,
				       Lock useLock,
				       long timeout,
				       long start,
				       long now,
				       DatabaseImpl database)
       throws DatabaseException {

int lockTableIndex = getLockTableIndex(nodeId);
Latch latch = lockTableLatches[lockTableIndex];
       latch.acquire();
       try {
           return makeTimeoutMsgInternal(lockOrTxn, locker,
                                         nodeId, type, grantType,
                                         useLock, timeout, start, now,
				  database);
       } finally {
           latch.release();
       }
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:28,代码来源:LatchedLockManager.java

示例2: makeTimeoutMsg

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
    * @see LockManager#makeTimeoutMsg
    */
   protected DeadlockException makeTimeoutMsg(String lockOrTxn,
				       Locker locker,
				       long nodeId,
				       LockType type,
				       LockGrantType grantType,
				       Lock useLock,
				       long timeout,
				       long start,
				       long now,
				       DatabaseImpl database) {

int lockTableIndex = getLockTableIndex(nodeId);
       synchronized(lockTableLatches[lockTableIndex]) {
           return makeTimeoutMsgInternal(lockOrTxn, locker, nodeId, type,
                                         grantType, useLock, timeout,
                                         start, now, database);
       }
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:22,代码来源:SyncedLockManager.java

示例3: testGetSearchKey_Success

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
public void testGetSearchKey_Success()
    throws DatabaseException, InterruptedException {

    openEnv(false);

    /* Insert key 2. */
    insert(2);

    /* getSearchKey returns key 2. */
    Transaction readerTxn = env.beginTransaction(null, txnConfig);
    Cursor cursor = db.openCursor(readerTxn, null);
    assertEquals(OperationStatus.SUCCESS, searchKey(cursor, 2));

    /* Insertions are never blocked. */
    try {
        insert(1);
    } catch (DeadlockException e) {
        fail();
    }

    cursor.close();
    readerTxn.commitNoSync();
    closeEnv();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:25,代码来源:PhantomTest.java

示例4: testGetSearchKey_Success_Dup

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
public void testGetSearchKey_Success_Dup()
    throws DatabaseException, InterruptedException {

    openEnv(true);

    /* Insert dups. */
    insert(1, 2);
    insert(1, 3);

    /* getSearchKey returns key {1,2}. */
    Transaction readerTxn = env.beginTransaction(null, txnConfig);
    Cursor cursor = db.openCursor(readerTxn, null);
    assertEquals(OperationStatus.SUCCESS, searchKey(cursor, 1, 2));

    /* Insertions are never blocked. */
    try {
        insert(1, 1);
    } catch (DeadlockException e) {
        fail();
    }

    cursor.close();
    readerTxn.commitNoSync();
    closeEnv();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:PhantomTest.java

示例5: testGetSearchBoth_Success

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
public void testGetSearchBoth_Success()
    throws DatabaseException, InterruptedException {

    openEnv(false);

    /* Insert key 2. */
    insert(2);

    /* getSearchBoth returns {2,0}. */
    Transaction readerTxn = env.beginTransaction(null, txnConfig);
    Cursor cursor = db.openCursor(readerTxn, null);
    assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 2, 0));

    /* Insertions are never blocked. */
    try {
        insert(1);
    } catch (DeadlockException e) {
        fail();
    }

    cursor.close();
    readerTxn.commitNoSync();
    closeEnv();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:25,代码来源:PhantomTest.java

示例6: testGetSearchBoth_Success_Dup

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
public void testGetSearchBoth_Success_Dup()
    throws DatabaseException, InterruptedException {

    openEnv(true);

    /* Insert dups. */
    insert(1, 1);
    insert(1, 3);

    /* getSearchBoth returns key {1,3}. */
    Transaction readerTxn = env.beginTransaction(null, txnConfig);
    Cursor cursor = db.openCursor(readerTxn, null);
    assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 3));

    /* Insertions are never blocked. */
    try {
        insert(1, 2);
    } catch (DeadlockException e) {
        fail();
    }

    cursor.close();
    readerTxn.commitNoSync();
    closeEnv();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:PhantomTest.java

示例7: insert

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
 * Inserts the given key and data in a new transaction and commits it.
 */
private void insert(int keyVal, int dataVal)
    throws DatabaseException {

    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    IntegerBinding.intToEntry(keyVal, key);
    IntegerBinding.intToEntry(dataVal, data);
    OperationStatus status;
    Transaction writerTxn = env.beginTransaction(null, txnConfig);
    try {
        if (dups) {
            status = db.putNoDupData(writerTxn, key, data);
        } else {
            status = db.putNoOverwrite(writerTxn, key, data);
        }
    } catch (DeadlockException e) {
        writerTxn.abort();
        throw e;
    }
    assertEquals(OperationStatus.SUCCESS, status);
    writerTxn.commitNoSync();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:PhantomTest.java

示例8: insert

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
 * Inserts the given key and data in a new transaction and commits it.
 */
private void insert(int keyVal, int dataVal)
    throws DatabaseException {

    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    IntegerBinding.intToEntry(keyVal, key);
    IntegerBinding.intToEntry(dataVal, data);
    OperationStatus status;
    Transaction writerTxn = env.beginTransaction(null, null);
    try {
        if (dups) {
            status = db.putNoDupData(writerTxn, key, data);
        } else {
            status = db.putNoOverwrite(writerTxn, key, data);
        }
    } catch (DeadlockException e) {
        writerTxn.abort();
        throw e;
    }
    assertEquals(OperationStatus.SUCCESS, status);
    writerTxn.commitNoSync();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:PhantomRestartTest.java

示例9:

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
    * Create a informative lock or txn timeout message.
    */
   protected abstract DeadlockException
makeTimeoutMsg(String lockOrTxn,
	       Locker locker,
	       long nodeId,
	       LockType type,
	       LockGrantType grantType,
	       Lock useLock,
	       long timeout,
	       long start,
	       long now,
	       DatabaseImpl database)
throws DatabaseException;
 
开发者ID:nologic,项目名称:nabs,代码行数:16,代码来源:LockManager.java

示例10: makeTimeoutMsg

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
    * @see LockManager#makeTimeoutMsg
    */
   protected DeadlockException makeTimeoutMsg(String lockOrTxn,
				       Locker locker,
				       long nodeId,
				       LockType type,
				       LockGrantType grantType,
				       Lock useLock,
				       long timeout,
				       long start,
				       long now,
				       DatabaseImpl database) {

return null;
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:DummyLockManager.java

示例11: checkSerializable

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
private void checkSerializable(boolean expectSerializable,
                               EnvironmentConfig envConfig,
                               CursorConfig cursorConfig,
                               LockMode lockMode)
    throws DatabaseException, InterruptedException {

    openEnv(false, envConfig);
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    OperationStatus status;

    /* Insert key 2. */
    insert(2);

    /* getFirst returns key 2. */
    Transaction readerTxn = env.beginTransaction(null, null);
    Cursor cursor = db.openCursor(readerTxn, cursorConfig);
    status = cursor.getFirst(key, data, lockMode);
    assertEquals(OperationStatus.SUCCESS, status);
    assertEquals(2, IntegerBinding.entryToInt(key));

    /* Should deadlock iff serializable. */
    try {
        insert(1);
        assertTrue(!expectSerializable);
    } catch (DeadlockException e) {
        assertTrue(expectSerializable);
    }

    cursor.close();
    readerTxn.commit();

    /* This method is called multiple times so remove the database. */
    db.close();
    db = null;
    env.removeDatabase(null, DB_NAME);

    closeEnv();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:40,代码来源:PhantomTest.java

示例12: testSingleDatumBug

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
 * Tests a particular getSearchBothRange bug that has come up in several
 * contexts.  This test is probably redundant with GetSearchBothTest but
 * I've left it here for good measure.
 */
public void testSingleDatumBug()
    throws DatabaseException, InterruptedException {

    openEnv(true);
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    OperationStatus status;

    insert(1, 1);
    insert(2, 2);

    /* getSearchBothRange for {2, 1} returns {2, 2}. */
    Transaction readerTxn = env.beginTransaction(null, txnConfig);
    Cursor cursor = db.openCursor(readerTxn, null);
    IntegerBinding.intToEntry(2, key);
    IntegerBinding.intToEntry(1, data);
    status = cursor.getSearchBothRange(key, data, null);
    assertEquals(OperationStatus.SUCCESS, status);
    assertEquals(2, IntegerBinding.entryToInt(key));
    assertEquals(2, IntegerBinding.entryToInt(data));

    /* If serializable, inserting in the locked range should deadlock. */
    try {
        insert(1, 2);
        if (txnSerializable) {
            fail();
        }
    } catch (DeadlockException e) {
        if (!txnSerializable) {
            fail();
        }
    }

    cursor.close();
    readerTxn.commitNoSync();
    closeEnv();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:43,代码来源:PhantomTest.java

示例13: runOverwriteNoDuplicates

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
   * The old put() implementation first did a search, then inserted if
   * NOTFOUND was returned by the search.  This test tries to create the
   * situation where one thread does a search on a key that returns NOTFOUND
   * and another thread immediately afterwards inserts the same key, before
   * the first thread has a chance to start the insert.  Before the fix to
   * make put() atomic, the first thread would have returned KEYEXIST from
   * put(), and that should never happen.
   */
  public void runOverwriteNoDuplicates()
      throws DatabaseException {

      DatabaseEntry key = new DatabaseEntry();
      DatabaseEntry data = new DatabaseEntry();
      while (nextKey < MAX_KEY) {
          /*
           * Attempt to insert the same key as was just inserted by the other
           * thread.  We need to keep incrementing the key, since the error
           * only occurs for a non-existing key value.
           */
          int val = nextKey++ / 2;
          Transaction txn = txnBegin();
          key.setData(TestUtils.getTestArray(val));
          data.setData(TestUtils.getTestArray(val));
   boolean commit = true;
   try {
OperationStatus status = db.put(txn, key, data);
assertEquals("Key=" + val, OperationStatus.SUCCESS, status);
   } catch (DeadlockException DE) {
commit = false;
   }
   if (commit) {
txnCommit(txn);
   } else {
txnAbort(txn);
   }
      }
  }
 
开发者ID:nologic,项目名称:nabs,代码行数:39,代码来源:AtomicPutTest.java

示例14: runOverwriteNoDuplicates

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
   * The old put() implementation first did a search, then inserted if
   * NOTFOUND was returned by the search.  This test tries to create the
   * situation where one thread does a search on a key that returns NOTFOUND
   * and another thread immediately afterwards inserts the same key, before
   * the first thread has a chance to start the insert.  Before the fix to
   * make put() atomic, the first thread would have returned KEYEXIST from
   * put(), and that should never happen.
   */
  public void runOverwriteNoDuplicates() 
      throws DatabaseException {

      DatabaseEntry key = new DatabaseEntry();
      DatabaseEntry data = new DatabaseEntry();
      while (nextKey < MAX_KEY) {
          /*
           * Attempt to insert the same key as was just inserted by the other
           * thread.  We need to keep incrementing the key, since the error
           * only occurs for a non-existing key value.
           */
          int val = nextKey++ / 2;
          Transaction txn = txnBegin();
          key.setData(TestUtils.getTestArray(val));
          data.setData(TestUtils.getTestArray(val));
   boolean commit = true;
   try {
OperationStatus status = db.put(txn, key, data);
assertEquals("Key=" + val, OperationStatus.SUCCESS, status);
   } catch (DeadlockException DE) {
commit = false;
   }
   if (commit) {
txnCommit(txn);
   } else {
txnAbort(txn);
   }
      }
  }
 
开发者ID:nologic,项目名称:nabs,代码行数:39,代码来源:AtomicPutTest.java

示例15: newTxnTimeoutException

import com.sleepycat.je.DeadlockException; //导入依赖的package包/类
/**
 * This method should always be called instead of explicitly creating
 * TransactionTimeoutException, to ensure that je.lock.oldLockExceptions is
 * enforced.
 */
@SuppressWarnings("deprecation")
private LockConflictException newTxnTimeoutException(Locker locker,
                                                     String msg) {
    return oldLockExceptions ?
        new DeadlockException(locker, msg) :
        new TransactionTimeoutException(locker, msg);
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:13,代码来源:LockManager.java


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