[ 
https://issues.apache.org/jira/browse/CASSANDRA-3220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13108050#comment-13108050
 ] 

Jackson Chung edited comment on CASSANDRA-3220 at 9/19/11 6:49 PM:
-------------------------------------------------------------------

i agree on all the points. I could use a help on what should be expected 
though. For instance, when "use keyspace" is issued without keyspace name, you 
get the similar output:

{noformat}
[default@Keyspace3] use keyspace;
Syntax error at position 4: mismatched input 'keyspace' expecting set null
{noformat}

The stacktrace is:
java.lang.RuntimeException: Syntax error at position 4: mismatched input 
'keyspace' expecting set null
        at 
org.apache.cassandra.cli.CliCompiler.compileQuery(CliCompiler.java:88)
        at 
org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:197)
        at 
org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:222)
        at org.apache.cassandra.cli.CliMain.main(CliMain.java:350)
Caused by: java.lang.RuntimeException: Syntax error at position 4: mismatched 
input 'keyspace' expecting set null
        at org.apache.cassandra.cli.CliParser.reportError(CliParser.java:197)
        at org.apache.cassandra.cli.CliParser.entityName(CliParser.java:7745)
        at org.apache.cassandra.cli.CliParser.keyspace(CliParser.java:7259)
        at org.apache.cassandra.cli.CliParser.useKeyspace(CliParser.java:5713)
        at org.apache.cassandra.cli.CliParser.statement(CliParser.java:528)
        at org.apache.cassandra.cli.CliParser.root(CliParser.java:229)
        at 
org.apache.cassandra.cli.CliCompiler.compileQuery(CliCompiler.java:79)

In any case. For this, I think I could use the "describe keyspace" pattern, 
which in the case where no keyspace is given, it ask you to use one first; and 
then if you are authenticated to one, and run describe ring without the 
keyspace name, describe the current one. Agree?

{noformat}
[default@unknown] describe;
Authenticate to a Keyspace, before using `describe` or `describe 
<column_family>`
[default@unknown] use Keyspace3;
Authenticated to keyspace: Keyspace3
[default@Keyspace3] describe;
Keyspace: Keyspace3:
  Replication Strategy: org.apache.cassandra.locator.SimpleStrategy
  Durable Writes: true
    Options: [replication_factor:4]
  Column Families:
    ColumnFamily: testcf
      Key Validation Class: org.apache.cassandra.db.marshal.BytesType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.BytesType
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Key cache size / save period in seconds: 100.0/14400
      GC grace seconds: 864000
      Compaction min/max thresholds: 4/32
      Read repair chance: 1.0
      Replicate on write: true
      Built indexes: []
      Compaction Strategy: 
org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
{noformat}


For using system, it error out because:
[default@system] describe ring system;
null
InvalidRequestException(why:There is no ring for the keyspace: system)
        at 
org.apache.cassandra.thrift.Cassandra$describe_ring_result.read(Cassandra.java:23267)
        at 
org.apache.cassandra.thrift.Cassandra$Client.recv_describe_ring(Cassandra.java:1262)
        at 
org.apache.cassandra.thrift.Cassandra$Client.describe_ring(Cassandra.java:1237)
        at 
org.apache.cassandra.cli.CliClient.executeDescribeRing(CliClient.java:1437)
        at 
org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:288)
        at 
org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:222)
        at org.apache.cassandra.cli.CliMain.main(CliMain.java:350)

It's probably because this keyspace uses internal strategy 
"org.apache.cassandra.locator.LocalStrategy"?  In any case, exception is thrown 
because in the CassandraServer.java:

{code}
public List<TokenRange> describe_ring(String keyspace)throws 
InvalidRequestException
    {
        if (keyspace == null || 
!Schema.instance.getNonSystemTables().contains(keyspace))
            throw new InvalidRequestException("There is no ring for the 
keyspace: " + keyspace);
{code}

So my option in the cli are either:
1) do what CassandraServer does: invalidate it if the keyspace given is a 
system table, make some pretty error
2) catch the invalidrequest exception, check if it is about "There is no 
ring"...  in the message, and error out with some pretty print.

(i don't like the 2nd option because the message is currently hardcoded within 
the CassandraServer. There is no enum or constant for message string to 
reference on.

I don't think the datacenter=null is part of the problem here. It looks to be 
another bug with the datacenter value not populated to the EndpointDetails. If 
anything, it is a bug from https://issues.apache.org/jira/browse/CASSANDRA-2882 
?

      was (Author: cywjackson):
    i agree on all the points. I could use a help on what should be expected 
though. For instance, when "use keyspace" is issued without keyspace name, you 
get the similar output:

{noformat}
[default@Keyspace3] use keyspace;
Syntax error at position 4: mismatched input 'keyspace' expecting set null
{noformat}

The stacktrace is:
java.lang.RuntimeException: Syntax error at position 4: mismatched input 
'keyspace' expecting set null
        at 
org.apache.cassandra.cli.CliCompiler.compileQuery(CliCompiler.java:88)
        at 
org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:197)
        at 
org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:222)
        at org.apache.cassandra.cli.CliMain.main(CliMain.java:350)
