org.apache.cassandra.service
Class StorageService

java.lang.Object
  extended by org.apache.cassandra.service.StorageService
All Implemented Interfaces:
IEndpointStateChangeSubscriber, StorageServiceMBean

public class StorageService
extends java.lang.Object
implements IEndpointStateChangeSubscriber, StorageServiceMBean

This abstraction contains the token/identifier of this node on the identifier space. This token gets gossiped around. This class will also maintain histograms of the load information of other nodes in the cluster.


Nested Class Summary
static class StorageService.Verb
           
 
Field Summary
static StorageService instance
           
static DebuggableScheduledThreadPoolExecutor optionalTasks
          tasks that do not need to be waited for on shutdown/drain
static int RING_DELAY
           
static DebuggableScheduledThreadPoolExecutor scheduledTasks
          This pool is used for periodic short (sub-second) tasks.
static DebuggableScheduledThreadPoolExecutor tasks
          This pool is used by tasks that can have longer execution times, and usually are non periodic.
 VersionedValue.VersionedValueFactory valueFactory
           
static StorageService.Verb[] VERBS
           
static java.util.EnumMap<StorageService.Verb,Stage> verbStages
           
 
Constructor Summary
StorageService()
           
 
Method Summary
protected  void addExpireTimeIfFound(java.net.InetAddress endpoint, long expireTime)
           
 void bulkLoad(java.lang.String directory)
           
static void calculatePendingRanges(AbstractReplicationStrategy strategy, java.lang.String table)
           
 Pair<java.util.Set<Range<Token>>,java.util.Set<Range<Token>>> calculateStreamAndFetchRanges(java.util.Collection<Range<Token>> current, java.util.Collection<Range<Token>> updated)
          Calculate pair of ranges to stream/fetch for given two range collections (current ranges for table and ranges after move to new token)
 void clearSnapshot(java.lang.String tag, java.lang.String... tableNames)
          Remove the snapshot with the given name from the given tables.
 void confirmReplication(java.net.InetAddress node)
           
 void decommission()
          transfer this node's data to other machines and remove it from service.
 void deliverHints(java.lang.String host)
           
 java.util.List<org.apache.cassandra.thrift.TokenRange> describeRing(java.lang.String keyspace)
          The TokenRange for a given keyspace.
 java.util.List<java.lang.String> describeRingJMX(java.lang.String keyspace)
          The same as describeRing(String) but converts TokenRange to the String for JMX compatibility
 void drain()
          Shuts node off to writes, empties memtables and the commit log.
 java.util.Map<java.lang.String,java.lang.Float> effectiveOwnership(java.lang.String keyspace)
          Effective ownership is % of the data each node owns given the keyspace we calculate the percentage using replication factor.
protected  long extractExpireTime(java.lang.String[] pieces)
           
 void finishBootstrapping()
           
 void flushLargestMemtables()
          Flushes the two largest memtables by ops and by throughput
 void forceRemoveCompletion()
          Force a remove operation to complete.
 void forceTableCleanup(java.lang.String tableName, java.lang.String... columnFamilies)
          Trigger a cleanup of keys on a single keyspace
 void forceTableCompaction(java.lang.String tableName, java.lang.String... columnFamilies)
          Forces major compaction of a single keyspace
 void forceTableFlush(java.lang.String tableName, java.lang.String... columnFamilies)
          Flush all memtables for a table and column families.
 AntiEntropyService.RepairFuture forceTableRepair(Range<Token> range, java.lang.String tableName, boolean isSequential, java.lang.String... columnFamilies)
           
 void forceTableRepair(java.lang.String tableName, boolean isSequential, java.lang.String... columnFamilies)
          Trigger proactive repair for a table and column families.
 void forceTableRepairPrimaryRange(java.lang.String tableName, boolean isSequential, java.lang.String... columnFamilies)
          Triggers proactive repair but only for the node primary range.
 void forceTableRepairRange(java.lang.String beginToken, java.lang.String endToken, java.lang.String tableName, boolean isSequential, java.lang.String... columnFamilies)
          Perform repair of a specific range.
 void forceTerminateAllRepairSessions()
           
 java.lang.String[] getAllDataFileLocations()
          Get the list of all data file locations from conf
 java.util.List<Range<Token>> getAllRanges(java.util.List<Token> sortedTokens)
          Get all ranges that span the ring given a set of tokens.
 Token getBootstrapToken()
          return a token to which if a node bootstraps it will get about 1/2 of this node's range
 java.lang.String getCommitLogLocation()
          Get location of the commit log
 int getCompactionThroughputMbPerSec()
           
 int getCurrentGenerationNumber()
          Return the generation value for this node.
 java.lang.String getDrainProgress()
          get the progress of a drain operation
 int getExceptionCount()
           
 java.util.List<java.lang.String> getJoiningNodes()
          Retrieve the list of nodes currently bootstrapping into the ring.
 java.util.List<java.lang.String> getKeyspaces()
           
 java.util.List<java.lang.String> getLeavingNodes()
          Retrieve the list of nodes currently leaving the ring.
 java.util.List<java.net.InetAddress> getLiveNaturalEndpoints(java.lang.String table, java.nio.ByteBuffer key)
          This method attempts to return N endpoints that are responsible for storing the specified key i.e for replication.
 java.util.List<java.net.InetAddress> getLiveNaturalEndpoints(java.lang.String table, RingPosition pos)
           
 java.util.List<java.lang.String> getLiveNodes()
          Retrieve the list of live nodes in the cluster, where "liveness" is determined by the failure detector of the node being queried.
 double getLoad()
          raw load value
 java.util.Map<java.lang.String,java.lang.String> getLoadMap()
          Human-readable load value.
 java.lang.String getLoadString()
          Human-readable load value
 Range<Token> getLocalPrimaryRange()
           
 java.util.Collection<Range<Token>> getLocalRanges(java.lang.String table)
           
 Token getLocalToken()
           
 java.util.List<java.lang.String> getMovingNodes()
          Retrieve the list of nodes currently moving in the ring.
 java.util.List<java.net.InetAddress> getNaturalEndpoints(java.lang.String table, java.nio.ByteBuffer key)
           
 java.util.List<java.net.InetAddress> getNaturalEndpoints(java.lang.String table, RingPosition pos)
          This method returns the N endpoints that are responsible for storing the specified key i.e for replication.
 java.util.List<java.net.InetAddress> getNaturalEndpoints(java.lang.String table, java.lang.String cf, java.lang.String key)
          This method returns the N endpoints that are responsible for storing the specified key i.e for replication.
 java.lang.String getOperationMode()
          get the operational mode (leaving, joining, normal, decommissioned, client)
 java.util.Map<java.lang.String,java.lang.Float> getOwnership()
          given a list of tokens (representing the nodes in the cluster), returns a mapping from "token -> %age of cluster owned by that token"
