cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1079462 - in /cassandra/trunk: conf/cassandra.yaml conf/schema-sample.txt src/java/org/apache/cassandra/config/DatabaseDescriptor.java src/java/org/apache/cassandra/service/StorageService.java
Date Tue, 08 Mar 2011 18:13:49 GMT
Author: jbellis
Date: Tue Mar  8 18:13:49 2011
New Revision: 1079462

URL: http://svn.apache.org/viewvc?rev=1079462&view=rev
Log:
move keyspace1 sample config out of cassandra.yaml
patch by Aaron Morton; reviewed by jbellis for CASSANDRA-2007

Added:
    cassandra/trunk/conf/schema-sample.txt
Modified:
    cassandra/trunk/conf/cassandra.yaml
    cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java

Modified: cassandra/trunk/conf/cassandra.yaml
URL: http://svn.apache.org/viewvc/cassandra/trunk/conf/cassandra.yaml?rev=1079462&r1=1079461&r2=1079462&view=diff
==============================================================================
--- cassandra/trunk/conf/cassandra.yaml (original)
+++ cassandra/trunk/conf/cassandra.yaml Tue Mar  8 18:13:49 2011
@@ -363,184 +363,4 @@ encryption_options:
     keystore: conf/.keystore
     keystore_password: cassandra
     truststore: conf/.truststore
