org.apache.cassandra.service
Class StorageProxy

java.lang.Object
  extended by org.apache.cassandra.service.StorageProxy
All Implemented Interfaces:
StorageProxyMBean

public class StorageProxy
extends java.lang.Object
implements StorageProxyMBean


Field Summary
static StorageProxy instance
           
static java.lang.String UNREACHABLE
           
 
Method Summary
static void applyCounterMutationOnCoordinator(CounterMutation cm)
           
static void applyCounterMutationOnLeader(CounterMutation cm)
           
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.
 long getCounterWriteOperations()
           
 boolean getHintedHandoffEnabled()
           
 int getMaxHintWindow()
           
 long getRangeOperations()
           
static java.util.List<Row> getRangeSlice(RangeSliceCommand command, org.apache.cassandra.thrift.ConsistencyLevel consistency_level)
           
 long getReadOperations()
           
 long[] getRecentCounterWriteLatencyHistogramMicros()
           
 double getRecentCounterWriteLatencyMicros()
           
 long[] getRecentRangeLatencyHistogramMicros()
           
 double getRecentRangeLatencyMicros()
           
 long[] getRecentReadLatencyHistogramMicros()
           
 double getRecentReadLatencyMicros()
           
 long[] getRecentWriteLatencyHistogramMicros()
           
 double getRecentWriteLatencyMicros()
           
 long[] getTotalCounterWriteLatencyHistogramMicros()
           
 long getTotalCounterWriteLatencyMicros()
           
 long[] getTotalRangeLatencyHistogramMicros()
           
 long getTotalRangeLatencyMicros()
           
 long[] getTotalReadLatencyHistogramMicros()
           
 long getTotalReadLatencyMicros()
           
 long[] getTotalWriteLatencyHistogramMicros()
           
 long getTotalWriteLatencyMicros()
           
 long getWriteOperations()
           
static boolean isHintedHandoffEnabled()
           
static void mutate(java.util.List<RowMutation> mutations, org.apache.cassandra.thrift.ConsistencyLevel consistency_level)
          Use this method to have these RowMutations applied across all replicas.
static void mutateCounters(java.util.List<CounterMutation> mutations)
          The equivalent of mutate() for counters.
static java.util.List<Row> read(java.util.List<ReadCommand> commands, org.apache.cassandra.thrift.ConsistencyLevel consistency_level)
          Performs the actual reading of a row out of the StorageService, fetching a specific set of column names from a given column family.
static java.util.List<Row> scan(java.lang.String keyspace, java.lang.String column_family, org.apache.cassandra.thrift.IndexClause index_clause, org.apache.cassandra.thrift.SlicePredicate column_predicate, org.apache.cassandra.thrift.ConsistencyLevel consistency_level)
           
 void setHintedHandoffEnabled(boolean b)
           
 void setMaxHintWindow(int ms)
           
static boolean shouldHint(java.net.InetAddress ep)
           
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
static void write(java.util.List<? extends IMutation> mutations, org.apache.cassandra.thrift.ConsistencyLevel consistency_level, org.apache.cassandra.service.StorageProxy.WritePerformer performer, boolean updateStats)
          Perform the write of a batch of mutations given a WritePerformer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNREACHABLE

public static final java.lang.String UNREACHABLE
See Also:
Constant Field Values

instance

public static final StorageProxy instance
Method Detail

mutate

public static void mutate(java.util.List<RowMutation> mutations,
                          org.apache.cassandra.thrift.ConsistencyLevel consistency_level)
                   throws org.apache.cassandra.thrift.UnavailableException,
                          java.util.concurrent.TimeoutException
Use this method to have these RowMutations 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:
org.apache.cassandra.thrift.UnavailableException
java.util.concurrent.TimeoutException

write

public static void write(java.util.List<? extends IMutation> mutations,
                         org.apache.cassandra.thrift.ConsistencyLevel consistency_level,
                         org.apache.cassandra.service.StorageProxy.WritePerformer performer,
                         boolean updateStats)
                  throws org.apache.cassandra.thrift.UnavailableException,
                         java.util.concurrent.TimeoutException
Perform the write of a batch of mutations given a WritePerformer. For each mutation, 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:
mutations - the mutations 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).
updateStats - whether or not to update the writeStats. This must be true for standard writes but false for counter writes as the latency of the latter is tracked in mutateCounters() by counterWriteStats.
Throws:
org.apache.cassandra.thrift.UnavailableException
java.util.concurrent.TimeoutException

mutateCounters

public static void mutateCounters(java.util.List<CounterMutation> mutations)
                           throws org.apache.cassandra.thrift.UnavailableException,
                                  java.util.concurrent.TimeoutException
The equivalent of mutate() for counters. (Note that each CounterMutation ship the consistency level) 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 applyCounterMutationOnLeader 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:
org.apache.cassandra.thrift.UnavailableException
java.util.concurrent.TimeoutException

applyCounterMutationOnLeader

public static void applyCounterMutationOnLeader(CounterMutation cm)
                                         throws org.apache.cassandra.thrift.UnavailableException,
                                                java.util.concurrent.TimeoutException,
                                                java.io.IOException
Throws:
org.apache.cassandra.thrift.UnavailableException
java.util.concurrent.TimeoutException
java.io.IOException

applyCounterMutationOnCoordinator

public static void applyCounterMutationOnCoordinator(CounterMutation cm)
                                              throws org.apache.cassandra.thrift.UnavailableException,
                                                     java.util.concurrent.TimeoutException,
                                                     java.io.IOException
Throws:
org.apache.cassandra.thrift.UnavailableException
java.util.concurrent.TimeoutException
java.io.IOException

read

