cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [2/2] cassandra git commit: Merge branch 'cassandra-2.1' into trunk
Date Thu, 05 Feb 2015 13:30:57 GMT
Merge branch 'cassandra-2.1' into trunk

Conflicts:
	src/java/org/apache/cassandra/config/CFMetaData.java
	src/java/org/apache/cassandra/config/KSMetaData.java
	src/java/org/apache/cassandra/db/SystemKeyspace.java


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

Branch: refs/heads/trunk
Commit: e70959dea475928c8d87eea68b9fafb7a5ea0b62
Parents: 0fa19b7 e60089d
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Feb 5 16:30:47 2015 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Feb 5 16:30:47 2015 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../cassandra/db/SizeEstimatesRecorder.java     | 124 +++++++++++++++++++
 .../org/apache/cassandra/db/SystemKeyspace.java |  56 ++++++++-
 .../cassandra/service/CassandraDaemon.java      |  12 +-
 4 files changed, 186 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e70959de/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 61c57a3,959a2de..0aba61a
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,63 -1,5 +1,64 @@@
 +3.0
 + * Avoid accessing partitioner through StorageProxy (CASSANDRA-8244, 8268)
 + * Upgrade Metrics library and remove depricated metrics (CASSANDRA-5657)
 + * Serializing Row cache alternative, fully off heap (CASSANDRA-7438)
 + * Duplicate rows returned when in clause has repeated values (CASSANDRA-6707)
 + * Make CassandraException unchecked, extend RuntimeException (CASSANDRA-8560)
 + * Support direct buffer decompression for reads (CASSANDRA-8464)
 + * DirectByteBuffer compatible LZ4 methods (CASSANDRA-7039)
 + * Add role based access control (CASSANDRA-7653)
 + * Group sstables for anticompaction correctly (CASSANDRA-8578)
 + * Add ReadFailureException to native protocol, respond
 +   immediately when replicas encounter errors while handling
 +   a read request (CASSANDRA-7886)
 + * Switch CommitLogSegment from RandomAccessFile to nio (CASSANDRA-8308)
 + * Allow mixing token and partition key restrictions (CASSANDRA-7016)
 + * Support index key/value entries on map collections (CASSANDRA-8473)
 + * Modernize schema tables (CASSANDRA-8261)
 + * Support for user-defined aggregation functions (CASSANDRA-8053)
 + * Fix NPE in SelectStatement with empty IN values (CASSANDRA-8419)
 + * Refactor SelectStatement, return IN results in natural order instead
 +   of IN value list order and ignore duplicate values in partition key IN restrictions (CASSANDRA-7981)
 + * Support UDTs, tuples, and collections in user-defined
 +   functions (CASSANDRA-7563)
 + * Fix aggregate fn results on empty selection, result column name,
 +   and cqlsh parsing (CASSANDRA-8229)
 + * Mark sstables as repaired after full repair (CASSANDRA-7586)
 + * Extend Descriptor to include a format value and refactor reader/writer
 +   APIs (CASSANDRA-7443)
 + * Integrate JMH for microbenchmarks (CASSANDRA-8151)
 + * Keep sstable levels when bootstrapping (CASSANDRA-7460)
 + * Add Sigar library and perform basic OS settings check on startup (CASSANDRA-7838)
 + * Support for aggregation functions (CASSANDRA-4914)
 + * Remove cassandra-cli (CASSANDRA-7920)
 + * Accept dollar quoted strings in CQL (CASSANDRA-7769)
 + * Make assassinate a first class command (CASSANDRA-7935)
 + * Support IN clause on any partition key column (CASSANDRA-7855)
 + * Support IN clause on any clustering column (CASSANDRA-4762)
 + * Improve compaction logging (CASSANDRA-7818)
 + * Remove YamlFileNetworkTopologySnitch (CASSANDRA-7917)
 + * Do anticompaction in groups (CASSANDRA-6851)
 + * Support user-defined functions (CASSANDRA-7395, 7526, 7562, 7740, 7781, 7929,
 +   7924, 7812, 8063, 7813, 7708)
 + * Permit configurable timestamps with cassandra-stress (CASSANDRA-7416)
 + * Move sstable RandomAccessReader to nio2, which allows using the
 +   FILE_SHARE_DELETE flag on Windows (CASSANDRA-4050)
 + * Remove CQL2 (CASSANDRA-5918)
 + * Add Thrift get_multi_slice call (CASSANDRA-6757)
 + * Optimize fetching multiple cells by name (CASSANDRA-6933)
 + * Allow compilation in java 8 (CASSANDRA-7028)
 + * Make incremental repair default (CASSANDRA-7250)
 + * Enable code coverage thru JaCoCo (CASSANDRA-7226)
 + * Switch external naming of 'column families' to 'tables' (CASSANDRA-4369) 
 + * Shorten SSTable path (CASSANDRA-6962)
 + * Use unsafe mutations for most unit tests (CASSANDRA-6969)
 + * Fix race condition during calculation of pending ranges (CASSANDRA-7390)
 + * Fail on very large batch sizes (CASSANDRA-8011)
 + * Improve concurrency of repair (CASSANDRA-6455, 8208)
 +
 +
  2.1.3