-    truststore_password: cassandra
-
-# Keyspaces have ColumnFamilies.        (Usually 1 KS per application.)
-# ColumnFamilies have Rows.             (Dozens of CFs per KS.)
-# Rows contain Columns.                 (Many per CF.)
-# Columns contain name:value:timestamp. (Many per Row.)
-#
-# A KS is most similar to a schema, and a CF is most similar to a relational table.
-#
-# Keyspaces, ColumnFamilies, and Columns may carry additional
-# metadata that change their behavior. These are as follows:
-#
-# Keyspace required parameters:
-# - name: name of the keyspace; "system" is
-#   reserved for Cassandra Internals.
-# - replica_placement_strategy: the class that determines how replicas
-#   are distributed among nodes. Contains both the class as well as
-#   configuration information.  Must extend AbstractReplicationStrategy.
-#   Out of the box, Cassandra provides 
-#     * org.apache.cassandra.locator.SimpleStrategy 
-#     * org.apache.cassandra.locator.NetworkTopologyStrategy
-#     * org.apache.cassandra.locator.OldNetworkTopologyStrategy
-#
-#   SimpleStrategy merely places the first
-#   replica at the node whose token is closest to the key (as determined
-#   by the Partitioner), and additional replicas on subsequent nodes
-#   along the ring in increasing Token order.
-# 
-#   With NetworkTopologyStrategy,
-#   for each datacenter, you can specify how many replicas you want
-#   on a per-keyspace basis.  Replicas are placed on different racks
-#   within each DC, if possible. 
-#   An example:
-#    - name: Keyspace1
-#      replica_placement_strategy: org.apache.cassandra.locator.NetworkTopologyStrategy
-#      strategy_options:
-#        DC1 : 3
-#        DC2 : 2
-#        DC3 : 1
-# 
-#   OldNetworkToplogyStrategy [formerly RackAwareStrategy] 
-#   places one replica in each of two datacenters, and the third on a
-#   different rack in in the first.  Additional datacenters are not
-#   guaranteed to get a replica.  Additional replicas after three are placed
-#   in ring order after the third without regard to rack or datacenter.
-# - replication_factor: Number of replicas of each row
-# Keyspace optional paramaters:
-# - strategy_options: Additional information for the replication strategy.
-# - column_families:
-#     ColumnFamily required parameters:
-#     - name: name of the ColumnFamily.  Must not contain the character "-".
-#     - compare_with: tells Cassandra how to sort the columns for slicing
-#       operations. The default is BytesType, which is a straightforward
-#       lexical comparison of the bytes in each column.  Other options are
-#       AsciiType, UTF8Type, LexicalUUIDType, TimeUUIDType, LongType,
-#       and IntegerType (a generic variable-length integer type).
-#       You can also specify the fully-qualified class name to a class of
-#       your choice extending org.apache.cassandra.db.marshal.AbstractType.
-#    
-#     ColumnFamily optional parameters:
-#     - keys_cached: specifies the number of keys per sstable whose
-#        locations we keep in memory in "mostly LRU" order.  (JUST the key
-#        locations, NOT any column values.) Specify a fraction (value less
-#        than 1) or an absolute number of keys to cache.  Defaults to 200000
-#        keys.
-#     - rows_cached: specifies the number of rows whose entire contents we
-#        cache in memory. Do not use this on ColumnFamilies with large rows,
-#        or ColumnFamilies with high write:read ratios. Specify a fraction
-#        (value less than 1) or an absolute number of rows to cache.
-#        Defaults to 0. (i.e. row caching is off by default)
-#     - comment: used to attach additional human-readable information about 
-#        the column family to its definition.
-#     - read_repair_chance: specifies the probability with which read
-#        repairs should be invoked on non-quorum reads.  must be between 0
-#        and 1. defaults to 1.0 (always read repair).
-#     - gc_grace_seconds: specifies the time to wait before garbage
-#        collecting tombstones (deletion markers). defaults to 864000 (10
-#        days). See http://wiki.apache.org/cassandra/DistributedDeletes
-#     - default_validation_class: specifies a validator class to use for
-#        validating all the column values in the CF.
-#     NOTE:
-#     min_ must be less than max_compaction_threshold!
-#     - min_compaction_threshold: the minimum number of SSTables needed
-#        to start a minor compaction.  increasing this will cause minor
-#        compactions to start less frequently and be more intensive. setting
-#        this to 0 disables minor compactions.  defaults to 4.
-#     - max_compaction_threshold: the maximum number of SSTables allowed
-#        before a minor compaction is forced.  decreasing this will cause
-#        minor compactions to start more frequently and be less intensive.
-#        setting this to 0 disables minor compactions.  defaults to 32.
-#     /NOTE
-#     - row_cache_save_period_in_seconds: number of seconds between saving
-#        row caches.  The row caches can be saved periodically and if one
-#        exists on startup it will be loaded.
-#     - key_cache_save_period_in_seconds: number of seconds between saving
-#        key caches.  The key caches can be saved periodically and if one 
-#        exists on startup it will be loaded.
-#     - memtable_flush_after_mins: The maximum time to leave a dirty table
-#        unflushed.  This should be large enough that it won't cause a flush
-#        storm of all memtables during periods of inactivity.
-#     - memtable_throughput_in_mb: The maximum size of the memtable before
-#        it is flushed.  If undefined, 1/8 * heapsize will be used.
-#     - memtable_operations_in_millions: Number of operations in millions
-#        before the memtable is flushed. If undefined, throughput / 64 * 0.3
-#        will be used.
-#     - column_metadata:
-#         Column required parameters:
-#         - name: binds a validator (and optionally an indexer) to columns 
-#            with this name in any row of the enclosing column family.
-#         - validator: like cf.compare_with, an AbstractType that checks
-#            that the value of the column is well-defined.
-#         Column optional parameters:
-#         NOTE:
-#         index_name cannot be set if index_type is not also set!
-#         - index_name: User-friendly name for the index.
-#         - index_type: The type of index to be created. Currently only
-#            KEYS is supported.
-#         /NOTE
-# 
-# NOTE:
-#   this keyspace definition is for demonstration purposes only.
-#   Cassandra will not load these definitions during startup. See
-#   http://wiki.apache.org/cassandra/FAQ#no_keyspaces for an explanation.
-# /NOTE
-keyspaces:
-    - name: Keyspace1
-      replica_placement_strategy: org.apache.cassandra.locator.SimpleStrategy
-      replication_factor: 1
-      column_families:
-        - name: Standard1
-          compare_with: BytesType
-          keys_cached: 10000
-          rows_cached: 1000
-          row_cache_save_period_in_seconds: 0
-          key_cache_save_period_in_seconds: 3600
-          memtable_flush_after_mins: 59
-          memtable_throughput_in_mb: 255
-          memtable_operations_in_millions: 0.29
-
-        - name: Standard2
-          compare_with: UTF8Type
-          read_repair_chance: 0.1
-          keys_cached: 100
-          gc_grace_seconds: 0
-          min_compaction_threshold: 5
-          max_compaction_threshold: 31
-
-        - name: StandardByUUID1
-          compare_with: TimeUUIDType
-
-        - name: Super1
-          column_type: Super
-          compare_with: BytesType
-          compare_subcolumns_with: BytesType
-
-        - name: Super2
-          column_type: Super
-          compare_subcolumns_with: UTF8Type
-          rows_cached: 10000
-          keys_cached: 50
-          comment: 'A column family with supercolumns, whose column and subcolumn names are
UTF8 strings'
-
-        - name: Super3
-          column_type: Super
-          compare_with: LongType
-          comment: 'A column family with supercolumns, whose column names are Longs (8 bytes)'
-
-        - name: Indexed1
-          default_validation_class: LongType
-          column_metadata:
-            - name: birthdate
-              validator_class: LongType
-              index_name: birthdate_idx
-              index_type: KEYS
-
-        - name: Counter1
-          default_validation_class: CounterColumnType
-
-        - name: SuperCounter1
-          column_type: Super
-          default_validation_class: CounterColumnType
+    truststore_password: cassandra
\ No newline at end of file

