voldemort.tools.admin
Class AdminToolUtils

java.lang.Object
  extended by voldemort.tools.admin.AdminToolUtils

public class AdminToolUtils
extends java.lang.Object

Utility class for AdminCommand


Constructor Summary
AdminToolUtils()
           
 
Method Summary
static java.lang.Boolean askConfirm(java.lang.Boolean confirm, java.lang.String opDesc)
          Utility function that pauses and asks for confirmation on dangerous operations.
static void assertServerInNormalState(AdminClient adminClient)
          Utility function that checks the execution state of the server by checking the state of MetadataStore.VoldemortState
This function checks if all nodes of the cluster are in normal state ( MetadataStore.VoldemortState.NORMAL_SERVER).
static void assertServerInNormalState(AdminClient adminClient, java.util.Collection<java.lang.Integer> nodeIds)
          Utility function that checks the execution state of the server by checking the state of MetadataStore.VoldemortState
This function checks if the nodes are in normal state ( MetadataStore.VoldemortState.NORMAL_SERVER).
static void assertServerInNormalState(AdminClient adminClient, java.lang.Integer nodeId)
          Utility function that checks the execution state of the server by checking the state of MetadataStore.VoldemortState
This function checks if a node is in normal state ( MetadataStore.VoldemortState.NORMAL_SERVER).
static
<V> java.util.Map<V,V>
convertListToMap(java.util.List<V> list)
          Utility function that converts a list to a map.
static java.lang.String[] copyArrayAddFirst(java.lang.String[] arr, java.lang.String add)
          Utility function that copies a string array and add another string to first
static java.lang.String[] copyArrayCutFirst(java.lang.String[] arr)
          Utility function that copies a string array except for the first element
static java.io.File createDir(java.lang.String dir)
          Utility function that creates directory.
static AdminClient getAdminClient(java.lang.String url)
          Utility function that constructs AdminClient.
static java.util.List<java.lang.Integer> getAllNodeIds(AdminClient adminClient)
          Utility function that fetches node ids.
static java.util.List<java.lang.Integer> getAllPartitions(AdminClient adminClient)
          Utility function that fetches partitions.
static java.util.List<java.lang.String> getAllUserStoreNamesOnNode(AdminClient adminClient, java.lang.Integer nodeId)
          Utility function that fetches all stores on a node.
static java.util.List<java.lang.String> getQuotaTypes(java.util.List<java.lang.String> quotaTypes)
          Utility function that fetches quota types.
static java.util.Map<java.lang.String,StoreDefinition> getSystemStoreDefMap()
          Utility function that fetches system store definitions
static java.util.Map<java.lang.String,StoreDefinition> getUserStoreDefMapOnNode(AdminClient adminClient, java.lang.Integer nodeId)
          Utility function that fetches user defined store definitions
static java.util.List<java.lang.String> getValueList(java.util.List<java.lang.String> valuePairs, java.lang.String delim)
          Utility function that gives list of values from list of value-pair strings.
static void validateUserStoreNamesOnNode(AdminClient adminClient, java.lang.Integer nodeId, java.util.List<java.lang.String> storeNames)
          Utility function that checks if store names are valid on a node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdminToolUtils

public AdminToolUtils()
Method Detail

copyArrayCutFirst

public static java.lang.String[] copyArrayCutFirst(java.lang.String[] arr)
Utility function that copies a string array except for the first element

Parameters:
arr - Original array of strings
Returns:
Copied array of strings

copyArrayAddFirst

public static java.lang.String[] copyArrayAddFirst(java.lang.String[] arr,
                                                   java.lang.String add)
Utility function that copies a string array and add another string to first

Parameters:
arr - Original array of strings
add -
Returns:
Copied array of strings

askConfirm

public static java.lang.Boolean askConfirm(java.lang.Boolean confirm,
                                           java.lang.String opDesc)
                                    throws java.io.IOException
Utility function that pauses and asks for confirmation on dangerous operations.

Parameters:
confirm - User has already confirmed in command-line input
opDesc - Description of the dangerous operation
Returns:
True if user confirms the operation in either command-line input or here.
Throws:
java.io.IOException

getValueList

public static java.util.List<java.lang.String> getValueList(java.util.List<java.lang.String> valuePairs,
                                                            java.lang.String delim)