static IPartitioner getPartitioner()
           
 java.util.Map<java.util.List<java.lang.String>,java.util.List<java.lang.String>> getPendingRangeToEndpointMap(java.lang.String keyspace)
          Retrieve a map of pending ranges to endpoints that describe the ring topology
 java.util.List<java.lang.String> getPrimaryRange()
          Returns the local node's primary range.
 Range<Token> getPrimaryRangeForEndpoint(java.net.InetAddress ep)
          Get the primary range for the specified endpoint.
 java.util.List<java.lang.String> getRangeKeySample()
          #Return a List of Tokens representing a sample of keys across all ColumnFamilyStores
 java.util.Map<Range<Token>,java.util.List<java.net.InetAddress>> getRangeToAddressMap(java.lang.String keyspace)
           
 java.util.Map<java.util.List<java.lang.String>,java.util.List<java.lang.String>> getRangeToEndpointMap(java.lang.String keyspace)
          for a keyspace, return the ranges and corresponding listen addresses.
 java.util.Map<java.util.List<java.lang.String>,java.util.List<java.lang.String>> getRangeToRpcaddressMap(java.lang.String keyspace)
          for a keyspace, return the ranges and corresponding RPC addresses for a given keyspace.
 java.lang.String getReleaseVersion()
          Fetch a string representation of the Cassandra version.
 java.lang.String getRemovalStatus()
          Get the status of a token removal.
 java.lang.String getRpcaddress(java.net.InetAddress endpoint)
          Return the rpc address associated with an endpoint as a string.
 java.lang.String getSavedCachesLocation()
          Get location of the saved caches dir
 java.lang.String getSchemaVersion()
          Fetch a string representation of the current Schema version.
 java.util.List<Token> getSplits(java.lang.String table, java.lang.String cfName, Range<Token> range, int keysPerSplit)
           
 int getStreamThroughputMbPerSec()
           
 java.net.InetAddress getSuccessor(java.net.InetAddress ep)
           
 java.lang.String getToken()
          Fetch a string representation of the token.
 TokenMetadata getTokenMetadata()
           
 java.util.Map<java.lang.String,java.lang.String> getTokenToEndpointMap()
          Retrieve a map of tokens to endpoints, including the bootstrapping ones.
 java.util.List<java.lang.String> getUnreachableNodes()
          Retrieve the list of unreachable nodes in the cluster, as determined by this node's failure detector.
 java.lang.Iterable<ColumnFamilyStore> getValidColumnFamilies(java.lang.String tableName, java.lang.String... cfNames)
           
 void initClient()
           
 void initClient(int delay)
           
 void initServer()
           
 void initServer(int delay)
           
 boolean isBootstrapMode()
           
 boolean isClientMode()
           
 boolean isIncrementalBackupsEnabled()
           
 boolean isInitialized()
           
 boolean isJoined()
           
 boolean isRPCServerRunning()
           
 void joinRing()
           
 void loadNewSSTables(java.lang.String ksName, java.lang.String cfName)
          #Load new SSTables to the given keyspace/columnFamily
 void move(java.lang.String newToken)
           
 void onAlive(java.net.InetAddress endpoint, EndpointState state)
           
 void onChange(java.net.InetAddress endpoint, ApplicationState state, VersionedValue value)
           
 void onDead(java.net.InetAddress endpoint, EndpointState state)
           
 void onJoin(java.net.InetAddress endpoint, EndpointState epState)
          Use to inform interested parties about the change in the state for specified endpoint
 void onRemove(java.net.InetAddress endpoint)
           
 void onRestart(java.net.InetAddress endpoint, EndpointState state)
          Called whenever a node is restarted.
 void rebuild(java.lang.String sourceDc)
          Initiate a process of streaming data for which we are responsible from other nodes.
 void rebuildSecondaryIndex(java.lang.String ksName, java.lang.String cfName, java.lang.String... idxNames)
          rebuild the specified indexes
 void registerDaemon(CassandraDaemon daemon)
           
 void removeToken(java.lang.String tokenString)
          Remove a node that has died, attempting to restore the replica count.
 void requestGC()
           
 void rescheduleFailedDeletions()
           
 void resetLocalSchema()
           
 void scrub(java.lang.String tableName, java.lang.String... columnFamilies)
          Scrub (deserialize + reserialize at the latest version, skipping bad rows if any) the given keyspace.
 void setCompactionThroughputMbPerSec(int value)
           
 void setIncrementalBackupsEnabled(boolean value)
           
 void setLog4jLevel(java.lang.String classQualifier, java.lang.String rawLevel)
          set the logging level at runtime
 void setStreamThroughputMbPerSec(int value)
           
 void setToken(Token token)
          This method updates the local token on disk
 void startGossiping()
           
 void startRPCServer()
           
 void stopClient()
           
 void stopGossiping()
           
 void stopRPCServer()
           
 void takeColumnFamilySnapshot(java.lang.String tableName, java.lang.String columnFamilyName, java.lang.String tag)
          Takes the snapshot of a specific column family.
 void takeSnapshot(java.lang.String tag, java.lang.String... tableNames)
          Takes the snapshot for the given tables.
 void truncate(java.lang.String keyspace, java.lang.String columnFamily)
          Truncates (deletes) the given columnFamily from the provided keyspace.
 void updateSnitch(java.lang.String epSnitchClassName, java.lang.Boolean dynamic, java.lang.Integer dynamicUpdateInterval, java.lang.Integer dynamicResetInterval, java.lang.Double dynamicBadnessThreshold)
          Change endpointsnitch class and dynamic-ness (and dynamic attributes) at runtime
 void upgradeSSTables(java.lang.String tableName, java.lang.String... columnFamilies)
          Rewrite all sstables to the latest version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RING_DELAY