Caused by: java.lang.RuntimeException: Syntax error at position 4: mismatched 
input 'keyspace' expecting set null
        at org.apache.cassandra.cli.CliParser.reportError(CliParser.java:197)
        at org.apache.cassandra.cli.CliParser.entityName(CliParser.java:7745)
        at org.apache.cassandra.cli.CliParser.keyspace(CliParser.java:7259)
        at org.apache.cassandra.cli.CliParser.useKeyspace(CliParser.java:5713)
        at org.apache.cassandra.cli.CliParser.statement(CliParser.java:528)
        at org.apache.cassandra.cli.CliParser.root(CliParser.java:229)
        at 
org.apache.cassandra.cli.CliCompiler.compileQuery(CliCompiler.java:79)

In any case. For this, I think I could use the "describe keyspace" pattern, 
which in the case where no keyspace is given, it ask you to use one first; and 
then if you are authenticated to one, and run describe ring without the 
keyspace name, describe the current one. Agree?

{noformat}
[default@unknown] describe;
Authenticate to a Keyspace, before using `describe` or `describe 
<column_family>`
[default@unknown] use Keyspace3;
Authenticated to keyspace: Keyspace3
[default@Keyspace3] describe;
Keyspace: Keyspace3:
  Replication Strategy: org.apache.cassandra.locator.SimpleStrategy
  Durable Writes: true
    Options: [replication_factor:4]
  Column Families:
    ColumnFamily: testcf
      Key Validation Class: org.apache.cassandra.db.marshal.BytesType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.BytesType
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Key cache size / save period in seconds: 100.0/14400
      GC grace seconds: 864000
      Compaction min/max thresholds: 4/32
      Read repair chance: 1.0
      Replicate on write: true
      Built indexes: []
      Compaction Strategy: 
org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
{noformat}

agree?

For using system, it error out because:
[default@system] describe ring system;
null
InvalidRequestException(why:There is no ring for the keyspace: system)
        at 
org.apache.cassandra.thrift.Cassandra$describe_ring_result.read(Cassandra.java:23267)
        at 
org.apache.cassandra.thrift.Cassandra$Client.recv_describe_ring(Cassandra.java:1262)
        at 
org.apache.cassandra.thrift.Cassandra$Client.describe_ring(Cassandra.java:1237)
        at 
org.apache.cassandra.cli.CliClient.executeDescribeRing(CliClient.java:1437)
        at 
org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:288)
        at 
org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:222)
        at org.apache.cassandra.cli.CliMain.main(CliMain.java:350)

It's probably because this keyspace uses internal strategy 
"org.apache.cassandra.locator.LocalStrategy"?  In any case, exception is thrown 
because in the CassandraServer.java:

{code}
public List<TokenRange> describe_ring(String keyspace)throws 
InvalidRequestException
    {
        if (keyspace == null || 
!Schema.instance.getNonSystemTables().contains(keyspace))
            throw new InvalidRequestException("There is no ring for the 
keyspace: " + keyspace);
{code}

So my option in the cli are either:
1) do what CassandraServer does: invalidate it if the keyspace given is a 
system table, make some pretty error
2) catch the invalidrequest exception, check if it is about "There is no 
ring"...  in the message, and error out with some pretty print.

(i don't like the 2nd option because the message is currently hardcoded within 
the CassandraServer. There is no enum or constant for message string to 
reference on.

I don't think the datacenter=null is part of the problem here. It looks to be 
another bug with the datacenter value not populated to the EndpointDetails. If 
anything, it is a bug from https://issues.apache.org/jira/browse/CASSANDRA-2882 
?
  
> add describe_ring to cli
> ------------------------
>
>                 Key: CASSANDRA-3220
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-3220
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Tools
>            Reporter: Jackson Chung
>            Assignee: Jackson Chung
>            Priority: Minor
>             Fix For: 1.0.0
>
>         Attachments: patch3220.diff
>
>
> Lately I have found the describe_ring feature was needed to debug/analyze 
> issue, but the cli does not have this available.
> So just in case it is useful, please see the attached patch.
> here is the sample output:
> {noformat}
> [default@unknown] help;
> ...
> ...
> decr                    Decrements a counter column.
> describe ring           Describe the token range information.
> describe cluster        Describe the cluster configuration.
> ...
> ...
> [default@unknown] help describe ring;
> describe ring <keyspace>;
> Describes the token range settings for the named keyspace.
> Required Parameters:
> - keyspace: Name of the keyspace to describe the token range.
> Examples:
> describe ring <keyspace>; - Describes the token range settings for the named 
> keyspace.
> [default@unknown] describe ring Keyspace3;
> TokenRange: 
>         TokenRange(start_token:9739248273232290250409572410247679660, 
> end_token:9739248273232290250409572410247679660, endpoints:[192.168.0.125], 
> rpc_endpoints:[192.168.0.125], 
> endpoint_details:[EndpointDetails(host:192.168.0.125, port:9160, 
> datacenter:168)])
> [default@unknown] describe ring fooks;
> Keyspace with name 'fooks' wasn't found, , please, authorize to one of the 
> keyspaces first.
> [default@unknown] describe ring;
> Syntax error at position 13: mismatched input ';' expecting set null
> {noformat}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to