StorageProxy (apache-cassandra API)
Date: 2018-02-12

org.apache.cassandra.service

## Class StorageProxy

- java.lang.Object
- - org.apache.cassandra.service.StorageProxy

- All Implemented Interfaces:
    StorageProxyMBean

      public class StorageProxy
      extends java.lang.Object
      implements StorageProxyMBean

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `StorageProxy.WritePerformer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static StorageProxy` | `instance`
    `static java.lang.String` | `MBEAN_NAME`
    `static java.lang.String` | `UNREACHABLE`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static AbstractWriteResponseHandler<IMutation>` | `applyCounterMutationOnCoordinator(CounterMutation cm, java.lang.String localDataCenter)`
    `static AbstractWriteResponseHandler<IMutation>` | `applyCounterMutationOnLeader(CounterMutation cm, java.lang.String localDataCenter, java.lang.Runnable callback)`
    `static ColumnFamily` | `cas(java.lang.String keyspaceName, java.lang.String cfName, java.nio.ByteBuffer key, CASRequest request, ConsistencyLevel consistencyForPaxos, ConsistencyLevel consistencyForCommit, ClientState state)` Apply @param updates if and only if the current values in the row for @param key match the provided @param conditions.
    `static java.util.Map<java.lang.String,java.util.List<java.lang.String>>` | `describeSchemaVersions()` initiate a request/response session with each live node to check whether or not everybody is using the same migration id.
    `java.lang.Long` | `getCasContentionTimeout()`
    `java.lang.Long` | `getCounterWriteRpcTimeout()`
    `boolean` | `getHintedHandoffEnabled()`
    `java.util.Set<java.lang.String>` | `getHintedHandoffEnabledByDC()`
    `int` | `getHintsInProgress()`
    `static java.util.List<java.net.InetAddress>` | `getLiveSortedEndpoints(Keyspace keyspace, java.nio.ByteBuffer key)`
    `int` | `getMaxHintsInProgress()`
    `int` | `getMaxHintWindow()`
    `java.lang.Long` | `getNativeTransportMaxConcurrentConnections()`
    `java.lang.Long` | `getNativeTransportMaxConcurrentConnectionsPerIp()`
    `java.lang.Long` | `getRangeRpcTimeout()`
    `static java.util.List<Row>` | `getRangeSlice(AbstractRangeCommand command, ConsistencyLevel consistency_level)`
    `long` | `getReadRepairAttempted()`
    `long` | `getReadRepairRepairedBackground()`
    `long` | `getReadRepairRepairedBlocking()`
    `java.lang.Long` | `getReadRpcTimeout()`
    `java.lang.Long` | `getRpcTimeout()`
    `java.util.Map<java.lang.String,java.util.List<java.lang.String>>` | `getSchemaVersions()` Returns each live node's schema version
    `long` | `getTotalHints()`
    `java.lang.Long` | `getTruncateRpcTimeout()`
    `java.lang.Long` | `getWriteRpcTimeout()`
    `static void` | `mutate(java.util.Collection<? extends IMutation> mutations, ConsistencyLevel consistency_level)` Use this method to have these Mutations applied across all replicas.
    `static void` | `mutateAtomically(java.util.Collection<Mutation> mutations, ConsistencyLevel consistency_level)` See mutate.
    `static AbstractWriteResponseHandler<IMutation>` | `mutateCounter(CounterMutation cm, java.lang.String localDataCenter)` Handle counter mutation on the coordinator host.
    `static void` | `mutateWithTriggers(java.util.Collection<? extends IMutation> mutations, ConsistencyLevel consistencyLevel, boolean mutateAtomically)`
    `static AbstractWriteResponseHandler<IMutation>` | `performWrite(IMutation mutation, ConsistencyLevel consistency_level, java.lang.String localDataCenter, StorageProxy.WritePerformer performer, java.lang.Runnable callback, WriteType writeType)` Perform the write of a mutation given a WritePerformer.
    `static java.util.List<Row>` | `read(java.util.List<ReadCommand> commands, ConsistencyLevel consistencyLevel)`
    `static java.util.List<Row>` | `read(java.util.List<ReadCommand> commands, ConsistencyLevel consistencyLevel, ClientState state)` Performs the actual reading of a row out of the StorageService, fetching a specific set of column names from a given column family.
    `void` | `reloadTriggerClasses()`
    `static void` | `sendToHintedEndpoints(Mutation mutation, java.lang.Iterable<java.net.InetAddress> targets, AbstractWriteResponseHandler<IMutation> responseHandler, java.lang.String localDataCenter)` Send the mutations to the right targets, write it locally if it corresponds or writes a hint when the node is not available.
    `void` | `setCasContentionTimeout(java.lang.Long timeoutInMillis)`
    `void` | `setCounterWriteRpcTimeout(java.lang.Long timeoutInMillis)`
    `void` | `setHintedHandoffEnabled(boolean b)`
    `void` | `setHintedHandoffEnabledByDCList(java.lang.String dcNames)`
    `void` | `setMaxHintsInProgress(int qs)`
    `void` | `setMaxHintWindow(int ms)`
    `void` | `setNativeTransportMaxConcurrentConnections(java.lang.Long nativeTransportMaxConcurrentConnections)`
    `void` | `setNativeTransportMaxConcurrentConnectionsPerIp(java.lang.Long nativeTransportMaxConcurrentConnections)`
    `void` | `setRangeRpcTimeout(java.lang.Long timeoutInMillis)`
    `void` | `setReadRpcTimeout(java.lang.Long timeoutInMillis)`
    `void` | `setRpcTimeout(java.lang.Long timeoutInMillis)`
    `void` | `setTruncateRpcTimeout(java.lang.Long timeoutInMillis)`
    `void` | `setWriteRpcTimeout(java.lang.Long timeoutInMillis)`
    `static boolean` | `shouldHint(java.net.InetAddress ep)`
    `static java.util.concurrent.Future<java.lang.Void>` | `submitHint(Mutation mutation, java.net.InetAddress target, AbstractWriteResponseHandler<IMutation> responseHandler)`
    `static void` | `truncateBlocking(java.lang.String keyspace, java.lang.String cfname)` Performs the truncate operatoin, which effectively deletes all data from the column family cfname
    `void` | `verifyNoHintsInProgress()`
    `static void` | `writeHintForMutation(Mutation mutation, long now, int ttl, java.net.InetAddress target)`

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

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

- - ### Field Detail

    - #### MBEAN_NAME

          public static final java.lang.String MBEAN_NAME

      See Also:
        Constant Field Values

    - #### UNREACHABLE

          public static final java.lang.String UNREACHABLE

      See Also:
        Constant Field Values

    - #### instance

          public static final StorageProxy instance

  - ### Method Detail

    - #### cas

          public static ColumnFamily cas(java.lang.String keyspaceName,
                                         java.lang.String cfName,
                                         java.nio.ByteBuffer key,
                                         CASRequest request,
                                         ConsistencyLevel consistencyForPaxos,
                                         ConsistencyLevel consistencyForCommit,
                                         ClientState state)
                                  throws UnavailableException,
                                         IsBootstrappingException,
                                         RequestFailureException,
                                         RequestTimeoutException,
                                         InvalidRequestException

      Apply @param updates if and only if the current values in the row for @param key match the provided @param conditions. The algorithm is "raw" Paxos: that is, Paxos minus leader election -- any node in the cluster may propose changes for any row, which (that is, the row) is the unit of values being proposed, not single columns. The Paxos cohort is only the replicas for the given key, not the entire cluster. So we expect performance to be reasonable, but CAS is still intended to be used "when you really need it," not for all your updates. There are three phases to Paxos: 1. Prepare: the coordinator generates a ballot (timeUUID in our case) and asks replicas to (a) promise not to accept updates from older ballots and (b) tell us about the most recent update it has already accepted. 2. Accept: if a majority of replicas reply, the coordinator asks replicas to accept the value of the highest proposal ballot it heard about, or a new value if no in-progress proposals were reported. 3. Commit (Learn): if a majority of replicas acknowledge the accept request, we can commit the new value. Commit procedure is not covered in "Paxos Made Simple," and only briefly mentioned in "Paxos Made Live," so here is our approach: 3a. The coordinator sends a commit message to all replicas with the ballot and value. 3b. Because of 1-2, this will be the highest-seen commit ballot. The replicas will note that, and send it with subsequent promise replies. This allows us to discard acceptance records for successfully committed replicas, without allowing incomplete proposals to commit erroneously later on. Note that since we are performing a CAS rather than a simple update, we perform a read (of committed values) between the prepare and accept phases. This gives us a slightly longer window for another coordinator to come along and trump our own promise with a newer one but is otherwise safe.
      Parameters:
        `keyspaceName` - the keyspace for the CAS
        `cfName` - the column family for the CAS
        `key` - the row key for the row to CAS
        `request` - the conditions for the CAS to apply as well as the update to perform if the conditions hold.
        `consistencyForPaxos` - the consistency for the paxos prepare and propose round. This can only be either SERIAL or LOCAL_SERIAL.
        `consistencyForCommit` - the consistency for write done during the commit phase. This can be anything, except SERIAL or LOCAL_SERIAL.
      Returns:
        null if the operation succeeds in updating the row, or the current values corresponding to conditions. (since, if the CAS doesn't succeed, it means the current value do not match the conditions).
      Throws:
        `UnavailableException`
        `IsBootstrappingException`
        `RequestFailureException`
        `RequestTimeoutException`
        `InvalidRequestException`

    - #### mutate

          public static void mutate(java.util.Collection<? extends IMutation> mutations,
                                    ConsistencyLevel consistency_level)
                             throws UnavailableException,
                                    OverloadedException,
                                    WriteTimeoutException,
                                    WriteFailureException

      Use this method to have these Mutations applied across all replicas. This method will take care of the possibility of a replica being down and hint the data across to some other replica.
      Parameters:
        `mutations` - the mutations to be applied across the replicas
        `consistency_level` - the consistency level for the operation
      Throws:
        `UnavailableException`
        `OverloadedException`
        `WriteTimeoutException`
        `WriteFailureException`

    - #### mutateWithTriggers

          public static void mutateWithTriggers(java.util.Collection<? extends IMutation> mutations,
                                                ConsistencyLevel consistencyLevel,
                                                boolean mutateAtomically)
                                         throws WriteTimeoutException,
                                                WriteFailureException,
                                                UnavailableException,
                                                OverloadedException,
                                                InvalidRequestException

      Throws:
        `WriteTimeoutException`
        `WriteFailureException`
        `UnavailableException`
        `OverloadedException`
        `InvalidRequestException`

    - #### mutateAtomically

          public static void mutateAtomically(java.util.Collection<Mutation> mutations,
                                              ConsistencyLevel consistency_level)
                                       throws UnavailableException,
                                              OverloadedException,
                                              WriteTimeoutException

      See mutate. Adds additional steps before and after writing a batch. Before writing the batch (but after doing availability check against the FD for the row replicas): write the entire batch to a batchlog elsewhere in the cluster. After: remove the batchlog entry (after writing hints for the batch rows, if necessary).
      Parameters:
        `mutations` - the Mutations to be applied across the replicas
        `consistency_level` - the consistency level for the operation
      Throws:
        `UnavailableException`
        `OverloadedException`
        `WriteTimeoutException`

    - #### performWrite

          public static AbstractWriteResponseHandler<IMutation> performWrite(IMutation mutation,
                                                                             ConsistencyLevel consistency_level,
                                                                             java.lang.String localDataCenter,
                                                                             StorageProxy.WritePerformer performer,
                                                                             java.lang.Runnable callback,
                                                                             WriteType writeType)
                                                                      throws UnavailableException,
                                                                             OverloadedException

      Perform the write of a mutation given a WritePerformer. Gather the list of write endpoints, apply locally and/or forward the mutation to said write endpoint (deletaged to the actual WritePerformer) and wait for the responses based on consistency level.
      Parameters:
        `mutation` - the mutation to be applied
        `consistency_level` - the consistency level for the write operation
        `performer` - the WritePerformer in charge of appliying the mutation given the list of write endpoints (either standardWritePerformer for standard writes or counterWritePerformer for counter writes).
        `callback` - an optional callback to be run if and when the write is successful.
      Throws:
        `UnavailableException`
        `OverloadedException`

    - #### sendToHintedEndpoints

          public static void sendToHintedEndpoints(Mutation mutation,
                                                   java.lang.Iterable<java.net.InetAddress> targets,
                                                   AbstractWriteResponseHandler<IMutation> responseHandler,
                                                   java.lang.String localDataCenter)
                                            throws OverloadedException

      Send the mutations to the right targets, write it locally if it corresponds or writes a hint when the node is not available. Note about hints:

           | Hinted Handoff | Consist. Level |
           | on             |       >=1      | --> wait for hints. We DO NOT notify the handler with handler.response() for hints;
           | on             |       ANY      | --> wait for hints. Responses count towards consistency.
           | off            |       >=1      | --> DO NOT fire hints. And DO NOT wait for them to complete.
           | off            |       ANY      | --> DO NOT fire hints. And DO NOT wait for them to complete.

      Throws:
        `OverloadedException` - if the hints cannot be written/enqueued

    - #### submitHint

          public static java.util.concurrent.Future<java.lang.Void> submitHint(Mutation mutation,
                                                                               java.net.InetAddress target,
                                                                               AbstractWriteResponseHandler<IMutation> responseHandler)

    - #### writeHintForMutation

          public static void writeHintForMutation(Mutation mutation,
                                                  long now,
                                                  int ttl,
                                                  java.net.InetAddress target)

      Parameters:
        `now` - current time in milliseconds - relevant for hint replay handling of truncated CFs

    - #### mutateCounter

          public static AbstractWriteResponseHandler<IMutation> mutateCounter(CounterMutation cm,
                                                                              java.lang.String localDataCenter)
                                                                       throws UnavailableException,
                                                                              OverloadedException

      Handle counter mutation on the coordinator host. A counter mutation needs to first be applied to a replica (that we'll call the leader for the mutation) before being replicated to the other endpoint. To achieve so, there is two case: 1) the coordinator host is a replica: we proceed to applying the update locally and replicate throug applyCounterMutationOnCoordinator 2) the coordinator is not a replica: we forward the (counter)mutation to a chosen replica (that will proceed through applyCounterMutationOnLeader upon receive) and wait for its acknowledgment. Implementation note: We check if we can fulfill the CL on the coordinator host even if he is not a replica to allow quicker response and because the WriteResponseHandlers don't make it easy to send back an error. We also always gather the write latencies at the coordinator node to make gathering point similar to the case of standard writes.
      Throws:
        `UnavailableException`
        `OverloadedException`

    - #### applyCounterMutationOnLeader

          public static AbstractWriteResponseHandler<IMutation> applyCounterMutationOnLeader(CounterMutation cm,
                                                                                             java.lang.String localDataCenter,
                                                                                             java.lang.Runnable callback)
                                                                                      throws UnavailableException,
                                                                                             OverloadedException

      Throws:
        `UnavailableException`
        `OverloadedException`

    - #### applyCounterMutationOnCoordinator

          public static AbstractWriteResponseHandler<IMutation> applyCounterMutationOnCoordinator(CounterMutation cm,
                                                                                                  java.lang.String localDataCenter)
                                                                                           throws UnavailableException,
                                                                                                  OverloadedException

      Throws:
        `UnavailableException`
        `OverloadedException`

    - #### read

          public static java.util.List<Row> read(java.util.List<ReadCommand> commands,
                                                 ConsistencyLevel consistencyLevel)
                                          throws UnavailableException,
                                                 IsBootstrappingException,
                                                 ReadFailureException,
                                                 ReadTimeoutException,
                                                 InvalidRequestException

      Throws:
        `UnavailableException`
        `IsBootstrappingException`
        `ReadFailureException`
        `ReadTimeoutException`
        `InvalidRequestException`

    - #### read

          public static java.util.List<Row> read(java.util.List<ReadCommand> commands,
                                                 ConsistencyLevel consistencyLevel,
                                                 ClientState state)
                                          throws UnavailableException,
                                                 IsBootstrappingException,
                                                 ReadFailureException,
                                                 ReadTimeoutException,
                                                 InvalidRequestException

      Performs the actual reading of a row out of the StorageService, fetching a specific set of column names from a given column family.
      Throws:
        `UnavailableException`
        `IsBootstrappingException`
        `ReadFailureException`
        `ReadTimeoutException`
        `InvalidRequestException`

    - #### getLiveSortedEndpoints

          public static java.util.List<java.net.InetAddress> getLiveSortedEndpoints(Keyspace keyspace,
                                                                                    java.nio.ByteBuffer key)

    - #### getRangeSlice

          public static java.util.List<Row> getRangeSlice(AbstractRangeCommand command,
                                                          ConsistencyLevel consistency_level)
                                                   throws UnavailableException,
                                                          ReadFailureException,
                                                          ReadTimeoutException

      Throws:
        `UnavailableException`
        `ReadFailureException`
        `ReadTimeoutException`

    - #### getSchemaVersions

          public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getSchemaVersions()

      Description copied from interface: `StorageProxyMBean`
      Returns each live node's schema version
      Specified by:
        `getSchemaVersions` in interface `StorageProxyMBean`

    - #### describeSchemaVersions

          public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> describeSchemaVersions()

      initiate a request/response session with each live node to check whether or not everybody is using the same migration id. This is useful for determining if a schema change has propagated through the cluster. Disagreement is assumed if any node fails to respond.

    - #### getHintedHandoffEnabled

          public boolean getHintedHandoffEnabled()

      Specified by:
        `getHintedHandoffEnabled` in interface `StorageProxyMBean`

    - #### getHintedHandoffEnabledByDC

          public java.util.Set<java.lang.String> getHintedHandoffEnabledByDC()

      Specified by:
        `getHintedHandoffEnabledByDC` in interface `StorageProxyMBean`

    - #### setHintedHandoffEnabled

          public void setHintedHandoffEnabled(boolean b)

      Specified by:
        `setHintedHandoffEnabled` in interface `StorageProxyMBean`

    - #### setHintedHandoffEnabledByDCList

          public void setHintedHandoffEnabledByDCList(java.lang.String dcNames)

      Specified by:
        `setHintedHandoffEnabledByDCList` in interface `StorageProxyMBean`

    - #### getMaxHintWindow

          public int getMaxHintWindow()

      Specified by:
        `getMaxHintWindow` in interface `StorageProxyMBean`

    - #### setMaxHintWindow

          public void setMaxHintWindow(int ms)

      Specified by:
        `setMaxHintWindow` in interface `StorageProxyMBean`

    - #### shouldHint

          public static boolean shouldHint(java.net.InetAddress ep)

    - #### truncateBlocking

          public static void truncateBlocking(java.lang.String keyspace,
                                              java.lang.String cfname)
                                       throws UnavailableException,
                                              java.util.concurrent.TimeoutException,
                                              java.io.IOException

      Performs the truncate operatoin, which effectively deletes all data from the column family cfname
      Parameters:
        `keyspace` -
        `cfname` -
      Throws:
        `UnavailableException` - If some of the hosts in the ring are down.
        `java.util.concurrent.TimeoutException`
        `java.io.IOException`

    - #### getTotalHints

          public long getTotalHints()

      Specified by:
        `getTotalHints` in interface `StorageProxyMBean`

    - #### getMaxHintsInProgress

          public int getMaxHintsInProgress()

      Specified by:
        `getMaxHintsInProgress` in interface `StorageProxyMBean`

    - #### setMaxHintsInProgress

          public void setMaxHintsInProgress(int qs)

      Specified by:
        `setMaxHintsInProgress` in interface `StorageProxyMBean`

    - #### getHintsInProgress

          public int getHintsInProgress()

      Specified by:
        `getHintsInProgress` in interface `StorageProxyMBean`

    - #### verifyNoHintsInProgress

          public void verifyNoHintsInProgress()

    - #### getRpcTimeout

          public java.lang.Long getRpcTimeout()

      Specified by:
        `getRpcTimeout` in interface `StorageProxyMBean`

    - #### setRpcTimeout

          public void setRpcTimeout(java.lang.Long timeoutInMillis)

      Specified by:
        `setRpcTimeout` in interface `StorageProxyMBean`

    - #### getReadRpcTimeout

          public java.lang.Long getReadRpcTimeout()

      Specified by:
        `getReadRpcTimeout` in interface `StorageProxyMBean`

    - #### setReadRpcTimeout

          public void setReadRpcTimeout(java.lang.Long timeoutInMillis)

      Specified by:
        `setReadRpcTimeout` in interface `StorageProxyMBean`

    - #### getWriteRpcTimeout

          public java.lang.Long getWriteRpcTimeout()

      Specified by:
        `getWriteRpcTimeout` in interface `StorageProxyMBean`

    - #### setWriteRpcTimeout

          public void setWriteRpcTimeout(java.lang.Long timeoutInMillis)

      Specified by:
        `setWriteRpcTimeout` in interface `StorageProxyMBean`

    - #### getCounterWriteRpcTimeout

          public java.lang.Long getCounterWriteRpcTimeout()

      Specified by:
        `getCounterWriteRpcTimeout` in interface `StorageProxyMBean`

    - #### setCounterWriteRpcTimeout

          public void setCounterWriteRpcTimeout(java.lang.Long timeoutInMillis)

      Specified by:
        `setCounterWriteRpcTimeout` in interface `StorageProxyMBean`

    - #### getCasContentionTimeout

          public java.lang.Long getCasContentionTimeout()

      Specified by:
        `getCasContentionTimeout` in interface `StorageProxyMBean`

    - #### setCasContentionTimeout

          public void setCasContentionTimeout(java.lang.Long timeoutInMillis)

      Specified by:
        `setCasContentionTimeout` in interface `StorageProxyMBean`

    - #### getRangeRpcTimeout

          public java.lang.Long getRangeRpcTimeout()

      Specified by:
        `getRangeRpcTimeout` in interface `StorageProxyMBean`

    - #### setRangeRpcTimeout

          public void setRangeRpcTimeout(java.lang.Long timeoutInMillis)

      Specified by:
        `setRangeRpcTimeout` in interface `StorageProxyMBean`

    - #### getTruncateRpcTimeout

          public java.lang.Long getTruncateRpcTimeout()

      Specified by:
        `getTruncateRpcTimeout` in interface `StorageProxyMBean`

    - #### setTruncateRpcTimeout

          public void setTruncateRpcTimeout(java.lang.Long timeoutInMillis)

      Specified by:
        `setTruncateRpcTimeout` in interface `StorageProxyMBean`

    - #### getNativeTransportMaxConcurrentConnections

          public java.lang.Long getNativeTransportMaxConcurrentConnections()

      Specified by:
        `getNativeTransportMaxConcurrentConnections` in interface `StorageProxyMBean`

    - #### setNativeTransportMaxConcurrentConnections

          public void setNativeTransportMaxConcurrentConnections(java.lang.Long nativeTransportMaxConcurrentConnections)

      Specified by:
        `setNativeTransportMaxConcurrentConnections` in interface `StorageProxyMBean`

    - #### getNativeTransportMaxConcurrentConnectionsPerIp

          public java.lang.Long getNativeTransportMaxConcurrentConnectionsPerIp()

    - #### setNativeTransportMaxConcurrentConnectionsPerIp

          public void setNativeTransportMaxConcurrentConnectionsPerIp(java.lang.Long nativeTransportMaxConcurrentConnections)

    - #### reloadTriggerClasses

          public void reloadTriggerClasses()

      Specified by:
        `reloadTriggerClasses` in interface `StorageProxyMBean`

    - #### getReadRepairAttempted

          public long getReadRepairAttempted()

      Specified by:
        `getReadRepairAttempted` in interface `StorageProxyMBean`

    - #### getReadRepairRepairedBlocking

          public long getReadRepairRepairedBlocking()

      Specified by:
        `getReadRepairRepairedBlocking` in interface `StorageProxyMBean`

    - #### getReadRepairRepairedBackground

          public long getReadRepairRepairedBackground()

      Specified by:
        `getReadRepairRepairedBackground` in interface `StorageProxyMBean`

Copyright © 2018 The Apache Software Foundation