public static final int RING_DELAY

VERBS

public static final StorageService.Verb[] VERBS

verbStages

public static final java.util.EnumMap<StorageService.Verb,Stage> verbStages

scheduledTasks

public static final DebuggableScheduledThreadPoolExecutor scheduledTasks
This pool is used for periodic short (sub-second) tasks.


tasks

public static final DebuggableScheduledThreadPoolExecutor tasks
This pool is used by tasks that can have longer execution times, and usually are non periodic.


optionalTasks

public static final DebuggableScheduledThreadPoolExecutor optionalTasks
tasks that do not need to be waited for on shutdown/drain


valueFactory

public VersionedValue.VersionedValueFactory valueFactory

instance

public static final StorageService instance
Constructor Detail

StorageService

public StorageService()
Method Detail

getPartitioner

public static IPartitioner getPartitioner()

getLocalRanges

public java.util.Collection<Range<Token>> getLocalRanges(java.lang.String table)

getLocalPrimaryRange

public Range<Token> getLocalPrimaryRange()

getPrimaryRange

public java.util.List<java.lang.String> getPrimaryRange()
Description copied from interface: StorageServiceMBean
Returns the local node's primary range.

Specified by:
getPrimaryRange in interface StorageServiceMBean

finishBootstrapping

public void finishBootstrapping()

setToken

public void setToken(Token token)
This method updates the local token on disk


registerDaemon

public void registerDaemon(CassandraDaemon daemon)

stopGossiping

public void stopGossiping()
Specified by:
stopGossiping in interface StorageServiceMBean

startGossiping

public void startGossiping()
Specified by:
startGossiping in interface StorageServiceMBean

startRPCServer

public void startRPCServer()
Specified by:
startRPCServer in interface StorageServiceMBean

stopRPCServer

public void stopRPCServer()
Specified by:
stopRPCServer in interface StorageServiceMBean

isRPCServerRunning

public boolean isRPCServerRunning()
Specified by:
isRPCServerRunning in interface StorageServiceMBean

stopClient

public void stopClient()

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface StorageServiceMBean

initClient

public void initClient()
                throws java.io.IOException,
                       ConfigurationException
Throws:
java.io.IOException
ConfigurationException

initClient

public void initClient(int delay)
                throws java.io.IOException,
                       ConfigurationException
Throws:
java.io.IOException
ConfigurationException

initServer

public void initServer()
                throws java.io.IOException,
                       ConfigurationException
Throws:
java.io.IOException
ConfigurationException

initServer

public void initServer(int delay)
                throws java.io.IOException,
                       ConfigurationException
Throws:
java.io.IOException
ConfigurationException

joinRing

public void joinRing()
              throws java.io.IOException,
                     ConfigurationException
Specified by:
joinRing in interface StorageServiceMBean
Throws:
java.io.IOException
ConfigurationException

isJoined

public boolean isJoined()
Specified by:
isJoined in interface StorageServiceMBean

rebuild

public void rebuild(java.lang.String sourceDc)
Description copied from interface: StorageServiceMBean
Initiate a process of streaming data for which we are responsible from other nodes. It is similar to bootstrap except meant to be used on a node which is already in the cluster (typically containing no data) as an alternative to running repair.

