Search in sources :

Example 6 with Lock

use of com.twitter.heron.spi.statemgr.Lock in project heron by twitter.

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);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Lock(com.twitter.heron.spi.statemgr.Lock) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Lock (com.twitter.heron.spi.statemgr.Lock)6 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)2 TimeUnit (java.util.concurrent.TimeUnit)2 Matchers.anyString (org.mockito.Matchers.anyString)2 PackingPlans (com.twitter.heron.proto.system.PackingPlans)1 IScalable (com.twitter.heron.spi.scheduler.IScalable)1 Path (java.nio.file.Path)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1