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); }
private KeyColumnValueStore getLockStore(KeyColumnValueStore store) throws StorageException { if (!storeFeatures.supportsLocking()) { if (storeFeatures.isTransactional()) { store = new TransactionalLockStore(store); } else if (storeFeatures.supportsConsistentKeyOperations()) { store = new ConsistentKeyLockStore( store, getStore(store.getName() + LOCK_STORE_SUFFIX), lockConfiguration); } else throw new IllegalArgumentException("Store needs to support some form of locking"); } return store; }
public void initialize(Configuration config) { try { // EdgeStore & VertexIndexStore KeyColumnValueStore idStore = getStore(ID_STORE_NAME); idAuthority = null; if (storeFeatures.isTransactional()) { idAuthority = new TransactionalIDManager(idStore, storeManager, config); } else if (storeFeatures.supportsConsistentKeyOperations()) { idAuthority = new ConsistentKeyIDManager(idStore, storeManager, config); } else { idAuthority = new TransactionalIDManager(idStore, storeManager, config); log.error( "Store needs to support consistent key or transactional operations for ID manager to guarantee proper id allocations"); } edgeStore = getLockStore(getBufferStore(EDGESTORE_NAME)); vertexIndexStore = getLockStore(getBufferStore(VERTEXINDEX_STORE_NAME)); if (hashPrefixIndex) vertexIndexStore = new HashPrefixKeyColumnValueStore(vertexIndexStore, 4); } catch (StorageException e) { throw new TitanException("Could not initialize backend", e); } }