Specified by:
rebuild in interface StorageServiceMBean
Parameters:
sourceDc - Name of DC from which to select sources for streaming or null to pick any node

setStreamThroughputMbPerSec

public void setStreamThroughputMbPerSec(int value)
Specified by:
setStreamThroughputMbPerSec in interface StorageServiceMBean

getStreamThroughputMbPerSec

public int getStreamThroughputMbPerSec()
Specified by:
getStreamThroughputMbPerSec in interface StorageServiceMBean

getCompactionThroughputMbPerSec

public int getCompactionThroughputMbPerSec()
Specified by:
getCompactionThroughputMbPerSec in interface StorageServiceMBean

setCompactionThroughputMbPerSec

public void setCompactionThroughputMbPerSec(int value)
Specified by:
setCompactionThroughputMbPerSec in interface StorageServiceMBean

isIncrementalBackupsEnabled

public boolean isIncrementalBackupsEnabled()
Specified by:
isIncrementalBackupsEnabled in interface StorageServiceMBean

setIncrementalBackupsEnabled

public void setIncrementalBackupsEnabled(boolean value)
Specified by:
setIncrementalBackupsEnabled in interface StorageServiceMBean

isBootstrapMode

public boolean isBootstrapMode()

getTokenMetadata

public TokenMetadata getTokenMetadata()

getRangeToEndpointMap

public java.util.Map<java.util.List<java.lang.String>,java.util.List<java.lang.String>> getRangeToEndpointMap(java.lang.String keyspace)
for a keyspace, return the ranges and corresponding listen addresses.

Specified by:
getRangeToEndpointMap in interface StorageServiceMBean
Parameters:
keyspace -
Returns:

getRpcaddress

public java.lang.String getRpcaddress(java.net.InetAddress endpoint)
Return the rpc address associated with an endpoint as a string.

Parameters:
endpoint - The endpoint to get rpc address for
Returns:

getRangeToRpcaddressMap

public java.util.Map<java.util.List<java.lang.String>,java.util.List<java.lang.String>> getRangeToRpcaddressMap(java.lang.String keyspace)
for a keyspace, return the ranges and corresponding RPC addresses for a given keyspace.

Specified by:
getRangeToRpcaddressMap in interface StorageServiceMBean
Parameters:
keyspace -
Returns:

getPendingRangeToEndpointMap

public java.util.Map<java.util.List<java.lang.String>,java.util.List<java.lang.String>> getPendingRangeToEndpointMap(java.lang.String keyspace)
Description copied from interface: StorageServiceMBean
Retrieve a map of pending ranges to endpoints that describe the ring topology

Specified by:
getPendingRangeToEndpointMap in interface StorageServiceMBean
Parameters:
keyspace - the keyspace to get the pending range map for.
Returns:
a map of pending ranges to endpoints

getRangeToAddressMap

public java.util.Map<Range<Token>,java.util.List<java.net.InetAddress>> getRangeToAddressMap(java.lang.String keyspace)

describeRingJMX

public java.util.List<java.lang.String> describeRingJMX(java.lang.String keyspace)
                                                 throws org.apache.cassandra.thrift.InvalidRequestException
The same as describeRing(String) but converts TokenRange to the String for JMX compatibility

Specified by:
describeRingJMX in interface StorageServiceMBean
Parameters:
keyspace - The keyspace to fetch information about
Returns:
a List of TokenRange(s) converted to String for the given keyspace
Throws:
org.apache.cassandra.thrift.InvalidRequestException - if there is no ring information available about keyspace

describeRing

public java.util.List<org.apache.cassandra.thrift.TokenRange> describeRing(java.lang.String keyspace)
                                                                    throws org.apache.cassandra.thrift.InvalidRequestException
The TokenRange for a given keyspace.

Parameters:
keyspace - The keyspace to fetch information about
Returns:
a List of TokenRange(s) for the given keyspace
Throws:
org.apache.cassandra.thrift.InvalidRequestException - if there is no ring information available about keyspace

getTokenToEndpointMap

public java.util.Map<java.lang.String,java.lang.String> getTokenToEndpointMap()
Description copied from interface: StorageServiceMBean
Retrieve a map of tokens to endpoints, including the bootstrapping ones.

Specified by:
getTokenToEndpointMap in interface StorageServiceMBean
Returns:
a map of tokens to endpoints in ascending order

onChange

public void onChange(java.net.InetAddress endpoint,
                     ApplicationState state,
                     VersionedValue value)
Specified by:
onChange in interface IEndpointStateChangeSubscriber

addExpireTimeIfFound

protected void addExpireTimeIfFound(java.net.InetAddress endpoint,
                                    long expireTime)

extractExpireTime

protected long extractExpireTime(java.lang.String[] pieces)

calculatePendingRanges

public static void calculatePendingRanges(AbstractReplicationStrategy strategy,
                                          java.lang.String table)

onJoin

public void onJoin(java.net.InetAddress endpoint,
                   EndpointState epState)
Description copied from interface: IEndpointStateChangeSubscriber
Use to inform interested parties about the change in the state for specified endpoint

Specified by:
onJoin in interface IEndpointStateChangeSubscriber
Parameters:
endpoint - endpoint for which the state change occurred.
epState - state that actually changed for the above endpoint.

onAlive

public void onAlive(java.net.InetAddress endpoint,
                    EndpointState state)
