/** * Opens a new transaction against all registered backend system wrapped in one {@link * BackendTransaction}. * * @return * @throws StorageException */ public BackendTransaction beginTransaction(TransactionConfiguration configuration) throws StorageException { StoreTxConfig txConfig = new StoreTxConfig(configuration.getMetricsPrefix()); if (configuration.hasTimestamp()) txConfig.setTimestamp(configuration.getTimestamp()); StoreTransaction tx = storeManager.beginTransaction(txConfig); if (bufferSize > 1) { Preconditions.checkArgument(storeManager.getFeatures().supportsBatchMutation()); tx = new BufferTransaction( tx, storeManager, bufferSize, writeAttempts, persistAttemptWaittime); } if (!storeFeatures.supportsLocking()) { if (storeFeatures.supportsTransactions()) { // No transaction wrapping needed } else if (storeFeatures.supportsConsistentKeyOperations()) { txConfig = new StoreTxConfig(ConsistencyLevel.KEY_CONSISTENT, configuration.getMetricsPrefix()); if (configuration.hasTimestamp()) txConfig.setTimestamp(configuration.getTimestamp()); tx = new ExpectedValueCheckingTransaction( tx, storeManager.beginTransaction(txConfig), readAttempts); } } // Index transactions Map<String, IndexTransaction> indexTx = new HashMap<String, IndexTransaction>(indexes.size()); for (Map.Entry<String, IndexProvider> entry : indexes.entrySet()) { indexTx.put(entry.getKey(), new IndexTransaction(entry.getValue())); } return new BackendTransaction( tx, storeManager.getFeatures(), edgeStore, vertexIndexStore, edgeIndexStore, readAttempts, persistAttemptWaittime, indexTx); }
public StoreTransaction startTx() throws StorageException { return manager.beginTransaction(new StoreTxConfig()); }