use of com.thinkaurelius.titan.diskstorage.util.time.StandardDuration in project incubator-atlas by apache.
the class HBaseKeyColumnValueStoreTest method shouldSucceedInLockingIfLockMediatorSucceeds.
@Test
public void shouldSucceedInLockingIfLockMediatorSucceeds() throws BackendException {
when(storeManager.getMetaDataSchema("hbase")).thenReturn(new EntryMetaData[] { EntryMetaData.TIMESTAMP });
when(storeManager.getStorageConfig()).thenReturn(storageConfig);
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_EXPIRE)).thenReturn(new StandardDuration(300L, TimeUnit.MILLISECONDS));
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_WAIT)).thenReturn(new StandardDuration(10L, TimeUnit.MILLISECONDS));
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_RETRY)).thenReturn(3);
KeyColumn lockID = new KeyColumn(key, column);
when(localLockMediator.lock(eq(lockID), eq(transaction), any(Timepoint.class))).thenReturn(true);
HBaseKeyColumnValueStore hBaseKeyColumnValueStore = new HBaseKeyColumnValueStore(storeManager, connectionMask, "titan", "e", "hbase", localLockMediator);
hBaseKeyColumnValueStore.acquireLock(key, column, expectedValue, transaction);
verify(transaction).updateLocks(lockID, expectedValue);
verify(localLockMediator, times(1)).lock(eq(lockID), eq(transaction), any(Timepoint.class));
}
use of com.thinkaurelius.titan.diskstorage.util.time.StandardDuration in project incubator-atlas by apache.
the class HBaseKeyColumnValueStoreTest method shouldThrowExceptionAfterConfiguredRetriesIfLockMediationFails.
@Test(expectedExceptions = PermanentLockingException.class)
public void shouldThrowExceptionAfterConfiguredRetriesIfLockMediationFails() throws BackendException {
when(storeManager.getMetaDataSchema("hbase")).thenReturn(new EntryMetaData[] { EntryMetaData.TIMESTAMP });
when(storeManager.getStorageConfig()).thenReturn(storageConfig);
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_EXPIRE)).thenReturn(new StandardDuration(300L, TimeUnit.MILLISECONDS));
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_WAIT)).thenReturn(new StandardDuration(10L, TimeUnit.MILLISECONDS));
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_RETRY)).thenReturn(3);
KeyColumn lockID = new KeyColumn(key, column);
when(localLockMediator.lock(eq(lockID), eq(transaction), any(Timepoint.class))).thenReturn(false).thenReturn(false).thenReturn(false);
HBaseKeyColumnValueStore hBaseKeyColumnValueStore = new HBaseKeyColumnValueStore(storeManager, connectionMask, "titan", "e", "hbase", localLockMediator);
hBaseKeyColumnValueStore.acquireLock(key, column, expectedValue, transaction);
fail("Should fail as lock could not be acquired after 3 retries.");
}
use of com.thinkaurelius.titan.diskstorage.util.time.StandardDuration in project incubator-atlas by apache.
the class HBaseKeyColumnValueStoreTest method shouldRetryRightNumberOfTimesIfLockMediationFails.
@Test
public void shouldRetryRightNumberOfTimesIfLockMediationFails() throws BackendException {
when(storeManager.getMetaDataSchema("hbase")).thenReturn(new EntryMetaData[] { EntryMetaData.TIMESTAMP });
when(storeManager.getStorageConfig()).thenReturn(storageConfig);
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_EXPIRE)).thenReturn(new StandardDuration(300L, TimeUnit.MILLISECONDS));
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_WAIT)).thenReturn(new StandardDuration(10L, TimeUnit.MILLISECONDS));
when(storageConfig.get(GraphDatabaseConfiguration.LOCK_RETRY)).thenReturn(3);
KeyColumn lockID = new KeyColumn(key, column);
when(localLockMediator.lock(eq(lockID), eq(transaction), any(Timepoint.class))).thenReturn(false).thenReturn(false).thenReturn(true);
HBaseKeyColumnValueStore hBaseKeyColumnValueStore = new HBaseKeyColumnValueStore(storeManager, connectionMask, "titan", "e", "hbase", localLockMediator);
hBaseKeyColumnValueStore.acquireLock(key, column, expectedValue, transaction);
verify(transaction).updateLocks(lockID, expectedValue);
verify(localLockMediator, times(3)).lock(eq(lockID), eq(transaction), any(Timepoint.class));
}
Aggregations