From 83119656a2f54db064ec1479eddb826d8fcaf7de Mon Sep 17 00:00:00 2001 From: Vijay Parthasarathy Date: Thu, 19 Jan 2012 13:04:21 -0800 Subject: [PATCH 1/3] 0001-CASSANDRA-3736-remove-token-from-systable-when-replaced --- src/java/org/apache/cassandra/db/SystemTable.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/java/org/apache/cassandra/db/SystemTable.java b/src/java/org/apache/cassandra/db/SystemTable.java index 8f1adfc91c..c831382f40 100644 --- a/src/java/org/apache/cassandra/db/SystemTable.java +++ b/src/java/org/apache/cassandra/db/SystemTable.java @@ -139,7 +139,10 @@ public class SystemTable public static synchronized void updateToken(InetAddress ep, Token token) { if (ep == FBUtilities.getLocalAddress()) + { + removeToken(token); return; + } IPartitioner p = StorageService.getPartitioner(); ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_TABLE, STATUS_CF); cf.addColumn(new Column(p.getTokenFactory().toByteArray(token), ByteBuffer.wrap(ep.getAddress()), System.currentTimeMillis())); From 95942f0221240e47e950a387a440b4dbe7dada65 Mon Sep 17 00:00:00 2001 From: paul cannon Date: Thu, 19 Jan 2012 14:23:56 -0600 Subject: [PATCH 2/3] cqlsh: add DESC COLUMNFAMILIES to show cf names as opposed to DESCRIBE KEYSPACE, which shows all columnfamilies but includes all their column definitions and options, which is usually a lot of output. patch by pcannon; reviewed by jbellis for CASSANDRA-3586 --- CHANGES.txt | 4 ++++ bin/cqlsh | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index d3919d7e66..4688381d0f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +1.0.8 + * (cqlsh) add DESCRIBE COLUMNFAMILIES (CASSANDRA-3586) + + 1.0.7 * fix regression in HH page size calculation (CASSANDRA-3624) * retry failed stream on IOException (CASSANDRA-3686) diff --git a/bin/cqlsh b/bin/cqlsh index 0f02a0c836..8fe044c069 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -136,6 +136,7 @@ cqlhandling.CqlRuleSet.append_rules(r''' ::= "DESCRIBE" ( "KEYSPACE" ksname=? | "COLUMNFAMILY" cfname= + | "COLUMNFAMILIES" | "SCHEMA" | "CLUSTER" ) ; @@ -205,6 +206,9 @@ def complete_assume_col(ctxt, cqlsh): class NoKeyspaceError(Exception): pass +class KeyspaceNotFound(Exception): + pass + def trim_if_present(s, prefix): if s.startswith(prefix): return s[len(prefix):] @@ -697,6 +701,22 @@ class Shell(cmd.Cmd): self.print_recreate_columnfamily(self.get_columnfamily(cfname)) self.printout('') + def describe_columnfamilies(self, ksname): + if ksname is None: + for k in self.get_keyspaces(): + self.printout('Keyspace %s' % (k.name,)) + self.printout('---------%s\n' % ('-' * len(k.name))) + cmd.Cmd.columnize(self, [c.name for c in k.cf_defs]) + self.printout('') + else: + try: + names = self.get_columnfamily_names(ksname) + except cql.cassandra.ttypes.NotFoundException: + raise KeyspaceNotFound('Keyspace %s not found.' % (ksname,)) + self.printout('') + cmd.Cmd.columnize(self, names) + self.printout('') + def describe_cluster(self): self.printout('Cluster: %s' % self.get_cluster_name()) p = trim_if_present(self.get_partitioner(), 'org.apache.cassandra.dht.') @@ -724,7 +744,7 @@ class Shell(cmd.Cmd): Outputs information about the connected Cassandra cluster, or about the data stored on it. Use in one of the following ways: - DESCRIBE KEYSPACE + DESCRIBE KEYSPACE [] Output CQL commands that could be used to recreate the given keyspace, and the columnfamilies in it. In some cases, as the CQL @@ -734,6 +754,11 @@ class Shell(cmd.Cmd): The '' argument may be omitted when using a non-system keyspace; in that case, the current keyspace will be described. + DESCRIBE COLUMNFAMILIES + + Output the names of all column families in the current keyspace, or + in all keyspaces if there is no current keyspace. + DESCRIBE COLUMNFAMILY Output CQL commands that could be used to recreate the given @@ -766,6 +791,8 @@ class Shell(cmd.Cmd): elif what == 'columnfamily': cfname = cql_dequote(parsed.get_binding('cfname')) self.describe_columnfamily(cfname) + elif what == 'columnfamilies': + self.describe_columnfamilies(self.current_keyspace) elif what == 'cluster': self.describe_cluster() elif what == 'schema': From fc6103966cbe90c96e75f4b52c10376b9df468d7 Mon Sep 17 00:00:00 2001 From: paul cannon Date: Thu, 19 Jan 2012 12:02:13 -0600 Subject: [PATCH 3/3] add DESC alias for DESCRIBE patch by pcannon; reviewed by jbellis for CASSANDRA-3587 --- bin/cqlsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/cqlsh b/bin/cqlsh index 8fe044c069..2a18722437 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -116,6 +116,7 @@ cqlhandling.commands_end_with_newline.update(( 'help', '?', 'describe', + 'desc', 'show', 'assume', 'eof', @@ -134,7 +135,7 @@ cqlhandling.CqlRuleSet.append_rules(r''' | ; - ::= "DESCRIBE" ( "KEYSPACE" ksname=? + ::= ( "DESCRIBE" | "DESC" ) ( "KEYSPACE" ksname=? | "COLUMNFAMILY" cfname= | "COLUMNFAMILIES" | "SCHEMA" @@ -741,6 +742,8 @@ class Shell(cmd.Cmd): """ DESCRIBE [cqlsh only] + (DESC may be used as a shorthand.) + Outputs information about the connected Cassandra cluster, or about the data stored on it. Use in one of the following ways: @@ -798,6 +801,8 @@ class Shell(cmd.Cmd): elif what == 'schema': self.describe_schema() + do_desc = do_describe + def do_show(self, parsed): """ SHOW [cqlsh only]