Пример #1
0
 @Override
 public void setup() throws Exception {
   StoreManager m = openStorageManager();
   m.clearStorage();
   m.close();
   super.setup();
 }
Пример #2
0
 public BackendTransaction beginTransaction() throws StorageException {
   StoreTransaction tx = storeManager.beginTransaction(ConsistencyLevel.DEFAULT);
   if (bufferSize > 1) {
     assert storeManager.getFeatures().supportsBatchMutation();
     if (isKeyColumnValueStore) {
       assert storeManager instanceof KeyColumnValueStoreManager;
       tx =
           new BufferTransaction(
               tx,
               (KeyColumnValueStoreManager) storeManager,
               bufferSize,
               writeAttempts,
               persistAttemptWaittime);
     } else {
       assert storeManager instanceof KeyValueStoreManager;
       // TODO: support buffer mutations
     }
   }
   if (!storeFeatures.supportsLocking()) {
     if (storeFeatures.isTransactional()) {
       // No transaction wrapping needed
     } else if (storeFeatures.supportsConsistentKeyOperations()) {
       tx =
           new ConsistentKeyLockTransaction(
               tx, storeManager.beginTransaction(ConsistencyLevel.KEY_CONSISTENT));
     }
   }
   return new BackendTransaction(tx);
 }
Пример #3
0
  public Backend(Configuration storageConfig) {
    storeManager = getStorageManager(storageConfig);
    isKeyColumnValueStore = storeManager instanceof KeyColumnValueStoreManager;
    storeFeatures = storeManager.getFeatures();

    int bufferSizeTmp = storageConfig.getInt(BUFFER_SIZE_KEY, BUFFER_SIZE_DEFAULT);
    Preconditions.checkArgument(
        bufferSizeTmp >= 0, "Buffer size must be non-negative (use 0 to disable)");
    if (!storeFeatures.supportsBatchMutation()) {
      bufferSize = 0;
      log.debug("Buffering disabled because backend does not support batch mutations");
    } else bufferSize = bufferSizeTmp;

    if (!storeFeatures.supportsLocking() && storeFeatures.supportsConsistentKeyOperations()) {
      lockConfiguration =
          new ConsistentKeyLockConfiguration(storageConfig, storeManager.toString());
    } else {
      lockConfiguration = null;
    }

    writeAttempts = storageConfig.getInt(WRITE_ATTEMPTS_KEY, WRITE_ATTEMPTS_DEFAULT);
    Preconditions.checkArgument(writeAttempts > 0, "Write attempts must be positive");
    readAttempts = storageConfig.getInt(READ_ATTEMPTS_KEY, READ_ATTEMPTS_DEFAULT);
    Preconditions.checkArgument(readAttempts > 0, "Read attempts must be positive");
    persistAttemptWaittime =
        storageConfig.getInt(STORAGE_ATTEMPT_WAITTIME_KEY, STORAGE_ATTEMPT_WAITTIME_DEFAULT);
    Preconditions.checkArgument(
        persistAttemptWaittime > 0, "Persistence attempt retry wait time must be non-negative");

    if (storeFeatures.isDistributed() && storeFeatures.isKeyOrdered()) {
      log.debug("Wrapping index store with HashPrefix");
      hashPrefixIndex = true;
    } else {
      hashPrefixIndex = false;
    }
  }
Пример #4
0
 private KeyColumnValueStore getBufferStore(String name) throws StorageException {
   Preconditions.checkArgument(
       bufferSize <= 1 || storeManager.getFeatures().supportsBatchMutation());
   KeyColumnValueStore store = null;
   if (isKeyColumnValueStore) {
     assert storeManager instanceof KeyColumnValueStoreManager;
     store = ((KeyColumnValueStoreManager) storeManager).openDatabase(name);
     if (bufferSize > 1) {
       store = new BufferedKeyColumnValueStore(store, true);
     }
   } else {
     assert storeManager instanceof KeyValueStoreManager;
     KeyValueStore kvstore = ((KeyValueStoreManager) storeManager).openDatabase(name);
     if (bufferSize > 1) {
       // TODO: support buffer mutations for KeyValueStores
     }
     store = KeyValueStoreManagerAdapter.wrapKeyValueStore(kvstore, staticKeyLengths);
   }
   return store;
 }
Пример #5
0
 public void clearStorage() throws StorageException {
   edgeStore.close();
   vertexIndexStore.close();
   idAuthority.close();
   storeManager.clearStorage();
 }
Пример #6
0
 public StoreFeatures getStoreFeatures() {
   return storeManager.getFeatures();
 }