public static java.util.List<Row> read(java.util.List<ReadCommand> commands,
                                       org.apache.cassandra.thrift.ConsistencyLevel consistency_level)
                                throws java.io.IOException,
                                       org.apache.cassandra.thrift.UnavailableException,
                                       java.util.concurrent.TimeoutException,
                                       org.apache.cassandra.thrift.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:
java.io.IOException
org.apache.cassandra.thrift.UnavailableException
java.util.concurrent.TimeoutException
org.apache.cassandra.thrift.InvalidRequestException

getRangeSlice

public static java.util.List<Row> getRangeSlice(RangeSliceCommand command,
                                                org.apache.cassandra.thrift.ConsistencyLevel consistency_level)
                                         throws java.io.IOException,
                                                org.apache.cassandra.thrift.UnavailableException,
                                                java.util.concurrent.TimeoutException
Throws:
java.io.IOException
org.apache.cassandra.thrift.UnavailableException
java.util.concurrent.TimeoutException

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.


getReadOperations

public long getReadOperations()
Specified by:
getReadOperations in interface StorageProxyMBean

getTotalReadLatencyMicros

public long getTotalReadLatencyMicros()
Specified by:
getTotalReadLatencyMicros in interface StorageProxyMBean

getRecentReadLatencyMicros

public double getRecentReadLatencyMicros()
Specified by:
getRecentReadLatencyMicros in interface StorageProxyMBean

getTotalReadLatencyHistogramMicros

public long[] getTotalReadLatencyHistogramMicros()
Specified by:
getTotalReadLatencyHistogramMicros in interface StorageProxyMBean

getRecentReadLatencyHistogramMicros

public long[] getRecentReadLatencyHistogramMicros()
Specified by:
getRecentReadLatencyHistogramMicros in interface StorageProxyMBean

getRangeOperations

public long getRangeOperations()
Specified by:
getRangeOperations in interface StorageProxyMBean

getTotalRangeLatencyMicros

public long getTotalRangeLatencyMicros()
Specified by:
getTotalRangeLatencyMicros in interface StorageProxyMBean

getRecentRangeLatencyMicros

public double getRecentRangeLatencyMicros()
Specified by:
getRecentRangeLatencyMicros in interface StorageProxyMBean

getTotalRangeLatencyHistogramMicros

public long[] getTotalRangeLatencyHistogramMicros()
Specified by:
getTotalRangeLatencyHistogramMicros in interface StorageProxyMBean

getRecentRangeLatencyHistogramMicros

public long[] getRecentRangeLatencyHistogramMicros()
Specified by:
getRecentRangeLatencyHistogramMicros in interface StorageProxyMBean

getWriteOperations

public long getWriteOperations()
Specified by:
getWriteOperations in interface StorageProxyMBean

getTotalWriteLatencyMicros

public long getTotalWriteLatencyMicros()
Specified by:
getTotalWriteLatencyMicros in interface StorageProxyMBean

getRecentWriteLatencyMicros

public double getRecentWriteLatencyMicros()
Specified by:
getRecentWriteLatencyMicros in interface StorageProxyMBean

getTotalWriteLatencyHistogramMicros

public long[] getTotalWriteLatencyHistogramMicros()
Specified by:
getTotalWriteLatencyHistogramMicros in interface StorageProxyMBean

getRecentWriteLatencyHistogramMicros

public long[] getRecentWriteLatencyHistogramMicros()
Specified by:
getRecentWriteLatencyHistogramMicros in interface StorageProxyMBean

getCounterWriteOperations

public long getCounterWriteOperations()
Specified by:
getCounterWriteOperations in interface StorageProxyMBean

getTotalCounterWriteLatencyMicros

public long getTotalCounterWriteLatencyMicros()
Specified by:
getTotalCounterWriteLatencyMicros in interface StorageProxyMBean

getRecentCounterWriteLatencyMicros

public double getRecentCounterWriteLatencyMicros()
Specified by:
getRecentCounterWriteLatencyMicros in interface StorageProxyMBean

getTotalCounterWriteLatencyHistogramMicros

public long[] getTotalCounterWriteLatencyHistogramMicros()
Specified by:
getTotalCounterWriteLatencyHistogramMicros in interface StorageProxyMBean

getRecentCounterWriteLatencyHistogramMicros

public long[] getRecentCounterWriteLatencyHistogramMicros()
Specified by:
getRecentCounterWriteLatencyHistogramMicros in interface StorageProxyMBean

scan

public static java.util.List<Row> scan(java.lang.String keyspace,
                                       java.lang.String column_family,
                                       org.apache.cassandra.thrift.IndexClause index_clause,
                                       org.apache.cassandra.thrift.SlicePredicate column_predicate,
                                       org.apache.cassandra.thrift.ConsistencyLevel consistency_level)
                                throws java.io.IOException,
                                       java.util.concurrent.TimeoutException,
                                       org.apache.cassandra.thrift.UnavailableException
Throws:
java.io.IOException
java.util.concurrent.TimeoutException
org.apache.cassandra.thrift.UnavailableException

getHintedHandoffEnabled

public boolean getHintedHandoffEnabled()
Specified by:
getHintedHandoffEnabled in interface StorageProxyMBean

setHintedHandoffEnabled

public void setHintedHandoffEnabled(boolean b)
Specified by:
setHintedHandoffEnabled in interface StorageProxyMBean

isHintedHandoffEnabled

public static boolean isHintedHandoffEnabled()

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 org.apache.cassandra.thrift.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:
org.apache.cassandra.thrift.UnavailableException - If some of the hosts in the ring are down.
java.util.concurrent.TimeoutException
java.io.IOException


Copyright © 2011 The Apache Software Foundation