Specified by:
onAlive in interface IEndpointStateChangeSubscriber

onRemove

public void onRemove(java.net.InetAddress endpoint)
Specified by:
onRemove in interface IEndpointStateChangeSubscriber

onDead

public void onDead(java.net.InetAddress endpoint,
                   EndpointState state)
Specified by:
onDead in interface IEndpointStateChangeSubscriber

onRestart

public void onRestart(java.net.InetAddress endpoint,
                      EndpointState state)
Description copied from interface: IEndpointStateChangeSubscriber
Called whenever a node is restarted. Note that there is no guarantee when that happens that the node was previously marked down. It will have only if state.isAlive() == false as state is from before the restarted node is marked up.

Specified by:
onRestart in interface IEndpointStateChangeSubscriber

getLoad

public double getLoad()
raw load value

Specified by:
getLoad in interface StorageServiceMBean

getLoadString

public java.lang.String getLoadString()
Description copied from interface: StorageServiceMBean
Human-readable load value

Specified by:
getLoadString in interface StorageServiceMBean

getLoadMap

public java.util.Map<java.lang.String,java.lang.String> getLoadMap()
Description copied from interface: StorageServiceMBean
Human-readable load value. Keys are IP addresses.

Specified by:
getLoadMap in interface StorageServiceMBean

deliverHints

public final void deliverHints(java.lang.String host)
                        throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

getLocalToken

public Token getLocalToken()

getToken

public java.lang.String getToken()
Description copied from interface: StorageServiceMBean
Fetch a string representation of the token.

Specified by:
getToken in interface StorageServiceMBean
Returns:
a string token

getReleaseVersion

public java.lang.String getReleaseVersion()
Description copied from interface: StorageServiceMBean
Fetch a string representation of the Cassandra version.

Specified by:
getReleaseVersion in interface StorageServiceMBean
Returns:
A string representation of the Cassandra version.

getSchemaVersion

public java.lang.String getSchemaVersion()
Description copied from interface: StorageServiceMBean
Fetch a string representation of the current Schema version.

Specified by:
getSchemaVersion in interface StorageServiceMBean
Returns:
A string representation of the Schema version.

getLeavingNodes

public java.util.List<java.lang.String> getLeavingNodes()
Description copied from interface: StorageServiceMBean
Retrieve the list of nodes currently leaving the ring.

Specified by:
getLeavingNodes in interface StorageServiceMBean
Returns:
set of IP addresses, as Strings

getMovingNodes

public java.util.List<java.lang.String> getMovingNodes()
Description copied from interface: StorageServiceMBean
Retrieve the list of nodes currently moving in the ring.

Specified by:
getMovingNodes in interface StorageServiceMBean
Returns:
set of IP addresses, as Strings

getJoiningNodes

public java.util.List<java.lang.String> getJoiningNodes()
Description copied from interface: StorageServiceMBean
Retrieve the list of nodes currently bootstrapping into the ring.

Specified by:
getJoiningNodes in interface StorageServiceMBean
Returns:
set of IP addresses, as Strings

getLiveNodes

public java.util.List<java.lang.String> getLiveNodes()
Description copied from interface: StorageServiceMBean
Retrieve the list of live nodes in the cluster, where "liveness" is determined by the failure detector of the node being queried.

Specified by:
getLiveNodes in interface StorageServiceMBean
Returns:
set of IP addresses, as Strings

getUnreachableNodes

public java.util.List<java.lang.String> getUnreachableNodes()
Description copied from interface: StorageServiceMBean
Retrieve the list of unreachable nodes in the cluster, as determined by this node's failure detector.

Specified by:
getUnreachableNodes in interface StorageServiceMBean
Returns:
set of IP addresses, as Strings

getAllDataFileLocations

public java.lang.String[] getAllDataFileLocations()
Description copied from interface: StorageServiceMBean
Get the list of all data file locations from conf

Specified by:
getAllDataFileLocations in interface StorageServiceMBean
Returns:
String array of all locations

getCommitLogLocation

public java.lang.String getCommitLogLocation()
Description copied from interface: StorageServiceMBean
Get location of the commit log

Specified by:
getCommitLogLocation in interface StorageServiceMBean
Returns:
a string path

getSavedCachesLocation

public java.lang.String getSavedCachesLocation()
Description copied from interface: StorageServiceMBean
Get location of the saved caches dir

Specified by:
getSavedCachesLocation in interface StorageServiceMBean
Returns:
a string path

getCurrentGenerationNumber

public int getCurrentGenerationNumber()
Description copied from interface: StorageServiceMBean
Return the generation value for this node.

Specified by:
getCurrentGenerationNumber in interface StorageServiceMBean
Returns:
generation number

forceTableCleanup

public void forceTableCleanup(java.lang.String tableName,
                              java.lang.String... columnFamilies)
                       throws java.io.IOException,
                              java.util.concurrent.ExecutionException,
                              java.lang.InterruptedException
Description copied from interface: StorageServiceMBean
Trigger a cleanup of keys on a single keyspace

Specified by:
forceTableCleanup in interface StorageServiceMBean
Throws:
java.io.IOException
java.util.concurrent.ExecutionException
java.lang.InterruptedException

scrub