+  * Write partition size estimates into a system table (CASSANDRA-7688)
   * Upgrade libthrift to 0.9.2 (CASSANDRA-8685)
   * Don't use the shared ref in sstableloader (CASSANDRA-8704)
   * Purge internal prepared statements if related tables or

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e70959de/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
index 0000000,b739ba5..dea5467
mode 000000,100644..100644
--- a/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
+++ b/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
@@@ -1,0 -1,121 +1,124 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *     http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package org.apache.cassandra.db;
+ 
+ import java.util.*;
+ 
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ 
+ import org.apache.cassandra.dht.Range;
+ import org.apache.cassandra.dht.Token;
 -import org.apache.cassandra.io.sstable.SSTableReader;
++import org.apache.cassandra.io.sstable.format.SSTableReader;
+ import org.apache.cassandra.service.MigrationListener;
+ import org.apache.cassandra.service.MigrationManager;
+ import org.apache.cassandra.service.StorageService;
+ import org.apache.cassandra.utils.Pair;
++import org.apache.cassandra.utils.concurrent.Refs;
+ 
+ /**
+  * A very simplistic/crude partition count/size estimator.
+  *
+  * Exposing per-primary-range estimated partitions count and size in CQL form,
+  * as a direct CQL alternative to Thrift's describe_splits_ex().
+  *
+  * Estimates (per primary range) are calculated and dumped into a system table (system.size_estimates)
every 5 minutes.
+  *
+  * See CASSANDRA-7688.
+  */
+ public class SizeEstimatesRecorder extends MigrationListener implements Runnable
+ {
+     private static final Logger logger = LoggerFactory.getLogger(SizeEstimatesRecorder.class);
+ 
+     public static final SizeEstimatesRecorder instance = new SizeEstimatesRecorder();
+ 
+     private SizeEstimatesRecorder()
+     {
+         MigrationManager.instance.register(this);
+     }
+ 
+     public void run()
+     {
+         logger.debug("Recording size estimates");
+ 
+         // find primary token ranges for the local node.
+         Collection<Token> localTokens = StorageService.instance.getLocalTokens();
+         Collection<Range<Token>> localRanges = StorageService.instance.getTokenMetadata().getPrimaryRangesFor(localTokens);
+ 
+         for (Keyspace keyspace : Keyspace.nonSystem())
+             for (ColumnFamilyStore table : keyspace.getColumnFamilyStores())
+                 recordSizeEstimates(table, localRanges);
+     }
+ 
+     private void recordSizeEstimates(ColumnFamilyStore table, Collection<Range<Token>>
localRanges)
+     {
+         // for each local primary range, estimate (crudely) mean partition size and partitions
count.
+         Map<Range<Token>, Pair<Long, Long>> estimates = new HashMap<>(localRanges.size());
+         for (Range<Token> range : localRanges)
+         {
+             // filter sstables that have partitions in this range.
 -            List<SSTableReader> sstables = table.viewFilter(range.toRowBounds()).apply(table.getDataTracker().getView());
 -            SSTableReader.acquireReferences(sstables);
++            List<SSTableReader> sstables = null;
++            Refs<SSTableReader> refs = null;
++            while (refs == null)
++                refs = Refs.tryRef(table.viewFilter(range.toRowBounds()).apply(table.getDataTracker().getView()));
+ 
+             long partitionsCount, meanPartitionSize;
+             try
+             {
+                 // calculate the estimates.
+                 partitionsCount = estimatePartitionsCount(sstables, range);
+                 meanPartitionSize = estimateMeanPartitionSize(sstables);
+             }
+             finally
+             {
 -                SSTableReader.releaseReferences(sstables);
++                refs.release();
+             }
+ 
+             estimates.put(range, Pair.create(partitionsCount, meanPartitionSize));
+         }
+ 
+         // atomically update the estimates.
+         SystemKeyspace.updateSizeEstimates(table.metadata.ksName, table.metadata.cfName,
estimates);
+     }
+ 
+     private long estimatePartitionsCount(Collection<SSTableReader> sstables, Range<Token>
range)
+     {
+         long count = 0;
+         for (SSTableReader sstable : sstables)
+             count += sstable.estimatedKeysForRanges(Collections.singleton(range));
+         return count;
+     }
+ 
+     private long estimateMeanPartitionSize(Collection<SSTableReader> sstables)
+     {
+         long sum = 0, count = 0;
+         for (SSTableReader sstable : sstables)
+         {
+             long n = sstable.getEstimatedRowSize().count();
+             sum += sstable.getEstimatedRowSize().mean() * n;
+             count += n;
+         }
+         return count > 0 ? sum / count : 0;
+     }
+ 
+     @Override
+     public void onDropColumnFamily(String keyspace, String table)
+     {
+         SystemKeyspace.clearSizeEstimates(keyspace, table);
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e70959de/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/SystemKeyspace.java
index f492c39,7338b28..7d0cdf4
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@@ -33,21 -35,23 +33,23 @@@ import org.slf4j.LoggerFactory
  import org.apache.cassandra.config.CFMetaData;
  import org.apache.cassandra.config.DatabaseDescriptor;
  import org.apache.cassandra.config.KSMetaData;
 -import org.apache.cassandra.config.Schema;
  import org.apache.cassandra.cql3.QueryProcessor;
  import org.apache.cassandra.cql3.UntypedResultSet;
 -import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
  import org.apache.cassandra.db.compaction.CompactionHistoryTabularData;
  import org.apache.cassandra.db.commitlog.ReplayPosition;
 +import org.apache.cassandra.db.compaction.LeveledCompactionStrategy;
+ import org.apache.cassandra.db.composites.Composite;
  import org.apache.cassandra.db.filter.QueryFilter;
  import org.apache.cassandra.db.marshal.*;
+ import org.apache.cassandra.dht.Range;
  import org.apache.cassandra.dht.Token;
  import org.apache.cassandra.exceptions.ConfigurationException;
 -import org.apache.cassandra.io.sstable.SSTableReader;
 +import org.apache.cassandra.io.sstable.format.SSTableReader;
  import org.apache.cassandra.io.util.DataOutputBuffer;
  import org.apache.cassandra.locator.IEndpointSnitch;
 +import org.apache.cassandra.locator.LocalStrategy;
  import org.apache.cassandra.metrics.RestorableMeter;
 +import org.apache.cassandra.schema.LegacySchemaTables;
  import org.apache.cassandra.service.StorageService;
  import org.apache.cassandra.service.paxos.Commit;
  import org.apache.cassandra.service.paxos.PaxosState;
@@@ -62,179 -66,33 +64,193 @@@ 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);
 +    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 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,"
 +                + "cluster_name text,"
 +                + "cql_version text,"
 +                + "data_center text,"
 +                + "gossip_generation int,"
 +                + "host_id uuid,"
 +                + "native_protocol_version text,"
 +                + "partitioner text,"
 +                + "rack text,"
 +                + "release_version text,"
 +                + "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))");
