Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cassandra.service
Class StorageService

    java.lang.Object
      org.apache.cassandra.service.StorageService

All Implemented Interfaces:
  IEndPointStateChangeSubscriber, StorageServiceMBean

    public class StorageService

extends java.lang.Object
implements IEndPointStateChangeSubscriber, StorageServiceMBean

Nested Class Summary
`static class` | `StorageService.Verb`

Field Summary
`static char` | `Delimiter`
`static StorageService` | `instance`
`static java.lang.String` | `MOVE_STATE`
`static java.lang.String` | `REMOVE_TOKEN`
`static int` | `RING_DELAY`
`static java.lang.String` | `STATE_BOOTSTRAPPING`
`static java.lang.String` | `STATE_LEAVING`
`static java.lang.String` | `STATE_LEFT`
`static java.lang.String` | `STATE_NORMAL`
`static StorageService.Verb[]` | `VERBS`

Constructor Summary
`StorageService()`

Method Summary
`void` | `addBootstrapSource(java.net.InetAddress s, java.lang.String table)`
`static void` | `calculatePendingRanges(AbstractReplicationStrategy strategy, java.lang.String table)`
`void` | `clearSnapshot()` Remove all the existing snapshots.
`void` | `decommission()` transfer this node's data to other machines and remove it from service.
`void` | `deliverHints(java.net.InetAddress endpoint)` Deliver hints to the specified node when it has crashed and come back up/ marked as alive after a network partition
`void` | `deliverHints(java.lang.String host)` force hint delivery to an endpoint
`void` | `doConsistencyCheck(Row row, java.util.List<java.net.InetAddress> endpoints, ReadCommand command)` This method performs the requisite operations to make sure that the N replicas are in sync.
`void` | `drain()` shuts node off to writes, empties memtables and the commit log.
`java.net.InetAddress` | `findSuitableEndPoint(java.lang.String table, java.lang.String key)` This function finds the closest live endpoint that contains a given key.
`void` | `forceTableCleanup()` Trigger a cleanup of keys on all tables.
`void` | `forceTableCleanup(java.lang.String tableName)` Trigger a cleanup of keys on a single keyspace
`void` | `forceTableCompaction()` Forces major compaction (all sstable files compacted)
`void` | `forceTableCompaction(java.lang.String tableName)` 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.
`void` | `forceTableRepair(java.lang.String tableName, java.lang.String... columnFamilies)` Trigger proactive repair for a table and column families.
`java.util.List<Range>` | `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
`int` | `getCurrentGenerationNumber()` Return the generation value for this node.
`java.util.List<java.net.InetAddress>` | `getLiveNaturalEndpoints(java.lang.String table, java.lang.String 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, Token token)`
`java.util.Set<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` | `getLocalPrimaryRange()`
`java.util.Collection<Range>` | `getLocalRanges(java.lang.String table)`
`Token` | `getLocalToken()`
`java.util.List<java.net.InetAddress>` | `getNaturalEndpoints(java.lang.String table, java.lang.String key)` 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, Token token)` 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)
`static IPartitioner` | `getPartitioner()`
`Range` | `getPrimaryRangeForEndPoint(java.net.InetAddress ep)` Get the primary range for the specified endpoint.
`java.util.Map<Range,java.util.List<java.net.InetAddress>>` | `getRangeToAddressMap(java.lang.String keyspace)`
`java.util.Map<Range,java.util.List<java.lang.String>>` | `getRangeToEndPointMap(java.lang.String keyspace)` for a keyspace, return the ranges and corresponding hosts for a given keyspace.
`AbstractReplicationStrategy` | `getReplicationStrategy(java.lang.String table)`
`static AbstractReplicationStrategy` | `getReplicationStrategy(TokenMetadata tokenMetadata, java.lang.String table)`
`java.util.List<Token>` | `getSplits(Range range, int keysPerSplit)`
`java.util.Map<java.lang.String,java.lang.String>` | `getStringEndpointMap()`
`java.net.InetAddress` | `getSuccessor(java.net.InetAddress ep)`
`java.lang.String` | `getToken()` Fetch a string representation of the token.
`TokenMetadata` | `getTokenMetadata()`
`java.util.Set<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... columnFamilies)`
`WriteResponseHandler` | `getWriteResponseHandler(int blockFor, ConsistencyLevel consistency_level, java.lang.String table)`
`void` | `initClient()`
`void` | `initServer()`
`boolean` | `isBootstrapMode()`
`boolean` | `isClientMode()`
`void` | `loadBalance()` This node will unload its data onto its neighbors, and bootstrap to share the range of the most-loaded node in the ring.
`void` | `move(java.lang.String newToken)`
`void` | `onAlive(java.net.InetAddress endpoint, EndPointState state)`
`void` | `onChange(java.net.InetAddress endpoint, java.lang.String apStateName, ApplicationState apState)`
`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` | `removeBootstrapSource(java.net.InetAddress s, java.lang.String table)`
`void` | `removeToken(java.lang.String tokenString)` removeToken removes token (and all data associated with enpoint that had it) from the ring
`void` | `requestGC()`
`void` | `saveCaches()` save row and key caches
`void` | `setLog4jLevel(java.lang.String classQualifier, java.lang.String rawLevel)` set the logging level at runtime
`void` | `setToken(Token token)` This method updates the local token on disk
`void` | `stopClient()`
`void` | `takeAllSnapshot(java.lang.String tag)` Takes a snapshot for every table.
`void` | `takeSnapshot(java.lang.String tableName, java.lang.String tag)` Takes the snapshot for a given table.

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