public void scrub(java.lang.String tableName,
                  java.lang.String... columnFamilies)
           throws java.io.IOException,
                  java.util.concurrent.ExecutionException,
                  java.lang.InterruptedException
Description copied from interface: StorageServiceMBean
Scrub (deserialize + reserialize at the latest version, skipping bad rows if any) the given keyspace. If columnFamilies array is empty, all CFs are scrubbed. Scrubbed CFs will be snapshotted first.

Specified by:
scrub in interface StorageServiceMBean
Throws:
java.io.IOException
java.util.concurrent.ExecutionException
java.lang.InterruptedException

upgradeSSTables

public void upgradeSSTables(java.lang.String tableName,
                            java.lang.String... columnFamilies)
                     throws java.io.IOException,
                            java.util.concurrent.ExecutionException,
                            java.lang.InterruptedException
Description copied from interface: StorageServiceMBean
Rewrite all sstables to the latest version. Unlike scrub, it doesn't skip bad rows and do not snapshot sstables first.

Specified by:
upgradeSSTables in interface StorageServiceMBean
Throws:
java.io.IOException
java.util.concurrent.ExecutionException
java.lang.InterruptedException

forceTableCompaction

public void forceTableCompaction(java.lang.String tableName,
                                 java.lang.String... columnFamilies)
                          throws java.io.IOException,
                                 java.util.concurrent.ExecutionException,
                                 java.lang.InterruptedException
Description copied from interface: StorageServiceMBean
Forces major compaction of a single keyspace

Specified by:
forceTableCompaction in interface StorageServiceMBean
Throws:
java.io.IOException
java.util.concurrent.ExecutionException
java.lang.InterruptedException

takeSnapshot

public void takeSnapshot(java.lang.String tag,
                         java.lang.String... tableNames)
                  throws java.io.IOException
Takes the snapshot for the given tables. A snapshot name must be specified.

Specified by:
takeSnapshot in interface StorageServiceMBean
Parameters:
tag - the tag given to the snapshot; may not be null or empty
tableNames - the name of the tables to snapshot; empty means "all."
Throws:
java.io.IOException

takeColumnFamilySnapshot

public void takeColumnFamilySnapshot(java.lang.String tableName,
                                     java.lang.String columnFamilyName,
                                     java.lang.String tag)
                              throws java.io.IOException
Takes the snapshot of a specific column family. A snapshot name must be specified.

Specified by:
takeColumnFamilySnapshot in interface StorageServiceMBean
Parameters:
tableName - the keyspace which holds the specified column family
columnFamilyName - the column family to snapshot
tag - the tag given to the snapshot; may not be null or empty
Throws:
java.io.IOException

clearSnapshot

public void clearSnapshot(java.lang.String tag,
                          java.lang.String... tableNames)
                   throws java.io.IOException
Remove the snapshot with the given name from the given tables. If no tag is specified we will remove all snapshots.

Specified by:
clearSnapshot in interface StorageServiceMBean
Throws:
java.io.IOException

getValidColumnFamilies

public java.lang.Iterable<ColumnFamilyStore> getValidColumnFamilies(java.lang.String tableName,
                                                                    java.lang.String... cfNames)
                                                             throws java.io.IOException
Throws:
java.io.IOException

forceTableFlush

public void forceTableFlush(java.lang.String tableName,
                            java.lang.String... columnFamilies)
                     throws java.io.IOException,
                            java.util.concurrent.ExecutionException,
                            java.lang.InterruptedException
Flush all memtables for a table and column families.

Specified by:
forceTableFlush in interface StorageServiceMBean
Parameters:
tableName -
columnFamilies -
Throws:
java.io.IOException
java.util.concurrent.ExecutionException
java.lang.InterruptedException

forceTableRepair

public void forceTableRepair(java.lang.String tableName,
                             boolean isSequential,
                             java.lang.String... columnFamilies)
                      throws java.io.IOException
Trigger proactive repair for a table and column families.

Specified by:
forceTableRepair in interface StorageServiceMBean
Parameters:
tableName -
columnFamilies -
Throws:
java.io.IOException

forceTableRepairPrimaryRange

public void forceTableRepairPrimaryRange(java.lang.String tableName,
                                         boolean isSequential,
                                         java.lang.String... columnFamilies)
                                  throws java.io.IOException
Description copied from interface: StorageServiceMBean
Triggers proactive repair but only for the node primary range.

Specified by:
forceTableRepairPrimaryRange in interface StorageServiceMBean
Throws:
java.io.IOException

forceTableRepairRange

public void forceTableRepairRange(java.lang.String beginToken,
                                  java.lang.String endToken,
                                  java.lang.String tableName,
                                  boolean isSequential,
                                  java.lang.String... columnFamilies)
                           throws java.io.IOException
Description copied from interface: StorageServiceMBean
Perform repair of a specific range. This allows incremental repair to be performed by having an external controller submitting repair jobs. Note that the provided range much be a subset of one of the node local range.

Specified by:
forceTableRepairRange in interface StorageServiceMBean
Throws:
java.io.IOException

forceTableRepair

public AntiEntropyService.RepairFuture forceTableRepair(Range<Token> range,
                                                        java.lang.String tableName,
                                                        boolean isSequential,
                                                        java.lang.String... columnFamilies)
                                                 throws java.io.IOException
Throws:
java.io.IOException

forceTerminateAllRepairSessions

