mirror of https://github.com/apache/cassandra
add cli 'describe cluster' command
patch by Pavel Yaskevich; reviewed by thobbs for CASSANDRA-2127 git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1069206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e10d3475fd
commit
a6fa41e5f1
|
|
@ -36,6 +36,7 @@ tokens {
|
|||
//
|
||||
NODE_CONNECT;
|
||||
NODE_DESCRIBE_TABLE;
|
||||
NODE_DESCRIBE_CLUSTER;
|
||||
NODE_USE_TABLE;
|
||||
NODE_EXIT;
|
||||
NODE_HELP;
|
||||
|
|
@ -138,6 +139,7 @@ statement
|
|||
| exitStatement
|
||||
| countStatement
|
||||
| describeTable
|
||||
| describeCluster
|
||||
| addKeyspace
|
||||
| addColumnFamily
|
||||
| updateKeyspace
|
||||
|
|
@ -172,6 +174,8 @@ helpStatement
|
|||
-> ^(NODE_HELP NODE_USE_TABLE)
|
||||
| HELP DESCRIBE KEYSPACE
|
||||
-> ^(NODE_HELP NODE_DESCRIBE_TABLE)
|
||||
| HELP DESCRIBE 'CLUSTER'
|
||||
-> ^(NODE_HELP NODE_DESCRIBE_CLUSTER)
|
||||
| HELP EXIT
|
||||
-> ^(NODE_HELP NODE_EXIT)
|
||||
| HELP QUIT
|
||||
|
|
@ -325,6 +329,11 @@ describeTable
|
|||
-> ^(NODE_DESCRIBE_TABLE (keyspace)?)
|
||||
;
|
||||
|
||||
describeCluster
|
||||
: DESCRIBE 'CLUSTER'
|
||||
-> ^(NODE_DESCRIBE_CLUSTER)
|
||||
;
|
||||
|
||||
useKeyspace
|
||||
: USE keyspace ( username )? ( password )?
|
||||
-> ^(NODE_USE_TABLE keyspace ( username )? ( password )?)
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ public class CliClient extends CliUserHelp
|
|||
case CliParser.NODE_DESCRIBE_TABLE:
|
||||
executeDescribeKeySpace(tree);
|
||||
break;
|
||||
case CliParser.NODE_DESCRIBE_CLUSTER:
|
||||
executeDescribeCluster();
|
||||
break;
|
||||
case CliParser.NODE_USE_TABLE:
|
||||
executeUseKeySpace(tree);
|
||||
break;
|
||||
|
|
@ -1385,6 +1388,33 @@ public class CliClient extends CliUserHelp
|
|||
describeKeySpace(keySpaceName, null);
|
||||
}
|
||||
|
||||
// ^(NODE_DESCRIBE_CLUSTER) or describe: schema_versions, partitioner, snitch
|
||||
private void executeDescribeCluster()
|
||||
{
|
||||
if (!CliMain.isConnected())
|
||||
return;
|
||||
|
||||
sessionState.out.println("Cluster Information:");
|
||||
try
|
||||
{
|
||||
sessionState.out.println(" Snitch: " + thriftClient.describe_snitch());
|
||||
sessionState.out.println(" Partitioner: " + thriftClient.describe_partitioner());
|
||||
|
||||
sessionState.out.println(" Schema versions: ");
|
||||
Map<String,List<String>> versions = thriftClient.describe_schema_versions();
|
||||
|
||||
for (String version : versions.keySet())
|
||||
{
|
||||
sessionState.out.println("\t" + version + ": " + versions.get(version));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
String message = (e instanceof InvalidRequestException) ? ((InvalidRequestException) e).getWhy() : e.getMessage();
|
||||
sessionState.err.println("Error retrieving data: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
// process a statement of the form: connect hostname/port
|
||||
private void executeConnect(Tree statement)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ public class CliUserHelp {
|
|||
state.out.println("describe keyspace system;");
|
||||
break;
|
||||
|
||||
case CliParser.NODE_DESCRIBE_CLUSTER:
|
||||
state.out.println("describe cluster;\n");
|
||||
state.out.println("Display information about cluster: snitch, partitioner, schema versions.");
|
||||
break;
|
||||
|
||||
case CliParser.NODE_EXIT:
|
||||
state.out.println("exit;");
|
||||
state.out.println("quit;\n");
|
||||
|
|
@ -337,6 +342,7 @@ public class CliUserHelp {
|
|||
state.out.println("describe keyspace (<keyspacename>)?; Describe keyspace.");
|
||||
state.out.println("exit; Exit CLI.");
|
||||
state.out.println("quit; Exit CLI.");
|
||||
state.out.println("describe cluster; Display information about cluster.");
|
||||
state.out.println("show cluster name; Display cluster name.");
|
||||
state.out.println("show keyspaces; Show list of keyspaces.");
|
||||
state.out.println("show api version; Show server API version.");
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ public class CliTest extends CleanupHelper
|
|||
"set myCF['key']['scName']['firstname'] = 'John';",
|
||||
"get myCF['key']['scName']",
|
||||
"use TestKEYSpace;",
|
||||
"describe cluster;",
|
||||
"help describe cluster;",
|
||||
"show cluster name",
|
||||
"show api version",
|
||||
"help help",
|
||||
|
|
|
|||
Loading…
Reference in New Issue