MCPcopy Create free account
hub / github.com/1345414527/MIT6.830 / grabLock

Method grabLock

test/simpledb/LockingTest.java:92–104  ·  view source on GitHub ↗

Generic unit test structure to grab an additional lock in a new thread. @param tid the transaction Id @param pid the first page to lock over @param perm the type of lock desired @param expected true if we expect the acquisition to succeed; false otherwise

(TransactionId tid, PageId pid, Permissions perm,
      boolean expected)

Source from the content-addressed store, hash-verified

90 * false otherwise
91 */
92 public void grabLock(TransactionId tid, PageId pid, Permissions perm,
93 boolean expected) throws Exception {
94
95 TestUtil.LockGrabber t = new TestUtil.LockGrabber(tid, pid, perm);
96 t.start();
97
98 // if we don't have the lock after TIMEOUT, we assume blocking.
99 Thread.sleep(TIMEOUT);
100 assertEquals(expected, t.acquired());
101
102 // TODO(ghuo): yes, stop() is evil, but this is unit test cleanup
103 t.stop();
104 }
105
106 /**
107 * Unit test for BufferPool.getPage() assuming locking.

Callers 1

metaLockTesterMethod · 0.95

Calls 2

acquiredMethod · 0.95
startMethod · 0.45

Tested by

no test coverage detected