public void forceTerminateAllRepairSessions()
Specified by:
forceTerminateAllRepairSessions in interface StorageServiceMBean

getSuccessor

public java.net.InetAddress getSuccessor(java.net.InetAddress ep)

getPrimaryRangeForEndpoint

public Range<Token> getPrimaryRangeForEndpoint(java.net.InetAddress ep)
Get the primary range for the specified endpoint.

Parameters:
ep - endpoint we are interested in.
Returns:
range for the specified endpoint.

getAllRanges

public java.util.List<Range<Token>> getAllRanges(java.util.List<Token> sortedTokens)
Get all ranges that span the ring given a set of tokens. All ranges are in sorted order of ranges.

Returns:
ranges in sorted order

getNaturalEndpoints

public java.util.List<java.net.InetAddress> getNaturalEndpoints(java.lang.String table,
                                                                java.lang.String cf,
                                                                java.lang.String key)
This method returns the N endpoints that are responsible for storing the specified key i.e for replication.

Specified by:
getNaturalEndpoints in interface StorageServiceMBean
Parameters:
table - keyspace name also known as table
cf - Column family name
key - key for which we need to find the endpoint
Returns:
the endpoint responsible for this key

getNaturalEndpoints

public java.util.List<java.net.InetAddress> getNaturalEndpoints(java.lang.String table,
                                                                java.nio.ByteBuffer key)
Specified by:
getNaturalEndpoints in interface StorageServiceMBean

getNaturalEndpoints

public java.util.List<java.net.InetAddress> getNaturalEndpoints(java.lang.String table,
                                                                RingPosition pos)
This method returns the N endpoints that are responsible for storing the specified key i.e for replication.

Parameters:
table - keyspace name also known as table
pos - position for which we need to find the endpoint
Returns:
the endpoint responsible for this token

getLiveNaturalEndpoints

public java.util.List<java.net.InetAddress> getLiveNaturalEndpoints(java.lang.String table,
                                                                    java.nio.ByteBuffer key)
This method attempts to return N endpoints that are responsible for storing the specified key i.e for replication.

Parameters:
table - keyspace name also known as table
key - key for which we need to find the endpoint
Returns:
the endpoint responsible for this key

getLiveNaturalEndpoints

public java.util.List<java.net.InetAddress> getLiveNaturalEndpoints(java.lang.String table,
                                                                    RingPosition pos)

setLog4jLevel

public void setLog4jLevel(java.lang.String classQualifier,
                          java.lang.String rawLevel)
Description copied from interface: StorageServiceMBean
set the logging level at runtime

Specified by:
setLog4jLevel in interface StorageServiceMBean

getSplits

public java.util.List<Token> getSplits(java.lang.String table,
                                       java.lang.String cfName,
                                       Range<Token> range,
                                       int keysPerSplit)
Returns:
list of Tokens (_not_ keys!) breaking up the data this node is responsible for into pieces of roughly keysPerSplit

getBootstrapToken

public Token getBootstrapToken()
return a token to which if a node bootstraps it will get about 1/2 of this node's range


decommission

public void decommission()
                  throws java.lang.InterruptedException
Description copied from interface: StorageServiceMBean
transfer this node's data to other machines and remove it from service.

Specified by:
decommission in interface StorageServiceMBean
Throws:
java.lang.InterruptedException

move

public void move(java.lang.String newToken)
          throws java.io.IOException,
                 java.lang.InterruptedException,
                 ConfigurationException
Specified by:
move in interface StorageServiceMBean
Parameters:
newToken - token to move this node to. This node will unload its data onto its neighbors, and bootstrap to the new token.
Throws:
java.io.IOException
java.lang.InterruptedException
ConfigurationException

getRemovalStatus

public java.lang.String getRemovalStatus()
Get the status of a token removal.

Specified by:
getRemovalStatus in interface StorageServiceMBean

forceRemoveCompletion

public void forceRemoveCompletion()
Force a remove operation to complete. This may be necessary if a remove operation blocks forever due to node/stream failure. removeToken() must be called first, this is a last resort measure. No further attempt will be made to restore replicas.

Specified by:
forceRemoveCompletion in interface StorageServiceMBean

removeToken

public void removeToken(java.lang.String tokenString)
Remove a node that has died, attempting to restore the replica count. If the node is alive, decommission should be attempted. If decommission fails, then removeToken should be called. If we fail while trying to restore the replica count, finally forceRemoveCompleteion should be called to forcibly remove the node without regard to replica count.

Specified by:
removeToken in interface StorageServiceMBean
Parameters:
tokenString - token for the node

confirmReplication

public void confirmReplication(java.net.InetAddress node)

isClientMode

public boolean isClientMode()

requestGC

public void requestGC()

getOperationMode

public java.lang.String getOperationMode()
Description copied from interface: StorageServiceMBean
get the operational mode (leaving, joining, normal, decommissioned, client)

Specified by:
getOperationMode in interface StorageServiceMBean

getDrainProgress

public java.lang.String getDrainProgress()
Description copied from interface: StorageServiceMBean
get the progress of a drain operation

Specified by:
getDrainProgress in interface StorageServiceMBean

drain

public void drain()
           throws java.io.IOException,
                  java.lang.InterruptedException,
                  java.util.concurrent.ExecutionException
