cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [09/10] cassandra git commit: Merge branch 'cassandra-2.1' into cassandra-2.2
Date Thu, 02 Jul 2015 20:09:36 GMT
Merge branch 'cassandra-2.1' into cassandra-2.2


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b73aa8e7
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b73aa8e7
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b73aa8e7

Branch: refs/heads/trunk
Commit: b73aa8e72c483a219b98d28287091538c1267f48
Parents: 492c65a ca40d11
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Jul 2 13:08:16 2015 -0700
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Jul 2 13:08:48 2015 -0700

----------------------------------------------------------------------
 CHANGES.txt                                          | 1 +
 src/java/org/apache/cassandra/db/SystemKeyspace.java | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b73aa8e7/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 4042722,ad5ed3d..745cacb
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -26,16 -6,15 +26,17 @@@ Merged from 2.1
   * Update internal python driver for cqlsh (CASSANDRA-9064)
   * Fix IndexOutOfBoundsException when inserting tuple with too many
     elements using the string literal notation (CASSANDRA-9559)
 - * Allow JMX over SSL directly from nodetool (CASSANDRA-9090)
 - * Fix incorrect result for IN queries where column not found (CASSANDRA-9540)
   * Enable describe on indices (CASSANDRA-7814)
 + * Fix incorrect result for IN queries where column not found (CASSANDRA-9540)
   * ColumnFamilyStore.selectAndReference may block during compaction (CASSANDRA-9637)
 + * Fix bug in cardinality check when compacting (CASSANDRA-9580)
 + * Fix memory leak in Ref due to ConcurrentLinkedQueue.remove() behaviour (CASSANDRA-9549)
 + * Make rebuild only run one at a time (CASSANDRA-9119)
  Merged from 2.0:
+  * Add listen_address to system.local (CASSANDRA-9603)
   * Bug fixes to resultset metadata construction (CASSANDRA-9636)
   * Fix setting 'durable_writes' in ALTER KEYSPACE (CASSANDRA-9560)
 - * Avoid ballot clash in Paxos (CASSANDRA-9649)
 + * Avoids ballot clash in Paxos (CASSANDRA-9649)
   * Improve trace messages for RR (CASSANDRA-9479)
   * Fix suboptimal secondary index selection when restricted
     clustering column is also indexed (CASSANDRA-9631)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b73aa8e7/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/SystemKeyspace.java