++
 +    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));
++                                           SSTableActivity,
++                                           SizeEstimates));
 +        return new KSMetaData(NAME, LocalStrategy.class, Collections.<String, String>emptyMap(),
true, tables);
 +    }
  
      private static volatile Map<UUID, Pair<ReplayPosition, Long>> truncationRecords;
  
@@@ -897,6 -940,47 +913,44 @@@
      public static void clearSSTableReadMeter(String keyspace, String table, int generation)
      {
          String cql = "DELETE FROM system.%s WHERE keyspace_name=? AND columnfamily_name=?
and generation=?";
 -        executeInternal(String.format(cql, SSTABLE_ACTIVITY_CF), keyspace, table, generation);
 +        executeInternal(String.format(cql, SSTABLE_ACTIVITY), keyspace, table, generation);
      }
+ 
+     /**
+      * Writes the current partition count and size estimates into SIZE_ESTIMATES_CF
+      */
+     public static void updateSizeEstimates(String keyspace, String table, Map<Range<Token>,
Pair<Long, Long>> estimates)
+     {
+         long timestamp = FBUtilities.timestampMicros();
 -        CFMetaData estimatesTable = CFMetaData.SizeEstimatesCf;
 -        Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, UTF8Type.instance.decompose(keyspace));
++        Mutation mutation = new Mutation(NAME, UTF8Type.instance.decompose(keyspace));
+ 
+         // delete all previous values with a single range tombstone.
 -        mutation.deleteRange(SIZE_ESTIMATES_CF,
 -                             estimatesTable.comparator.make(table).start(),
 -                             estimatesTable.comparator.make(table).end(),
++        mutation.deleteRange(SIZE_ESTIMATES,
++                             SizeEstimates.comparator.make(table).start(),
++                             SizeEstimates.comparator.make(table).end(),
+                              timestamp - 1);
+ 
+         // add a CQL row for each primary token range.
 -        ColumnFamily cells = mutation.addOrGet(estimatesTable);
++        ColumnFamily cells = mutation.addOrGet(SizeEstimates);
+         for (Map.Entry<Range<Token>, Pair<Long, Long>> entry : estimates.entrySet())
+         {
+             Range<Token> range = entry.getKey();
+             Pair<Long, Long> values = entry.getValue();
 -            Composite prefix = estimatesTable.comparator.make(table, range.left.toString(),
range.right.toString());
++            Composite prefix = SizeEstimates.comparator.make(table, range.left.toString(),
range.right.toString());
+             CFRowAdder adder = new CFRowAdder(cells, prefix, timestamp);
+             adder.add("partitions_count", values.left)
+                  .add("mean_partition_size", values.right);
+         }
+ 
+         mutation.apply();
+     }
+ 
+     /**
+      * Clears size estimates for a table (on table drop)
+      */
+     public static void clearSizeEstimates(String keyspace, String table)
+     {
 -        String cql = String.format("DELETE FROM %s.%s WHERE keyspace_name = ? AND table_name
= ?",
 -                                   Keyspace.SYSTEM_KS,
 -                                   SIZE_ESTIMATES_CF);
++        String cql = String.format("DELETE FROM %s.%s WHERE keyspace_name = ? AND table_name
= ?", NAME, SIZE_ESTIMATES);
+         executeInternal(cql, keyspace, table);
+     }
  }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e70959de/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------


Mime
View raw message