Shuts node off to writes, empties memtables and the commit log. There are two differences between drain and the normal shutdown hook: - Drain waits for in-progress streaming to complete - Drain flushes *all* columnfamilies (shutdown hook only flushes non-durable CFs)

Specified by:
drain in interface StorageServiceMBean
Throws:
java.io.IOException
java.lang.InterruptedException
java.util.concurrent.ExecutionException

truncate

public void truncate(java.lang.String keyspace,
                     java.lang.String columnFamily)
              throws org.apache.cassandra.thrift.UnavailableException,
                     java.util.concurrent.TimeoutException,
                     java.io.IOException
Description copied from interface: StorageServiceMBean
Truncates (deletes) the given columnFamily from the provided keyspace. Calling truncate results in actual deletion of all data in the cluster under the given columnFamily and it will fail unless all hosts are up. All data in the given column family will be deleted, but its definition will not be affected.

Specified by:
truncate in interface StorageServiceMBean
Parameters:
keyspace - The keyspace to delete from
columnFamily - The column family to delete data from.
Throws:
org.apache.cassandra.thrift.UnavailableException - if some of the hosts in the ring are down.
java.util.concurrent.TimeoutException
java.io.IOException

getOwnership

public java.util.Map<java.lang.String,java.lang.Float> getOwnership()
Description copied from interface: StorageServiceMBean
given a list of tokens (representing the nodes in the cluster), returns a mapping from "token -> %age of cluster owned by that token"

Specified by:
getOwnership in interface StorageServiceMBean

effectiveOwnership

public java.util.Map<java.lang.String,java.lang.Float> effectiveOwnership(java.lang.String keyspace)
                                                                   throws ConfigurationException
Description copied from interface: StorageServiceMBean
Effective ownership is % of the data each node owns given the keyspace we calculate the percentage using replication factor. If Keyspace == null, this method will try to verify if all the keyspaces in the cluster have the same replication strategies and if yes then we will use the first else a empty Map is returned.

Specified by:
effectiveOwnership in interface StorageServiceMBean
Throws:
ConfigurationException

getKeyspaces

public java.util.List<java.lang.String> getKeyspaces()
Specified by:
getKeyspaces in interface StorageServiceMBean

updateSnitch

public void updateSnitch(java.lang.String epSnitchClassName,
                         java.lang.Boolean dynamic,
                         java.lang.Integer dynamicUpdateInterval,
                         java.lang.Integer dynamicResetInterval,
                         java.lang.Double dynamicBadnessThreshold)
                  throws ConfigurationException
Description copied from interface: StorageServiceMBean
Change endpointsnitch class and dynamic-ness (and dynamic attributes) at runtime

Specified by:
updateSnitch in interface StorageServiceMBean
Parameters:
epSnitchClassName - the canonical path name for a class implementing IEndpointSnitch
dynamic - boolean that decides whether dynamicsnitch is used or not
dynamicUpdateInterval - integer, in ms (default 100)
dynamicResetInterval - integer, in ms (default 600,000)
dynamicBadnessThreshold - double, (default 0.0)
Throws:
ConfigurationException - classname not found on classpath

flushLargestMemtables

public void flushLargestMemtables()
Flushes the two largest memtables by ops and by throughput


calculateStreamAndFetchRanges

public Pair<java.util.Set<Range<Token>>,java.util.Set<Range<Token>>> calculateStreamAndFetchRanges(java.util.Collection<Range<Token>> current,
                                                                                                   java.util.Collection<Range<Token>> updated)
Calculate pair of ranges to stream/fetch for given two range collections (current ranges for table and ranges after move to new token)

Parameters:
current - collection of the ranges by current token
updated - collection of the ranges after token is changed
Returns:
pair of ranges to stream/fetch for given current and updated range collections

bulkLoad

public void bulkLoad(java.lang.String directory)
Specified by:
bulkLoad in interface StorageServiceMBean

getExceptionCount

public int getExceptionCount()
Specified by:
getExceptionCount in interface StorageServiceMBean

rescheduleFailedDeletions

public void rescheduleFailedDeletions()
Specified by:
rescheduleFailedDeletions in interface StorageServiceMBean

loadNewSSTables

public void loadNewSSTables(java.lang.String ksName,
                            java.lang.String cfName)
#Load new SSTables to the given keyspace/columnFamily

Specified by:
loadNewSSTables in interface StorageServiceMBean
Parameters:
ksName - The parent keyspace name
cfName - The ColumnFamily name where SSTables belong

getRangeKeySample

public java.util.List<java.lang.String> getRangeKeySample()
#Return a List of Tokens representing a sample of keys across all ColumnFamilyStores

Specified by:
getRangeKeySample in interface StorageServiceMBean
Returns:
set of Tokens as Strings

rebuildSecondaryIndex

public void rebuildSecondaryIndex(java.lang.String ksName,
                                  java.lang.String cfName,
                                  java.lang.String... idxNames)
Description copied from interface: StorageServiceMBean
rebuild the specified indexes

Specified by:
rebuildSecondaryIndex in interface StorageServiceMBean

resetLocalSchema

public void resetLocalSchema()
                      throws java.io.IOException
Specified by:
resetLocalSchema in interface StorageServiceMBean
Throws:
java.io.IOException


Copyright © 2012 The Apache Software Foundation