index 64d11f6,2185c6c..18af90f
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@@ -67,215 -66,33 +67,216 @@@ public final class SystemKeyspac
  {
      private static final Logger logger = LoggerFactory.getLogger(SystemKeyspace.class);
  
 -    // see CFMetaData for schema definitions
 -    public static final String PEERS_CF = "peers";
 -    public static final String PEER_EVENTS_CF = "peer_events";
 -    public static final String LOCAL_CF = "local";
 -    public static final String INDEX_CF = "IndexInfo";
 -    public static final String HINTS_CF = "hints";
 -    public static final String RANGE_XFERS_CF = "range_xfers";
 -    public static final String BATCHLOG_CF = "batchlog";
 -    // see layout description in the DefsTables class header
 -    public static final String SCHEMA_KEYSPACES_CF = "schema_keyspaces";
 -    public static final String SCHEMA_COLUMNFAMILIES_CF = "schema_columnfamilies";
 -    public static final String SCHEMA_COLUMNS_CF = "schema_columns";
 -    public static final String SCHEMA_TRIGGERS_CF = "schema_triggers";
 -    public static final String SCHEMA_USER_TYPES_CF = "schema_usertypes";
 -    public static final String COMPACTION_LOG = "compactions_in_progress";
 -    public static final String PAXOS_CF = "paxos";
 -    public static final String SSTABLE_ACTIVITY_CF = "sstable_activity";
 -    public static final String COMPACTION_HISTORY_CF = "compaction_history";
 -    public static final String SIZE_ESTIMATES_CF = "size_estimates";
 -
 -    private static final String LOCAL_KEY = "local";
 -
 -    public static final List<String> allSchemaCfs = Arrays.asList(SCHEMA_KEYSPACES_CF,
 -                                                                  SCHEMA_COLUMNFAMILIES_CF,
 -                                                                  SCHEMA_COLUMNS_CF,
 -                                                                  SCHEMA_TRIGGERS_CF,
 -                                                                  SCHEMA_USER_TYPES_CF);
 +    // Used to indicate that there was a previous version written to the legacy (pre 1.2)
 +    // system.Versions table, but that we cannot read it. Suffice to say, any upgrade should
 +    // proceed through 1.2.x before upgrading to the current version.
 +    public static final CassandraVersion UNREADABLE_VERSION = new CassandraVersion("0.0.0-unknown");
 +
 +    // Used to indicate that no previous version information was found. When encountered,
we assume that
 +    // Cassandra was not previously installed and we're in the process of starting a fresh
node.
 +    public static final CassandraVersion NULL_VERSION = new CassandraVersion("0.0.0-absent");
 +
 +    public static final String NAME = "system";
 +
 +    public static final String HINTS = "hints";
 +    public static final String BATCHLOG = "batchlog";
 +    public static final String PAXOS = "paxos";
 +    public static final String BUILT_INDEXES = "IndexInfo";
 +    public static final String LOCAL = "local";
 +    public static final String PEERS = "peers";
 +    public static final String PEER_EVENTS = "peer_events";
 +    public static final String RANGE_XFERS = "range_xfers";
 +    public static final String COMPACTIONS_IN_PROGRESS = "compactions_in_progress";
 +    public static final String COMPACTION_HISTORY = "compaction_history";
 +    public static final String SSTABLE_ACTIVITY = "sstable_activity";
 +    public static final String SIZE_ESTIMATES = "size_estimates";
 +    public static final String AVAILABLE_RANGES = "available_ranges";
 +
 +    public static final CFMetaData Hints =
 +        compile(HINTS,
 +                "hints awaiting delivery",
 +                "CREATE TABLE %s ("
 +                + "target_id uuid,"
 +                + "hint_id timeuuid,"
 +                + "message_version int,"
 +                + "mutation blob,"
 +                + "PRIMARY KEY ((target_id), hint_id, message_version)) "
 +                + "WITH COMPACT STORAGE")
 +                .compactionStrategyOptions(Collections.singletonMap("enabled", "false"))
 +                .gcGraceSeconds(0);
 +
 +    public static final CFMetaData Batchlog =
 +        compile(BATCHLOG,
 +                "batches awaiting replay",
 +                "CREATE TABLE %s ("
 +                + "id uuid,"
 +                + "data blob,"
 +                + "version int,"
 +                + "written_at timestamp,"
 +                + "PRIMARY KEY ((id)))")
 +                .compactionStrategyOptions(Collections.singletonMap("min_threshold", "2"))
 +                .gcGraceSeconds(0);
 +
 +    private static final CFMetaData Paxos =
 +        compile(PAXOS,
 +                "in-progress paxos proposals",
 +                "CREATE TABLE %s ("
 +                + "row_key blob,"
 +                + "cf_id UUID,"
 +                + "in_progress_ballot timeuuid,"
 +                + "most_recent_commit blob,"
 +                + "most_recent_commit_at timeuuid,"
 +                + "proposal blob,"
 +                + "proposal_ballot timeuuid,"
 +                + "PRIMARY KEY ((row_key), cf_id))")
 +                .compactionStrategyClass(LeveledCompactionStrategy.class);
 +
 +    // TODO: make private
 +    public static final CFMetaData BuiltIndexes =
 +        compile(BUILT_INDEXES,
 +                "built column indexes",
 +                "CREATE TABLE \"%s\" ("
 +                + "table_name text,"
 +                + "index_name text,"
 +                + "PRIMARY KEY ((table_name), index_name)) "
 +                + "WITH COMPACT STORAGE");
 +
 +    private static final CFMetaData Local =
 +        compile(LOCAL,
 +                "information about the local node",
 +                "CREATE TABLE %s ("
 +                + "key text,"
 +                + "bootstrapped text,"
 +                + "broadcast_address inet,"
 +                + "cluster_name text,"
 +                + "cql_version text,"
 +                + "data_center text,"
 +                + "gossip_generation int,"
 +                + "host_id uuid,"
++                + "listen_address inet,"
 +                + "native_protocol_version text,"
 +                + "partitioner text,"
 +                + "rack text,"
 +                + "release_version text,"
 +                + "rpc_address inet,"
 +                + "schema_version uuid,"
 +                + "thrift_version text,"
 +                + "tokens set<varchar>,"
 +                + "truncated_at map<uuid, blob>,"
 +                + "PRIMARY KEY ((key)))");
 +
 +    private static final CFMetaData Peers =
 +        compile(PEERS,
 +                "information about known peers in the cluster",
 +                "CREATE TABLE %s ("
 +                + "peer inet,"
 +                + "data_center text,"
 +                + "host_id uuid,"
 +                + "preferred_ip inet,"
 +                + "rack text,"
 +                + "release_version text,"
 +                + "rpc_address inet,"
 +                + "schema_version uuid,"
 +                + "tokens set<varchar>,"
 +                + "PRIMARY KEY ((peer)))");
 +
 +    private static final CFMetaData PeerEvents =
 +        compile(PEER_EVENTS,
 +                "events related to peers",
 +                "CREATE TABLE %s ("
 +                + "peer inet,"
 +                + "hints_dropped map<uuid, int>,"
 +                + "PRIMARY KEY ((peer)))");
 +
 +    private static final CFMetaData RangeXfers =
 +        compile(RANGE_XFERS,
 +                "ranges requested for transfer",
 +                "CREATE TABLE %s ("
 +                + "token_bytes blob,"
 +                + "requested_at timestamp,"
 +                + "PRIMARY KEY ((token_bytes)))");
 +
 +    private static final CFMetaData CompactionsInProgress =
 +        compile(COMPACTIONS_IN_PROGRESS,
 +                "unfinished compactions",
 +                "CREATE TABLE %s ("
 +                + "id uuid,"
 +                + "columnfamily_name text,"
 +                + "inputs set<int>,"
 +                + "keyspace_name text,"
 +                + "PRIMARY KEY ((id)))");
 +
 +    private static final CFMetaData CompactionHistory =
 +        compile(COMPACTION_HISTORY,
 +                "week-long compaction history",
 +                "CREATE TABLE %s ("
 +                + "id uuid,"
 +                + "bytes_in bigint,"
 +                + "bytes_out bigint,"
 +                + "columnfamily_name text,"
 +                + "compacted_at timestamp,"
 +                + "keyspace_name text,"
 +                + "rows_merged map<int, bigint>,"
 +                + "PRIMARY KEY ((id)))")
 +                .defaultTimeToLive((int) TimeUnit.DAYS.toSeconds(7));
 +
 +    private static final CFMetaData SSTableActivity =
 +        compile(SSTABLE_ACTIVITY,
 +                "historic sstable read rates",
 +                "CREATE TABLE %s ("
 +                + "keyspace_name text,"
 +                + "columnfamily_name text,"
 +                + "generation int,"
 +                + "rate_120m double,"
 +                + "rate_15m double,"
 +                + "PRIMARY KEY ((keyspace_name, columnfamily_name, generation)))");
 +
 +    private static final CFMetaData SizeEstimates =
 +        compile(SIZE_ESTIMATES,
 +                "per-table primary range size estimates",
 +                "CREATE TABLE %s ("
 +                + "keyspace_name text,"
 +                + "table_name text,"
 +                + "range_start text,"
 +                + "range_end text,"
 +                + "mean_partition_size bigint,"
 +                + "partitions_count bigint,"
 +                + "PRIMARY KEY ((keyspace_name), table_name, range_start, range_end))")
 +                .gcGraceSeconds(0);
 +
 +    private static final CFMetaData AvailableRanges =
 +        compile(AVAILABLE_RANGES,
 +                "Available keyspace/ranges during bootstrap/replace that are ready to be
served",
 +                "CREATE TABLE %s ("
 +                        + "keyspace_name text PRIMARY KEY,"
 +                        + "ranges set<blob>"
 +                        + ")");
 +
 +    private static CFMetaData compile(String name, String description, String schema)
 +    {
 +        return CFMetaData.compile(String.format(schema, name), NAME)
 +                         .comment(description);
 +    }
 +
 +    public static KSMetaData definition()
 +    {
 +        Iterable<CFMetaData> tables =
 +            Iterables.concat(LegacySchemaTables.All,
 +                             Arrays.asList(BuiltIndexes,
 +                                           Hints,
 +                                           Batchlog,
 +                                           Paxos,
 +                                           Local,
 +                                           Peers,
 +                                           PeerEvents,
 +                                           RangeXfers,
 +                                           CompactionsInProgress,
 +                                           CompactionHistory,
 +                                           SSTableActivity,
 +                                           SizeEstimates,
 +                                           AvailableRanges));
 +        return new KSMetaData(NAME, LocalStrategy.class, Collections.<String, String>emptyMap(),
true, tables);
 +    }
  
      private static volatile Map<UUID, Pair<ReplayPosition, Long>> truncationRecords;
  
@@@ -293,29 -110,37 +294,30 @@@
  
      public static void finishStartup()
      {
 -        setupVersion();
 -
 -        migrateIndexInterval();
 -        migrateCachingOption();
 -        // add entries to system schema columnfamilies for the hardcoded system definitions
 -        KSMetaData ksmd = Schema.instance.getKSMetaData(Keyspace.SYSTEM_KS);
 -
 -        long timestamp = FBUtilities.timestampMicros();
 -
 -        // delete old, possibly obsolete entries in schema columnfamilies
 -        for (String cfname : Arrays.asList(SystemKeyspace.SCHEMA_KEYSPACES_CF,
 -                                           SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF,
 -                                           SystemKeyspace.SCHEMA_COLUMNS_CF,
 -                                           SystemKeyspace.SCHEMA_TRIGGERS_CF,
 -                                           SystemKeyspace.SCHEMA_USER_TYPES_CF))
 -        {
 -            executeOnceInternal(String.format("DELETE FROM system.%s USING TIMESTAMP ? WHERE
keyspace_name = ?", cfname),
 -                                timestamp,
 -                                ksmd.name);
 -        }
 -
 -        // (+1 to timestamp to make sure we don't get shadowed by the tombstones we just
added)
 -        ksmd.toSchema(timestamp + 1).apply();
 -    }
 -
 -    private static void setupVersion()
 -    {
 -        String req = "INSERT INTO system.%s (key, release_version, cql_version, thrift_version,
native_protocol_version, data_center, rack, partitioner, rpc_address, broadcast_address, listen_address)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
 +        persistLocalMetadata();
 +        LegacySchemaTables.saveSystemKeyspaceSchema();
 +    }
 +
 +    private static void persistLocalMetadata()
 +    {
 +        String req = "INSERT INTO system.%s (" +
 +                     "key," +
 +                     "cluster_name," +
 +                     "release_version," +
 +                     "cql_version," +
 +                     "thrift_version," +
 +                     "native_protocol_version," +
 +                     "data_center," +
 +                     "rack," +
 +                     "partitioner," +
 +                     "rpc_address," +
-                      "broadcast_address" +
-                      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
++                     "broadcast_address," +
++                     "listen_address" +
++                     ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
          IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
 -        executeOnceInternal(String.format(req, LOCAL_CF),
 -                            LOCAL_KEY,
 +        executeOnceInternal(String.format(req, LOCAL),
 +                            LOCAL,
 +                            DatabaseDescriptor.getClusterName(),
                              FBUtilities.getReleaseVersionString(),
                              QueryProcessor.CQL_VERSION.toString(),
                              cassandraConstants.VERSION,
@@@ -324,9 -149,60 +326,10 @@@
                              snitch.getRack(FBUtilities.getBroadcastAddress()),
                              DatabaseDescriptor.getPartitioner().getClass().getName(),
                              DatabaseDescriptor.getRpcAddress(),
-                             FBUtilities.getBroadcastAddress());
+                             FBUtilities.getBroadcastAddress(),
+                             FBUtilities.getLocalAddress());
      }
  
 -    // TODO: In 3.0, remove this and the index_interval column from system.schema_columnfamilies
 -    /** Migrates index_interval values to min_index_interval and sets index_interval to
null */
 -    private static void migrateIndexInterval()
 -    {
 -        for (UntypedResultSet.Row row : executeOnceInternal(String.format("SELECT * FROM
system.%s", SCHEMA_COLUMNFAMILIES_CF)))
 -        {
 -            if (!row.has("index_interval"))
 -                continue;
 -
 -            logger.debug("Migrating index_interval to min_index_interval");
 -
 -            CFMetaData table = CFMetaData.fromSchema(row);
 -            String query = String.format("SELECT writetime(type) FROM system.%s WHERE keyspace_name
= ? AND columnfamily_name = ?", SCHEMA_COLUMNFAMILIES_CF);
 -            long timestamp = executeOnceInternal(query, table.ksName, table.cfName).one().getLong("writetime(type)");
 -            try
 -            {
 -                table.toSchema(timestamp).apply();
 -            }
 -            catch (ConfigurationException e)
 -            {
 -                // shouldn't happen
 -            }
 -        }
 -    }
 -
 -    private static void migrateCachingOption()
 -    {
 -        for (UntypedResultSet.Row row : executeOnceInternal(String.format("SELECT * FROM
system.%s", SCHEMA_COLUMNFAMILIES_CF)))
 -        {
 -            if (!row.has("caching"))
 -                continue;
 -
 -            if (!CachingOptions.isLegacy(row.getString("caching")))
 -                continue;
 -            try
 -            {
 -                CachingOptions caching = CachingOptions.fromString(row.getString("caching"));
 -                CFMetaData table = CFMetaData.fromSchema(row);
 -                logger.info("Migrating caching option {} to {} for {}.{}", row.getString("caching"),
caching.toString(), table.ksName, table.cfName);
 -                String query = String.format("SELECT writetime(type) FROM system.%s WHERE
keyspace_name = ? AND columnfamily_name = ?", SCHEMA_COLUMNFAMILIES_CF);
 -                long timestamp = executeOnceInternal(query, table.ksName, table.cfName).one().getLong("writetime(type)");
 -                table.toSchema(timestamp).apply();
 -            }
 -            catch (ConfigurationException e)
 -            {
 -                // shouldn't happen
 -            }
 -        }
 -    }
 -
      /**
       * Write compaction log, except columfamilies under system keyspace.
       *


Mime
View raw message