See Also:
  Constant Field Values

### MOVE_STATE

    public static final java.lang.String MOVE_STATE

See Also:
  Constant Field Values

### Delimiter

    public static final char Delimiter

See Also:
  Constant Field Values

### STATE_BOOTSTRAPPING

    public static final java.lang.String STATE_BOOTSTRAPPING

See Also:
  Constant Field Values

### STATE_NORMAL

    public static final java.lang.String STATE_NORMAL

See Also:
  Constant Field Values

### STATE_LEAVING

    public static final java.lang.String STATE_LEAVING

See Also:
  Constant Field Values

### STATE_LEFT

    public static final java.lang.String STATE_LEFT

See Also:
  Constant Field Values

### REMOVE_TOKEN

    public static final java.lang.String REMOVE_TOKEN

See Also:
  Constant Field Values

### VERBS

    public static final StorageService.Verb[] VERBS

### instance

    public static final StorageService instance

Constructor Detail

### StorageService

    public StorageService()

Method Detail

### getPartitioner

    public static IPartitioner getPartitioner()

### getLocalRanges

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

### getLocalPrimaryRange

    public Range getLocalPrimaryRange()

### addBootstrapSource

    public void addBootstrapSource(java.net.InetAddress s,
                                   java.lang.String table)

### removeBootstrapSource

    public void removeBootstrapSource(java.net.InetAddress s,
                                      java.lang.String table)

### setToken

    public void setToken(Token token)

  This method updates the local token on disk

### getReplicationStrategy

    public AbstractReplicationStrategy getReplicationStrategy(java.lang.String table)

### getReplicationStrategy

    public static AbstractReplicationStrategy getReplicationStrategy(TokenMetadata tokenMetadata,
                                                                     java.lang.String table)

### stopClient

    public void stopClient()

### initClient

    public void initClient()
                    throws java.io.IOException

  Throws:
    `java.io.IOException`

### initServer

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

  Throws:
    `java.io.IOException`
    `ConfigurationException`

### isBootstrapMode

    public boolean isBootstrapMode()

### getTokenMetadata

    public TokenMetadata getTokenMetadata()

### doConsistencyCheck

    public void doConsistencyCheck(Row row,
                                   java.util.List<java.net.InetAddress> endpoints,
                                   ReadCommand command)

  This method performs the requisite operations to make sure that the N replicas are in sync. We do this in the background when we do not care much about consistency.

### getRangeToEndPointMap

    public java.util.Map<Range,java.util.List<java.lang.String>> getRangeToEndPointMap(java.lang.String keyspace)

  for a keyspace, return the ranges and corresponding hosts for a given keyspace.

  Specified by:
    `getRangeToEndPointMap` in interface `StorageServiceMBean`
  Parameters:
    `keyspace` -
  Returns:

### getRangeToAddressMap

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

### onChange

    public void onChange(java.net.InetAddress endpoint,
                         java.lang.String apStateName,
                         ApplicationState apState)

  Specified by:
    `onChange` in interface `IEndPointStateChangeSubscriber`

### 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`

### 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.net.InetAddress endpoint)

  Deliver hints to the specified node when it has crashed and come back up/ marked as alive after a network partition

### deliverHints

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

  Description copied from interface: `StorageServiceMBean`
  force hint delivery to an endpoint

  Specified by:
    `deliverHints` in interface `StorageServiceMBean`
  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

### getLiveNodes

    public java.util.Set<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.Set<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

### 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()
                           throws java.io.IOException

  Description copied from interface: `StorageServiceMBean`
  Trigger a cleanup of keys on all tables.

  Specified by:
    `forceTableCleanup` in interface `StorageServiceMBean`
  Throws:
    `java.io.IOException`

