use of com.twitter.heron.spi.statemgr.Lock in project incubator-heron by apache.
the class LocalFileSystemStateManagerTest method testGetLock.
@Test
public void testGetLock() throws Exception {
initMocks();
String expectedLockPath = String.format("//locks/%s__%s", TOPOLOGY_NAME, LOCK_NAME.getName());
byte[] expectedContents = Thread.currentThread().getName().getBytes(Charset.defaultCharset());
Lock lock = manager.getLock(TOPOLOGY_NAME, LOCK_NAME);
assertTrue(lock.tryLock(0, TimeUnit.MILLISECONDS));
assertWriteToFile(expectedLockPath, expectedContents, false);
lock.unlock();
assertDeleteFile(expectedLockPath);
}
use of com.twitter.heron.spi.statemgr.Lock in project incubator-heron by apache.
the class UpdateTopologyManagerTest method mockLock.
private static Lock mockLock(boolean available) throws InterruptedException {
Lock lock = mock(Lock.class);
when(lock.tryLock(any(Long.class), any(TimeUnit.class))).thenReturn(available);
return lock;
}
Aggregations