Added: cassandra/trunk/conf/schema-sample.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/conf/schema-sample.txt?rev=1079462&view=auto
==============================================================================
--- cassandra/trunk/conf/schema-sample.txt (added)
+++ cassandra/trunk/conf/schema-sample.txt Tue Mar  8 18:13:49 2011
@@ -0,0 +1,69 @@
+/*This file contains an example Keyspace that can be created using the
+cassandra-cli command line interface as follows.
+
+bin/cassandra-cli -host localhost --file conf/Keyspace1.txt
+
+The cassandra-cli includes online help that explains the statements below. You can
+accessed the help without connecting to a running cassandra instance by starting the
+client and typing "help;"
+*/
+
+create keyspace Keyspace1
+    with replication_factor = 1
+    and placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy';
+
+use Keyspace1;
+
+create column family Standard1
+    with comparator = BytesType
+    and keys_cached = 10000
+    and rows_cached = 1000
+    and row_cache_save_period = 0
+    and key_cache_save_period = 3600
+    and memtable_flush_after = 59
+    and memtable_throughput = 255
+    and memtable_operations = 0.29;
+
+create column family Standard2
+    with comparator = UTF8Type
+    and read_repair_chance = 0.1
+    and keys_cached = 100
+    and gc_grace = 0
+    and min_compaction_threshold = 5
+    and max_compaction_threshold = 31;
+
+create column family StandardByUUID1
+    with comparator = TimeUUIDType;
+
+create column family Super1
+    with column_type = Super
+    and comparator = BytesType
+    and subcomparator = BytesType;
+
+create column family Super2
+    with column_type = Super
+    and subcomparator = UTF8Type
+    and rows_cached = 10000
+    and keys_cached = 50
+    and comment = 'A column family with supercolumns, whose column and subcolumn names are
UTF8 strings';
+
+create column family Super3
+    with column_type = Super
+    and comparator = LongType
+    and comment = 'A column family with supercolumns, whose column names are Longs (8 bytes)';
+
+create column family Indexed1
+    with default_validation_class = LongType
+    and column_metadata = [{
+        column_name : birthdate,
+        validation_class : LongType,
+        index_name : birthdate_idx,
+        index_type : 0}
+    ];
+
+create column family Counter1
+    with default_validation_class = CounterColumnType;
+
+create column family SuperCounter1
+    with column_type = Super
+    and default_validation_class = CounterColumnType;

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=1079462&r1=1079461&r2=1079462&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Tue Mar 
8 18:13:49 2011
@@ -510,7 +510,8 @@ public class DatabaseDescriptor
     public static Collection<KSMetaData> readTablesFromYaml() throws ConfigurationException
     {
         List<KSMetaData> defs = new ArrayList<KSMetaData>();
-        
+        if (conf.keyspaces == null)
+            return defs;
         
         /* Read the table related stuff from config */
         for (RawKeyspace keyspace : conf.keyspaces)

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=1079462&r1=1079461&r2=1079462&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Tue Mar  8 18:13:49
2011
@@ -2103,6 +2103,9 @@ public class StorageService implements I
     { 
         // validate
         final Collection<KSMetaData> tables = DatabaseDescriptor.readTablesFromYaml();
+        if (tables.isEmpty())
+            return;
+
         for (KSMetaData table : tables)
         {
             if (!table.name.matches(Migration.NAME_VALIDATOR_REGEX))



Mime
View raw message