### forceTableCleanup

    public void forceTableCleanup(java.lang.String tableName)
                           throws java.io.IOException

  Description copied from interface: `StorageServiceMBean`
  Trigger a cleanup of keys on a single keyspace

  Specified by:
    `forceTableCleanup` in interface `StorageServiceMBean`
  Throws:
    `java.io.IOException`

### forceTableCompaction

    public void forceTableCompaction()
                              throws java.io.IOException

  Description copied from interface: `StorageServiceMBean`
  Forces major compaction (all sstable files compacted)

  Specified by:
    `forceTableCompaction` in interface `StorageServiceMBean`
  Throws:
    `java.io.IOException`

### forceTableCompaction

    public void forceTableCompaction(java.lang.String tableName)
                              throws java.io.IOException

  Description copied from interface: `StorageServiceMBean`
  Forces major compaction of a single keyspace

  Specified by:
    `forceTableCompaction` in interface `StorageServiceMBean`
  Throws:
    `java.io.IOException`

### takeSnapshot

    public void takeSnapshot(java.lang.String tableName,
                             java.lang.String tag)
                      throws java.io.IOException

  Takes the snapshot for a given table.

  Specified by:
    `takeSnapshot` in interface `StorageServiceMBean`
  Parameters:
    `tableName` - the name of the table.
    `tag` - the tag given to the snapshot (null is permissible)
  Throws:
    `java.io.IOException`

### takeAllSnapshot

    public void takeAllSnapshot(java.lang.String tag)
                         throws java.io.IOException

  Takes a snapshot for every table.

  Specified by:
    `takeAllSnapshot` in interface `StorageServiceMBean`
  Parameters:
    `tag` - the tag given to the snapshot (null is permissible)
  Throws:
    `java.io.IOException`

### clearSnapshot

    public void clearSnapshot()
                       throws java.io.IOException

  Remove all the existing 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... columnFamilies)
                                                                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### forceTableFlush

    public void forceTableFlush(java.lang.String tableName,
                                java.lang.String... columnFamilies)
                         throws java.io.IOException

  Flush all memtables for a table and column families.

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

### forceTableRepair

    public void forceTableRepair(java.lang.String tableName,
                                 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`

### getSuccessor

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

### getPrimaryRangeForEndPoint

    public Range 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> 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 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:
    `key` - - key for which we need to find the endpoint return value - the endpoint responsible for this key
    `table` - - key for which we need to find the endpoint return value - the endpoint responsible for this key

### getNaturalEndpoints

    public java.util.List<java.net.InetAddress> getNaturalEndpoints(java.lang.String table,
                                                                    Token token)

  This method returns the N endpoints that are responsible for storing the specified key i.e for replication.

  Parameters:
    `token` - - token for which we need to find the endpoint return value - the endpoint responsible for this token

### getLiveNaturalEndpoints

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

  This method attempts to return N endpoints that are responsible for storing the specified key i.e for replication.

  Parameters:
    `key` - - key for which we need to find the endpoint return value - the endpoint responsible for this key

### getLiveNaturalEndpoints

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

### findSuitableEndPoint

    public java.net.InetAddress findSuitableEndPoint(java.lang.String table,
                                                     java.lang.String key)
                                              throws java.io.IOException,
                                                     UnavailableException

  This function finds the closest live endpoint that contains a given key.

  Throws:
    `java.io.IOException`
    `UnavailableException`

### getStringEndpointMap

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

### 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(Range 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

  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`

### loadBalance

    public void loadBalance()
                     throws java.io.IOException,
                            java.lang.InterruptedException

  Description copied from interface: `StorageServiceMBean`
  This node will unload its data onto its neighbors, and bootstrap to share the range of the most-loaded node in the ring.

  Specified by:
    `loadBalance` in interface `StorageServiceMBean`
  Throws:
    `java.io.IOException`
    `java.lang.InterruptedException`

### removeToken

    public void removeToken(java.lang.String tokenString)

  Description copied from interface: `StorageServiceMBean`
  removeToken removes token (and all data associated with enpoint that had it) from the ring

  Specified by:
    `removeToken` in interface `StorageServiceMBean`

### getWriteResponseHandler

    public WriteResponseHandler getWriteResponseHandler(int blockFor,
                                                        ConsistencyLevel consistency_level,
                                                        java.lang.String table)

### 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`

### 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.

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

### saveCaches

    public void saveCaches()
                    throws java.util.concurrent.ExecutionException,
                           java.lang.InterruptedException

  Description copied from interface: `StorageServiceMBean`
  save row and key caches

  Specified by:
    `saveCaches` in interface `StorageServiceMBean`
  Throws:
    `java.util.concurrent.ExecutionException`
    `java.lang.InterruptedException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 The Apache Software Foundation