Search in sources :

Example 1 with StandardDuration

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));
}
Also used : StandardDuration(com.thinkaurelius.titan.diskstorage.util.time.StandardDuration) KeyColumn(com.thinkaurelius.titan.diskstorage.util.KeyColumn) Timepoint(com.thinkaurelius.titan.diskstorage.util.time.Timepoint) Test(org.testng.annotations.Test)

Example 2 with StandardDuration

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.");
}
Also used : StandardDuration(com.thinkaurelius.titan.diskstorage.util.time.StandardDuration) KeyColumn(com.thinkaurelius.titan.diskstorage.util.KeyColumn) Timepoint(com.thinkaurelius.titan.diskstorage.util.time.Timepoint) Test(org.testng.annotations.Test)

Example 3 with StandardDuration

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));
}
Also used : StandardDuration(com.thinkaurelius.titan.diskstorage.util.time.StandardDuration) KeyColumn(com.thinkaurelius.titan.diskstorage.util.KeyColumn) Timepoint(com.thinkaurelius.titan.diskstorage.util.time.Timepoint) Test(org.testng.annotations.Test)

Aggregations

KeyColumn (com.thinkaurelius.titan.diskstorage.util.KeyColumn)3 StandardDuration (com.thinkaurelius.titan.diskstorage.util.time.StandardDuration)3 Timepoint (com.thinkaurelius.titan.diskstorage.util.time.Timepoint)3 Test (org.testng.annotations.Test)3