org.apache.cassandra.tools

## Class Shuffle

- java.lang.Object
- - org.apache.cassandra.tools.AbstractJmxClient
  - - org.apache.cassandra.tools.Shuffle

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

      public class Shuffle
      extends AbstractJmxClient

- - ### Field Summary

    - ### Fields inherited from class org.apache.cassandra.tools.AbstractJmxClient

      `DEFAULT_HOST, DEFAULT_JMX_PORT, host, jmxConn, out, password, port, username`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Shuffle(java.lang.String host, int port)`
    `Shuffle(java.lang.String host, int port, java.lang.String thriftHost, int thriftPort, boolean thriftFramed, java.lang.String username, java.lang.String password)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.google.common.collect.Multimap<java.lang.String,java.lang.String>` | `calculateRelocations(com.google.common.collect.Multimap<java.lang.String,java.lang.String> endpointMap)` Given a Multimap of endpoint to tokens, return a new randomized mapping.
    `void` | `clear()` Clear pending token relocations on all nodes.
    `static java.lang.String` | `createShuffleBatchInsert(java.util.Collection<java.lang.String> tokens, IPartitioner<?> partitioner)` Create and return a CQL batch insert statement for a set of token relocations.
    `void` | `disable()` Disable shuffling on all nodes in the cluster.
    `void` | `disableRelocations(java.util.Collection<java.lang.String> endpoints)` Disable relocations.
    `void` | `disableRelocations(java.lang.String... endpoints)` Disable relocations.
    `void` | `enable()` Enable shuffling on all nodes in the cluster.
    `void` | `enableRelocations(java.util.Collection<java.lang.String> endpoints)` Enable relocations.
    `void` | `enableRelocations(java.lang.String... endpoints)` Enable relocations.
    `static CqlResult` | `executeCqlQuery(java.lang.String hostName, int port, boolean isFramed, java.lang.String cqlQuery)` Execute a CQL v3 query.
    `EndpointSnitchInfoMBean` | `getEpSnitchProxy(javax.management.MBeanServerConnection mbeanConn)`
    `java.util.Collection<java.lang.String>` | `getLiveNodes()` Return a list of the live nodes (using JMX).
    `static IPartitioner<?>` | `getPartitioner(java.lang.String hostName, int port, boolean framed)` Return a partitioner instance for remote host.
    `StorageServiceMBean` | `getSSProxy(javax.management.MBeanServerConnection mbeanConn)`
    `static org.apache.cassandra.tools.CassandraClient` | `getThriftClient(java.lang.String hostName, int port, boolean framed)` Setup and return a new Thrift RPC connection.
    `void` | `ls()` Print a list of pending token relocations for all nodes.
    `static void` | `main(java.lang.String[] args)` Execute.
    `void` | `shuffle(boolean enable, java.lang.String onlyDc)` Create and distribute a new, randomized token to endpoint mapping.

    - ### Methods inherited from class org.apache.cassandra.tools.AbstractJmxClient

      `addCmdOption, close, printHelp, processArguments, setOutput, write, write, writeln, writeln, writeln`

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

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

- - ### Constructor Detail

    - #### Shuffle

          public Shuffle(java.lang.String host,
                 int port)
                  throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### Shuffle

          public Shuffle(java.lang.String host,
                 int port,
                 java.lang.String thriftHost,
                 int thriftPort,
                 boolean thriftFramed,
                 java.lang.String username,
                 java.lang.String password)
                  throws java.io.IOException

      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### getSSProxy

          public StorageServiceMBean getSSProxy(javax.management.MBeanServerConnection mbeanConn)

    - #### getEpSnitchProxy

          public EndpointSnitchInfoMBean getEpSnitchProxy(javax.management.MBeanServerConnection mbeanConn)

    - #### calculateRelocations

          public com.google.common.collect.Multimap<java.lang.String,java.lang.String> calculateRelocations(com.google.common.collect.Multimap<java.lang.String,java.lang.String> endpointMap)

      Given a Multimap of endpoint to tokens, return a new randomized mapping.
      Parameters:
        `endpointMap` - current mapping of endpoint to tokens
      Returns:
        a new mapping of endpoint to tokens

    - #### enableRelocations

          public void enableRelocations(java.lang.String... endpoints)

      Enable relocations.
      Parameters:
        `endpoints` - sequence of hostname or IP strings

    - #### enableRelocations

          public void enableRelocations(java.util.Collection<java.lang.String> endpoints)

      Enable relocations.
      Parameters:
        `endpoints` - Collection of hostname or IP strings

    - #### disableRelocations

          public void disableRelocations(java.lang.String... endpoints)

      Disable relocations.
      Parameters:
        `endpoints` - sequence of hostname or IP strings

    - #### disableRelocations

          public void disableRelocations(java.util.Collection<java.lang.String> endpoints)

      Disable relocations.
      Parameters:
        `endpoints` - Collection of hostname or IP strings

    - #### getLiveNodes

          public java.util.Collection<java.lang.String> getLiveNodes()
                                                              throws org.apache.cassandra.tools.ShuffleError

      Return a list of the live nodes (using JMX).
      Returns:
        String endpoint names
      Throws:
        `org.apache.cassandra.tools.ShuffleError`

    - #### shuffle

          public void shuffle(boolean enable,
                     java.lang.String onlyDc)
                       throws org.apache.cassandra.tools.ShuffleError

      Create and distribute a new, randomized token to endpoint mapping.
      Throws:
        `org.apache.cassandra.tools.ShuffleError` - on handled exceptions

    - #### ls

          public void ls()
                  throws org.apache.cassandra.tools.ShuffleError

      Print a list of pending token relocations for all nodes.
      Throws:
        `org.apache.cassandra.tools.ShuffleError`

    - #### clear

          public void clear()
                     throws org.apache.cassandra.tools.ShuffleError

      Clear pending token relocations on all nodes.
      Throws:
        `org.apache.cassandra.tools.ShuffleError`

    - #### enable

          public void enable()
                      throws org.apache.cassandra.tools.ShuffleError

      Enable shuffling on all nodes in the cluster.
      Throws:
        `org.apache.cassandra.tools.ShuffleError`

    - #### disable

          public void disable()
                       throws org.apache.cassandra.tools.ShuffleError

      Disable shuffling on all nodes in the cluster.
      Throws:
        `org.apache.cassandra.tools.ShuffleError`

    - #### getThriftClient

          public static org.apache.cassandra.tools.CassandraClient getThriftClient(java.lang.String hostName,
                                                                   int port,
                                                                   boolean framed)
                                                                            throws org.apache.cassandra.tools.ShuffleError

      Setup and return a new Thrift RPC connection.
      Parameters:
        `hostName` - hostname or address to connect to
        `port` - port number to connect to
        `framed` - wrap with framed transport if true
      Returns:
        a CassandraClient instance
      Throws:
        `org.apache.cassandra.tools.ShuffleError`

    - #### executeCqlQuery

          public static CqlResult executeCqlQuery(java.lang.String hostName,
                                  int port,
                                  boolean isFramed,
                                  java.lang.String cqlQuery)
                                           throws org.apache.cassandra.tools.ShuffleError

      Execute a CQL v3 query.
      Parameters:
        `hostName` - hostname or address to connect to
        `port` - port number to connect to
        `isFramed` - wrap with framed transport if true
        `cqlQuery` - CQL query string
      Returns:
        a Thrift CqlResult instance
      Throws:
        `org.apache.cassandra.tools.ShuffleError`

    - #### getPartitioner

          public static IPartitioner<?> getPartitioner(java.lang.String hostName,
                                       int port,
                                       boolean framed)
                                                throws org.apache.cassandra.tools.ShuffleError

      Return a partitioner instance for remote host.
      Parameters:
        `hostName` - hostname or address to connect to
        `port` - port number to connect to
        `framed` - wrap with framed transport if true
      Returns:
        an IPartitioner instance
      Throws:
        `org.apache.cassandra.tools.ShuffleError`

    - #### createShuffleBatchInsert

          public static java.lang.String createShuffleBatchInsert(java.util.Collection<java.lang.String> tokens,
                                                  IPartitioner<?> partitioner)

      Create and return a CQL batch insert statement for a set of token relocations.
      Parameters:
        `tokens` - tokens to be relocated
        `partitioner` - an instance of the IPartitioner in use
      Returns:
        a query string

    - #### main

          public static void main(java.lang.String[] args)
                           throws java.lang.Exception

      Execute.
      Parameters:
        `args` - arguments passed on the command line
      Throws:
        `java.lang.Exception` - when face meets palm

Copyright © 2014 The Apache Software Foundation