Utility function that gives list of values from list of value-pair strings.

Parameters:
valueList - List of value-pair strings
delim - Delimiter that separates the value pair

convertListToMap

public static <V> java.util.Map<V,V> convertListToMap(java.util.List<V> list)
Utility function that converts a list to a map.

Parameters:
list - The list in which even elements are keys and odd elements are values.

getAdminClient

public static AdminClient getAdminClient(java.lang.String url)
Utility function that constructs AdminClient.

Parameters:
url - URL pointing to the bootstrap node
Returns:
Newly constructed AdminClient

getAllNodeIds

public static java.util.List<java.lang.Integer> getAllNodeIds(AdminClient adminClient)
Utility function that fetches node ids.

Parameters:
adminClient - An instance of AdminClient points to given cluster
Returns:
Node ids in cluster

getAllUserStoreNamesOnNode

public static java.util.List<java.lang.String> getAllUserStoreNamesOnNode(AdminClient adminClient,
                                                                          java.lang.Integer nodeId)
Utility function that fetches all stores on a node.

Parameters:
adminClient - An instance of AdminClient points to given cluster
nodeId - Node id to fetch stores from
Returns:
List of all store names

validateUserStoreNamesOnNode

public static void validateUserStoreNamesOnNode(AdminClient adminClient,
                                                java.lang.Integer nodeId,
                                                java.util.List<java.lang.String> storeNames)
Utility function that checks if store names are valid on a node.

Parameters:
adminClient - An instance of AdminClient points to given cluster
nodeId - Node id to fetch stores from
storeNames - Store names to check

getAllPartitions

public static java.util.List<java.lang.Integer> getAllPartitions(AdminClient adminClient)
Utility function that fetches partitions.

Parameters:
adminClient - An instance of AdminClient points to given cluster
Returns:
all partitions on cluster

getQuotaTypes

public static java.util.List<java.lang.String> getQuotaTypes(java.util.List<java.lang.String> quotaTypes)
Utility function that fetches quota types.

Parameters:
nodeIds - List of IDs of nodes parsed from command-line input
allNodes - Tells if all nodes are selected
Returns:
Collection of node objects selected by user

createDir

public static java.io.File createDir(java.lang.String dir)
Utility function that creates directory.

Parameters:
dir - Directory path
Returns:
File object of directory.

getSystemStoreDefMap

public static java.util.Map<java.lang.String,StoreDefinition> getSystemStoreDefMap()
Utility function that fetches system store definitions

Returns:
The map container that maps store names to store definitions

getUserStoreDefMapOnNode

public static java.util.Map<java.lang.String,StoreDefinition> getUserStoreDefMapOnNode(AdminClient adminClient,
                                                                                       java.lang.Integer nodeId)
Utility function that fetches user defined store definitions

Parameters:
adminClient - An instance of AdminClient points to given cluster
nodeId - Node id to fetch store definitions from
Returns:
The map container that maps store names to store definitions

assertServerInNormalState

public static void assertServerInNormalState(AdminClient adminClient)
Utility function that checks the execution state of the server by checking the state of MetadataStore.VoldemortState
This function checks if all nodes of the cluster are in normal state ( MetadataStore.VoldemortState.NORMAL_SERVER).

Parameters:
adminClient - An instance of AdminClient points to given cluster
Throws:
VoldemortException - if any node is not in normal state

assertServerInNormalState

public static void assertServerInNormalState(AdminClient adminClient,
                                             java.lang.Integer nodeId)
Utility function that checks the execution state of the server by checking the state of MetadataStore.VoldemortState
This function checks if a node is in normal state ( MetadataStore.VoldemortState.NORMAL_SERVER).

Parameters:
adminClient - An instance of AdminClient points to given cluster
nodeId - Node id to be checked
Throws:
VoldemortException - if any node is not in normal state

assertServerInNormalState

public static void assertServerInNormalState(AdminClient adminClient,
                                             java.util.Collection<java.lang.Integer> nodeIds)
Utility function that checks the execution state of the server by checking the state of MetadataStore.VoldemortState
This function checks if the nodes are in normal state ( MetadataStore.VoldemortState.NORMAL_SERVER).

Parameters:
adminClient - An instance of AdminClient points to given cluster
nodeIds - List of node ids to be checked
Throws:
VoldemortException - if any node is not in normal state


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu