private Log openLog(String logManagerName, String logName) {
   try {
     ModifiableConfiguration configuration =
         new ModifiableConfiguration(
             GraphDatabaseConfiguration.ROOT_NS,
             config.copy(),
             BasicConfiguration.Restriction.NONE);
     configuration.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "reader");
     configuration.set(
         GraphDatabaseConfiguration.LOG_READ_INTERVAL, Duration.ofMillis(500L), logManagerName);
     if (logStoreManager == null) {
       logStoreManager = Backend.getStorageManager(configuration);
     }
     StoreFeatures f = logStoreManager.getFeatures();
     boolean part = f.isDistributed() && f.isKeyOrdered();
     if (part) {
       for (String logname : new String[] {USER_LOG, TRANSACTION_LOG, MANAGEMENT_LOG})
         configuration.set(KCVSLogManager.LOG_MAX_PARTITIONS, 8, logname);
     }
     assert logStoreManager != null;
     if (!logManagers.containsKey(logManagerName)) {
       // Open log manager - only supports KCVSLog
       Configuration logConfig = configuration.restrictTo(logManagerName);
       Preconditions.checkArgument(
           logConfig.get(LOG_BACKEND).equals(LOG_BACKEND.getDefaultValue()));
       logManagers.put(logManagerName, new KCVSLogManager(logStoreManager, logConfig));
     }
     assert logManagers.containsKey(logManagerName);
     return logManagers.get(logManagerName).openLog(logName);
   } catch (BackendException e) {
     throw new TitanException("Could not open log: " + logName, e);
   }
 }
 public AbstractStoreManager(Configuration storageConfig) {
   batchLoading = storageConfig.get(STORAGE_BATCH);
   boolean transactional = storageConfig.get(STORAGE_TRANSACTIONAL);
   if (batchLoading) {
     transactional = false;
   }
   this.transactional = transactional;
   this.storageConfig = storageConfig;
 }
  public EntryMetaData[] getMetaDataSchema(String storeName) {
    List<EntryMetaData> schemaBuilder = Lists.newArrayList();
    StoreFeatures features = getFeatures();
    if (features.hasTimestamps() && storageConfig.get(STORE_META_TIMESTAMPS, storeName))
      schemaBuilder.add(EntryMetaData.TIMESTAMP);
    if (features.hasCellTTL() && storageConfig.get(STORE_META_TTL, storeName))
      schemaBuilder.add(EntryMetaData.TTL);
    if (features.hasVisibility() && storageConfig.get(STORE_META_VISIBILITY, storeName))
      schemaBuilder.add(EntryMetaData.VISIBILITY);

    if (schemaBuilder.isEmpty()) return StaticArrayEntry.EMPTY_SCHEMA;
    return schemaBuilder.toArray(new EntryMetaData[schemaBuilder.size()]);
  }
  @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));
  }
  @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.");
  }