com.thinkaurelius.titan.diskstorage

## Class BackendTransaction

- java.lang.Object
- - com.thinkaurelius.titan.diskstorage.BackendTransaction

- All Implemented Interfaces:
    BaseTransaction, LoggableTransaction

      public class BackendTransaction
      extends Object
      implements LoggableTransaction

  Bundles all storage/index transactions and provides a proxy for some of their methods for convenience. Also increases robustness of read call by attempting read calls multiple times on failure.
  Author:
    Matthias Broecheler (me@matthiasb.com)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static StaticBuffer` | `EDGESTORE_MAX_KEY`
    `static StaticBuffer` | `EDGESTORE_MIN_KEY`
    `static int` | `MIN_TASKS_TO_PARALLELIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BackendTransaction(CacheTransaction storeTx, BaseTransactionConfig txConfig, StoreFeatures features, KCVSCache edgeStore, KCVSCache indexStore, KCVSCache txLogStore, Duration maxReadTime, Map<String,IndexTransaction> indexTx, Executor threadPool)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `acquireEdgeLock(StaticBuffer key, Entry entry)`
    `void` | `acquireEdgeLock(StaticBuffer key, StaticBuffer column)` Acquires a lock for the key-column pair on the edge store which ensures that nobody else can take a lock on that respective entry for the duration of this lock (but somebody could potentially still overwrite the key-value entry without taking a lock).
    `void` | `acquireIndexLock(StaticBuffer key, Entry entry)`
    `void` | `acquireIndexLock(StaticBuffer key, StaticBuffer column)` Acquires a lock for the key-column pair on the property index which ensures that nobody else can take a lock on that respective entry for the duration of this lock (but somebody could potentially still overwrite the key-value entry without taking a lock).
    `void` | `commit()` Commits the transaction and persists all modifications to the backend.
    `Map<String,Throwable>` | `commitIndexes()`
    `void` | `commitStorage()`
    `void` | `disableCache()`
    `KeyIterator` | `edgeStoreKeys(KeyRangeQuery range)`
    `KeyIterator` | `edgeStoreKeys(SliceQuery sliceQuery)`
    `Map<StaticBuffer,EntryList>` | `edgeStoreMultiQuery(List<StaticBuffer> keys, SliceQuery query)`
    `EntryList` | `edgeStoreQuery(KeySliceQuery query)`
    `void` | `enableCache()`
    `BaseTransactionConfig` | `getBaseTransactionConfig()`
    `IndexTransaction` | `getIndexTransaction(String index)`
    `StoreTransaction` | `getStoreTransaction()`
    `ExternalCachePersistor` | `getTxLogPersistor()`
    `boolean` | `hasAcquiredLock()`
    `EntryList` | `indexQuery(KeySliceQuery query)`
    `List<String>` | `indexQuery(String index, IndexQuery query)`
    `void` | `logMutations(DataOutput out)`
    `void` | `mutateEdges(StaticBuffer key, List<Entry> additions, List<Entry> deletions)` Applies the specified insertion and deletion mutations on the edge store to the provided key.
    `void` | `mutateIndex(StaticBuffer key, List<Entry> additions, List<Entry> deletions)` Applies the specified insertion and deletion mutations on the property index to the provided key.
    `Iterable<RawQuery.Result<String>>` | `rawQuery(String index, RawQuery query)`
    `void` | `rollback()` Rolls back all transactions and makes sure that this does not get cut short by exceptions.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MIN_TASKS_TO_PARALLELIZE

          public static final int MIN_TASKS_TO_PARALLELIZE

      See Also:
        Constant Field Values

    - #### EDGESTORE_MIN_KEY

          public static final StaticBuffer EDGESTORE_MIN_KEY

    - #### EDGESTORE_MAX_KEY

          public static final StaticBuffer EDGESTORE_MAX_KEY

  - ### Constructor Detail

    - #### BackendTransaction

          public BackendTransaction(CacheTransaction storeTx,
                            BaseTransactionConfig txConfig,
                            StoreFeatures features,
                            KCVSCache edgeStore,
                            KCVSCache indexStore,
                            KCVSCache txLogStore,
                            Duration maxReadTime,
                            Map<String,IndexTransaction> indexTx,
                            Executor threadPool)

  - ### Method Detail

    - #### hasAcquiredLock

          public boolean hasAcquiredLock()

    - #### getStoreTransaction

          public StoreTransaction getStoreTransaction()

    - #### getTxLogPersistor

          public ExternalCachePersistor getTxLogPersistor()

    - #### getBaseTransactionConfig

          public BaseTransactionConfig getBaseTransactionConfig()

    - #### getIndexTransaction

          public IndexTransaction getIndexTransaction(String index)

    - #### disableCache

          public void disableCache()

    - #### enableCache

          public void enableCache()

    - #### commitStorage

          public void commitStorage()
                             throws BackendException

      Throws:
        `BackendException`

    - #### commitIndexes

          public Map<String,Throwable> commitIndexes()

    - #### commit

          public void commit()
                      throws BackendException

      Description copied from interface: `BaseTransaction`
      Commits the transaction and persists all modifications to the backend. Call either this method or `BaseTransaction.rollback()` at most once per instance.
      Specified by:
        `commit` in interface `BaseTransaction`
      Throws:
        `BackendException`

    - #### rollback

          public void rollback()
                        throws BackendException

      Rolls back all transactions and makes sure that this does not get cut short by exceptions. If exceptions occur, the storage exception takes priority on re-throw.
      Specified by:
        `rollback` in interface `BaseTransaction`
      Throws:
        `BackendException`

    - #### logMutations

          public void logMutations(DataOutput out)

      Specified by:
        `logMutations` in interface `LoggableTransaction`

    - #### mutateEdges

          public void mutateEdges(StaticBuffer key,
                         List<Entry> additions,
                         List<Entry> deletions)
                           throws BackendException

      Applies the specified insertion and deletion mutations on the edge store to the provided key. Both, the list of additions or deletions, may be empty or NULL if there is nothing to be added and/or deleted.
      Parameters:
        `key` - Key
        `additions` - List of entries (column + value) to be added
        `deletions` - List of columns to be removed
      Throws:
        `BackendException`

    - #### mutateIndex

          public void mutateIndex(StaticBuffer key,
                         List<Entry> additions,
                         List<Entry> deletions)
                           throws BackendException

      Applies the specified insertion and deletion mutations on the property index to the provided key. Both, the list of additions or deletions, may be empty or NULL if there is nothing to be added and/or deleted.
      Parameters:
        `key` - Key
        `additions` - List of entries (column + value) to be added
        `deletions` - List of columns to be removed
      Throws:
        `BackendException`

    - #### acquireEdgeLock

          public void acquireEdgeLock(StaticBuffer key,
                             StaticBuffer column)
                               throws BackendException

      Acquires a lock for the key-column pair on the edge store which ensures that nobody else can take a lock on that respective entry for the duration of this lock (but somebody could potentially still overwrite the key-value entry without taking a lock). The expectedValue defines the value expected to match the value at the time the lock is acquired (or null if it is expected that the key-column pair does not exist).

      If this method is called multiple times with the same key-column pair in the same transaction, all but the first invocation are ignored.

      The lock has to be released when the transaction closes (commits or aborts).
      Parameters:
        `key` - Key on which to lock
        `column` - Column the column on which to lock
      Throws:
        `BackendException`

    - #### acquireEdgeLock

          public void acquireEdgeLock(StaticBuffer key,
                             Entry entry)
                               throws BackendException

      Throws:
        `BackendException`

    - #### acquireIndexLock

          public void acquireIndexLock(StaticBuffer key,
                              StaticBuffer column)
                                throws BackendException

      Acquires a lock for the key-column pair on the property index which ensures that nobody else can take a lock on that respective entry for the duration of this lock (but somebody could potentially still overwrite the key-value entry without taking a lock). The expectedValue defines the value expected to match the value at the time the lock is acquired (or null if it is expected that the key-column pair does not exist).

      If this method is called multiple times with the same key-column pair in the same transaction, all but the first invocation are ignored.

      The lock has to be released when the transaction closes (commits or aborts).
      Parameters:
        `key` - Key on which to lock
        `column` - Column the column on which to lock
        `expectedValue` - The expected value for the specified key-column pair on which to lock. Null if it is expected that the pair does not exist
      Throws:
        `BackendException`

    - #### acquireIndexLock

          public void acquireIndexLock(StaticBuffer key,
                              Entry entry)
                                throws BackendException

      Throws:
        `BackendException`

    - #### edgeStoreQuery

          public EntryList edgeStoreQuery(KeySliceQuery query)

    - #### edgeStoreMultiQuery

          public Map<StaticBuffer,EntryList> edgeStoreMultiQuery(List<StaticBuffer> keys,
                                                        SliceQuery query)

    - #### edgeStoreKeys

          public KeyIterator edgeStoreKeys(SliceQuery sliceQuery)

    - #### edgeStoreKeys

          public KeyIterator edgeStoreKeys(KeyRangeQuery range)

    - #### indexQuery

          public EntryList indexQuery(KeySliceQuery query)

    - #### indexQuery

          public List<String> indexQuery(String index,
                                IndexQuery query)

    - #### rawQuery

          public Iterable<RawQuery.Result<String>> rawQuery(String index,
                                                   RawQuery query)

Copyright © 2012–2014. All rights reserved.