com.thinkaurelius.titan.diskstorage.common

## Class DistributedStoreManager

- java.lang.Object
- - com.thinkaurelius.titan.diskstorage.common.AbstractStoreManager
  - - com.thinkaurelius.titan.diskstorage.common.DistributedStoreManager

- All Implemented Interfaces:
    StoreManager

      public abstract class DistributedStoreManager
      extends AbstractStoreManager

  Abstract class that handles configuration options shared by all distributed storage backends
  Author:
    Matthias Broecheler (me@matthiasb.com)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DistributedStoreManager.Deployment`
    `class` | `DistributedStoreManager.MaskedTimestamp` Helper class to create the deletion and addition timestamps for a particular transaction.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Duration` | `connectionTimeoutMS`
    `protected String[]` | `hostnames`
    `protected int` | `pageSize`
    `protected String` | `password`
    `protected int` | `port`
    `protected TimestampProvider` | `times`
    `protected String` | `username`

    - ### Fields inherited from class com.thinkaurelius.titan.diskstorage.common.AbstractStoreManager

      `batchLoading, isReadOnly, storageConfig, transactional`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DistributedStoreManager(Configuration storageConfig, int portDefault)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract DistributedStoreManager.Deployment` | `getDeployment()` Returns the `DistributedStoreManager.Deployment` mode of this connection to the storage backend
    `int` | `getPageSize()` Returns the default configured page size for this storage backend.
    `protected String` | `getSingleHostname()` Returns a randomly chosen host name.
    `TimestampProvider` | `getTimestampProvider()`
    `boolean` | `hasAuthentication()` Whether authentication is enabled for this storage backend
    `protected void` | `sleepAfterWrite(StoreTransaction txh, DistributedStoreManager.MaskedTimestamp mustPass)` This method attempts to generate Rid in the following three ways, in order, returning the value produced by the first successful attempt in the sequence.
    `String` | `toString()`

    - ### Methods inherited from class com.thinkaurelius.titan.diskstorage.common.AbstractStoreManager

      `getMetaDataSchema, getStorageConfig`

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

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

    - ### Methods inherited from interface com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreManager

      `beginTransaction, clearStorage, close, getFeatures, getLocalKeyPartition, getName`

- - ### Field Detail

    - #### hostnames

          protected final String[] hostnames

    - #### port

          protected final int port

    - #### connectionTimeoutMS

          protected final Duration connectionTimeoutMS

    - #### pageSize

          protected final int pageSize

    - #### username

          protected final String username

    - #### password

          protected final String password

    - #### times

          protected final TimestampProvider times

  - ### Constructor Detail

    - #### DistributedStoreManager

          public DistributedStoreManager(Configuration storageConfig,
                                 int portDefault)

  - ### Method Detail

    - #### getSingleHostname

          protected String getSingleHostname()

      Returns a randomly chosen host name. This is used to pick one host when multiple are configured
      Returns:

    - #### hasAuthentication

          public boolean hasAuthentication()

      Whether authentication is enabled for this storage backend
      Returns:

    - #### getPageSize

          public int getPageSize()

      Returns the default configured page size for this storage backend. The page size is used to determine the number of records to request at a time when streaming result data.
      Returns:

    - #### getTimestampProvider

          public TimestampProvider getTimestampProvider()

    - #### getDeployment

          public abstract DistributedStoreManager.Deployment getDeployment()

      Returns the `DistributedStoreManager.Deployment` mode of this connection to the storage backend
      Returns:

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### sleepAfterWrite

          protected void sleepAfterWrite(StoreTransaction txh,
                             DistributedStoreManager.MaskedTimestamp mustPass)
                                  throws BackendException

      This method attempts to generate Rid in the following three ways, in order, returning the value produced by the first successful attempt in the sequence.

      1. If `config` contains `GraphDatabaseConfiguration#INSTANCE_RID_RAW_KEY`, then read it as a String value. Convert the String returned into a char[] and call `org.apache.commons.codec.binary.Hex#decodeHex on the char[]`. The byte[] returned by `decodeHex` is then returned as Rid.
      2. If `config` contains `GraphDatabaseConfiguration#INSTANCE_RID_SHORT_KEY`, then read it as a short value. Call `InetAddress.getLocalHost()`, and on its return value call `InetAddress.getAddress()` to retrieve the machine's IP address in byte[] form. The returned Rid is a byte[] containing the localhost address bytes in its lower indices and the short value in its penultimate and final indices.
      3. If both of the previous failed, then call `RuntimeMXBean.getName()` and then call `String#getBytes()` on the returned value. Return a Rid as described in the previous point, replacing the short value with the byte[] representing the JVM name.
      Parameters:
        `config` - commons config from which to read Rid-related keys
      Throws:
        `BackendException`

Copyright © 2012–2014. All rights reserved.