cassandra 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/CHANGELOG +12 -0
  2. data/Manifest +31 -12
  3. data/README.rdoc +3 -2
  4. data/Rakefile +53 -23
  5. data/cassandra.gemspec +6 -8
  6. data/conf/{cassandra.in.sh → 0.6/cassandra.in.sh} +0 -0
  7. data/conf/{log4j.properties → 0.6/log4j.properties} +0 -0
  8. data/conf/0.6/schema.json +48 -0
  9. data/conf/{storage-conf.xml → 0.6/storage-conf.xml} +5 -5
  10. data/conf/0.7/cassandra.in.sh +46 -0
  11. data/conf/0.7/cassandra.yaml +336 -0
  12. data/conf/0.7/log4j-server.properties +41 -0
  13. data/conf/0.7/schema.json +48 -0
  14. data/conf/0.7/schema.txt +56 -0
  15. data/conf/0.8/cassandra.in.sh +41 -0
  16. data/conf/0.8/cassandra.yaml +61 -0
  17. data/conf/0.8/log4j-server.properties +40 -0
  18. data/conf/0.8/schema.json +48 -0
  19. data/conf/0.8/schema.txt +56 -0
  20. data/lib/cassandra.rb +1 -1
  21. data/lib/cassandra/0.6/cassandra.rb +1 -0
  22. data/lib/cassandra/0.6/columns.rb +5 -7
  23. data/lib/cassandra/0.6/protocol.rb +1 -1
  24. data/lib/cassandra/0.7/cassandra.rb +5 -5
  25. data/lib/cassandra/0.7/columns.rb +5 -6
  26. data/lib/cassandra/0.7/protocol.rb +12 -3
  27. data/lib/cassandra/0.8.rb +7 -0
  28. data/lib/cassandra/0.8/cassandra.rb +272 -0
  29. data/lib/cassandra/0.8/column_family.rb +3 -0
  30. data/lib/cassandra/0.8/columns.rb +84 -0
  31. data/lib/cassandra/0.8/keyspace.rb +3 -0
  32. data/lib/cassandra/0.8/protocol.rb +120 -0
  33. data/lib/cassandra/cassandra.rb +6 -11
  34. data/lib/cassandra/helpers.rb +1 -0
  35. data/lib/cassandra/mock.rb +107 -64
  36. data/lib/cassandra/ordered_hash.rb +1 -6
  37. data/test/cassandra_mock_test.rb +7 -27
  38. data/test/cassandra_test.rb +41 -15
  39. data/test/eventmachine_test.rb +30 -30
  40. data/test/test_helper.rb +2 -1
  41. data/vendor/0.8/gen-rb/cassandra.rb +2215 -0
  42. data/vendor/0.8/gen-rb/cassandra_constants.rb +12 -0
  43. data/vendor/0.8/gen-rb/cassandra_types.rb +814 -0
  44. metadata +50 -27
  45. data/conf/cassandra.yaml +0 -113
@@ -0,0 +1,41 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # for production, you should probably set pattern to %c instead of %l.
18
+ # (%l is slower.)
19
+
20
+ # output messages into a rolling log file as well as stdout
21
+ log4j.rootLogger=DEBUG,stdout,R
22
+
23
+ # stdout
24
+ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
25
+ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
26
+ log4j.appender.stdout.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n
27
+
28
+ # rolling log file
29
+ log4j.appender.R=org.apache.log4j.RollingFileAppender
30
+ log4j.appender.R.maxFileSize=20MB
31
+ log4j.appender.R.maxBackupIndex=50
32
+ log4j.appender.R.layout=org.apache.log4j.PatternLayout
33
+ log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
34
+ # Edit the next line to point to your logs directory
35
+ log4j.appender.R.File=data/logs/system.log
36
+
37
+ # Application logging options
38
+ #log4j.logger.org.apache.cassandra=DEBUG
39
+ #log4j.logger.org.apache.cassandra.db=DEBUG
40
+ #log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG
41
+
@@ -0,0 +1,48 @@
1
+ {"Twitter":{
2
+ "Users":{
3
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
4
+ "column_type":"Standard"},
5
+ "UserAudits":{
6
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
7
+ "column_type":"Standard"},
8
+ "UserRelationships":{
9
+ "subcomparator_type":"org.apache.cassandra.db.marshal.TimeUUIDType",
10
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
11
+ "column_type":"Super"},
12
+ "Usernames":{
13
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
14
+ "column_type":"Standard"},
15
+ "Statuses":{
16
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
17
+ "column_type":"Standard"},
18
+ "StatusAudits":{
19
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
20
+ "column_type":"Standard"},
21
+ "StatusRelationships":{
22
+ "subcomparator_type":"org.apache.cassandra.db.marshal.TimeUUIDType",
23
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
24
+ "column_type":"Super"},
25
+ "Index":{
26
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
27
+ "column_type":"Super"},
28
+ "TimelinishThings":{
29
+ "comparator_type":"org.apache.cassandra.db.marshal.BytesType",
30
+ "column_type":"Standard"}
31
+ },
32
+ "Multiblog":{
33
+ "Blogs":{
34
+ "comparator_type":"org.apache.cassandra.db.marshal.TimeUUIDType",
35
+ "column_type":"Standard"},
36
+ "Comments":{
37
+ "comparator_type":"org.apache.cassandra.db.marshal.TimeUUIDType",
38
+ "column_type":"Standard"}
39
+ },
40
+ "MultiblogLong":{
41
+ "Blogs":{
42
+ "comparator_type":"org.apache.cassandra.db.marshal.LongType",
43
+ "column_type":"Standard"},
44
+ "Comments":{
45
+ "comparator_type":"org.apache.cassandra.db.marshal.LongType",
46
+ "column_type":"Standard"}
47
+ }
48
+ }
@@ -0,0 +1,56 @@
1
+ create keyspace Twitter with
2
+ placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' AND
3
+ replication_factor = 1;
4
+ use Twitter;
5
+ create column family Users with comparator = 'UTF8Type';
6
+ create column family UserAudits with comparator = 'UTF8Type';
7
+ create column family UserRelationships with
8
+ comparator = 'UTF8Type' and
9
+ column_type = 'Super' and
10
+ subcomparator = 'TimeUUIDType';
11
+ create column family Usernames with comparator = 'UTF8Type';
12
+ create column family Statuses with comparator = 'UTF8Type';
13
+ create column family StatusAudits with comparator = 'UTF8Type';
14
+ create column family StatusRelationships with
15
+ comparator = 'UTF8Type' and
16
+ column_type = 'Super' and
17
+ subcomparator = 'TimeUUIDType';
18
+ create column family Index with
19
+ comparator = 'UTF8Type' and
20
+ column_type = 'Super';
21
+ create column family TimelinishThings with
22
+ comparator = 'BytesType';
23
+
24
+ create keyspace Multiblog with
25
+ placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' AND
26
+ replication_factor = 1;
27
+ use Multiblog;
28
+ create column family Blogs with comparator = 'TimeUUIDType';
29
+ create column family Comments with comparator = 'TimeUUIDType';
30
+
31
+
32
+ create keyspace MultiblogLong with
33
+ placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' AND
34
+ replication_factor = 1;
35
+ use MultiblogLong;
36
+ create column family Blogs with comparator = 'LongType';
37
+ create column family Comments with comparator = 'LongType';
38
+
39
+ create keyspace CassandraObject with
40
+ placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' AND
41
+ replication_factor = 1;
42
+ use CassandraObject;
43
+ create column family Customers with comparator = 'UTF8Type';
44
+ create column family CustomerRelationships with
45
+ comparator = 'UTF8Type' AND
46
+ column_type = 'Super' AND
47
+ subcomparator = 'TimeUUIDType';
48
+ create column family CustomersByLastName with comparator = 'TimeUUIDType';
49
+ create column family Invoices with comparator = 'UTF8Type';
50
+ create column family InvoiceRelationships with
51
+ comparator = 'UTF8Type' AND
52
+ column_type = 'Super' AND
53
+ subcomparator = 'TimeUUIDType';
54
+ create column family InvoicesByNumber with comparator = 'UTF8Type';
55
+ create column family Payments with comparator = 'UTF8Type';
56
+ create column family Appointments with comparator = 'UTF8Type';
@@ -0,0 +1,41 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ if [ "x$CASSANDRA_HOME" = "x" ]; then
18
+ CASSANDRA_HOME=`dirname $0`/..
19
+ fi
20
+
21
+ # The directory where Cassandra's configs live (required)
22
+ if [ "x$CASSANDRA_CONF" = "x" ]; then
23
+ CASSANDRA_CONF=$CASSANDRA_HOME/conf
24
+ fi
25
+
26
+ # This can be the path to a jar file, or a directory containing the
27
+ # compiled classes. NOTE: This isn't needed by the startup script,
28
+ # it's just used here in constructing the classpath.
29
+ cassandra_bin=$CASSANDRA_HOME/build/classes/main
30
+ cassandra_bin=$cassandra_bin:$CASSANDRA_HOME/build/classes/thrift
31
+ #cassandra_bin=$cassandra_home/build/cassandra.jar
32
+
33
+ # JAVA_HOME can optionally be set here
34
+ #JAVA_HOME=/usr/local/jdk6
35
+
36
+ # The java classpath (required)
37
+ CLASSPATH=$CASSANDRA_CONF:$cassandra_bin
38
+
39
+ for jar in $CASSANDRA_HOME/lib/*.jar; do
40
+ CLASSPATH=$CLASSPATH:$jar
41
+ done
@@ -0,0 +1,61 @@
1
+ # Cassandra storage config YAML
2
+ cluster_name: 'Test'
3
+ initial_token:
4
+ auto_bootstrap: false
5
+ hinted_handoff_enabled: true
6
+ max_hint_window_in_ms: 3600000 # one hour
7
+ hinted_handoff_throttle_delay_in_ms: 50
8
+ authenticator: org.apache.cassandra.auth.AllowAllAuthenticator
9
+ authority: org.apache.cassandra.auth.AllowAllAuthority
10
+ partitioner: org.apache.cassandra.dht.RandomPartitioner
11
+
12
+ # directories where Cassandra should store data on disk.
13
+ data_file_directories:
14
+ - data/data
15
+ commitlog_directory: data/commitlog
16
+
17
+ # saved caches
18
+ saved_caches_directory: data/saved_caches
19
+
20
+ commitlog_rotation_threshold_in_mb: 128
21
+ commitlog_sync: periodic
22
+ commitlog_sync_period_in_ms: 10000
23
+ seed_provider:
24
+ - class_name: org.apache.cassandra.locator.SimpleSeedProvider
25
+ parameters:
26
+ - seeds: "127.0.0.1"
27
+ flush_largest_memtables_at: 0.75
28
+ reduce_cache_sizes_at: 0.85
29
+ reduce_cache_capacity_to: 0.6
30
+ concurrent_reads: 32
31
+ concurrent_writes: 32
32
+ memtable_flush_queue_size: 4
33
+ sliced_buffer_size_in_kb: 64
34
+ storage_port: 7000
35
+ listen_address: localhost
36
+ rpc_address: localhost
37
+ rpc_port: 9160
38
+ rpc_keepalive: true
39
+ thrift_framed_transport_size_in_mb: 15
40
+ thrift_max_message_length_in_mb: 16
41
+ incremental_backups: false
42
+ snapshot_before_compaction: false
43
+ column_index_size_in_kb: 64
44
+ in_memory_compaction_limit_in_mb: 64
45
+ compaction_multithreading: false
46
+ compaction_throughput_mb_per_sec: 16
47
+ compaction_preheat_key_cache: true
48
+ rpc_timeout_in_ms: 10000
49
+ endpoint_snitch: org.apache.cassandra.locator.SimpleSnitch
50
+ dynamic_snitch: true
51
+ dynamic_snitch_update_interval_in_ms: 100
52
+ dynamic_snitch_reset_interval_in_ms: 600000
53
+ dynamic_snitch_badness_threshold: 0.0
54
+ request_scheduler: org.apache.cassandra.scheduler.NoScheduler
55
+ index_interval: 128
56
+ encryption_options:
57
+ internode_encryption: none
58
+ keystore: conf/.keystore
59
+ keystore_password: cassandra
60
+ truststore: conf/.truststore
61
+ truststore_password: cassandra
@@ -0,0 +1,40 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # for production, you should probably set pattern to %c instead of %l.
18
+ # (%l is slower.)
19
+
20
+ # output messages into a rolling log file as well as stdout
21
+ log4j.rootLogger=DEBUG,stdout,R
22
+
23
+ # stdout
24
+ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
25
+ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
26
+ log4j.appender.stdout.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n
27
+
28
+ # rolling log file
29
+ log4j.appender.R=org.apache.log4j.RollingFileAppender
30
+ log4j.appender.R.maxFileSize=20MB
31
+ log4j.appender.R.maxBackupIndex=50
32
+ log4j.appender.R.layout=org.apache.log4j.PatternLayout
33
+ log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
34
+ # Edit the next line to point to your logs directory
35
+ log4j.appender.R.File=data/logs/system.log
36
+
37
+ # Application logging options
38
+ #log4j.logger.org.apache.cassandra=DEBUG
39
+ #log4j.logger.org.apache.cassandra.db=DEBUG
40
+ #log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG
@@ -0,0 +1,48 @@
1
+ {"Twitter":{
2
+ "Users":{
3
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
4
+ "column_type":"Standard"},
5
+ "UserAudits":{
6
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
7
+ "column_type":"Standard"},
8
+ "UserRelationships":{
9
+ "subcomparator_type":"org.apache.cassandra.db.marshal.TimeUUIDType",
10
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
11
+ "column_type":"Super"},
12
+ "Usernames":{
13
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
14
+ "column_type":"Standard"},
15
+ "Statuses":{
16
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
17
+ "column_type":"Standard"},
18
+ "StatusAudits":{
19
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
20
+ "column_type":"Standard"},
21
+ "StatusRelationships":{
22
+ "subcomparator_type":"org.apache.cassandra.db.marshal.TimeUUIDType",
23
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
24
+ "column_type":"Super"},
25
+ "Index":{
26
+ "comparator_type":"org.apache.cassandra.db.marshal.UTF8Type",
27
+ "column_type":"Super"},
28
+ "TimelinishThings":{
29
+ "comparator_type":"org.apache.cassandra.db.marshal.BytesType",
30
+ "column_type":"Standard"}
31
+ },
32
+ "Multiblog":{
33
+ "Blogs":{
34
+ "comparator_type":"org.apache.cassandra.db.marshal.TimeUUIDType",
35
+ "column_type":"Standard"},
36
+ "Comments":{
37
+ "comparator_type":"org.apache.cassandra.db.marshal.TimeUUIDType",
38
+ "column_type":"Standard"}
39
+ },
40
+ "MultiblogLong":{
41
+ "Blogs":{
42
+ "comparator_type":"org.apache.cassandra.db.marshal.LongType",
43
+ "column_type":"Standard"},
44
+ "Comments":{
45
+ "comparator_type":"org.apache.cassandra.db.marshal.LongType",
46
+ "column_type":"Standard"}
47
+ }
48
+ }
@@ -0,0 +1,56 @@
1
+ create keyspace Twitter with
2
+ placement_strategy = 'org.apache.cassandra.locator.LocalStrategy' AND
3
+ strategy_options = [{replication_factor:1}];
4
+ use Twitter;
5
+ create column family Users with comparator = 'UTF8Type';
6
+ create column family UserAudits with comparator = 'UTF8Type';
7
+ create column family UserRelationships with
8
+ comparator = 'UTF8Type' and
9
+ column_type = 'Super' and
10
+ subcomparator = 'TimeUUIDType';
11
+ create column family Usernames with comparator = 'UTF8Type';
12
+ create column family Statuses with comparator = 'UTF8Type';
13
+ create column family StatusAudits with comparator = 'UTF8Type';
14
+ create column family StatusRelationships with
15
+ comparator = 'UTF8Type' and
16
+ column_type = 'Super' and
17
+ subcomparator = 'TimeUUIDType';
18
+ create column family Index with
19
+ comparator = 'UTF8Type' and
20
+ column_type = 'Super';
21
+ create column family TimelinishThings with
22
+ comparator = 'BytesType';
23
+
24
+ create keyspace Multiblog with
25
+ placement_strategy = 'org.apache.cassandra.locator.LocalStrategy' AND
26
+ strategy_options = [{replication_factor:1}];
27
+ use Multiblog;
28
+ create column family Blogs with comparator = 'TimeUUIDType';
29
+ create column family Comments with comparator = 'TimeUUIDType';
30
+
31
+
32
+ create keyspace MultiblogLong with
33
+ placement_strategy = 'org.apache.cassandra.locator.LocalStrategy' AND
34
+ strategy_options = [{replication_factor:1}];
35
+ use MultiblogLong;
36
+ create column family Blogs with comparator = 'LongType';
37
+ create column family Comments with comparator = 'LongType';
38
+
39
+ create keyspace CassandraObject with
40
+ placement_strategy = 'org.apache.cassandra.locator.LocalStrategy' AND
41
+ strategy_options = [{replication_factor:1}];
42
+ use CassandraObject;
43
+ create column family Customers with comparator = 'UTF8Type';
44
+ create column family CustomerRelationships with
45
+ comparator = 'UTF8Type' AND
46
+ column_type = 'Super' AND
47
+ subcomparator = 'TimeUUIDType';
48
+ create column family CustomersByLastName with comparator = 'TimeUUIDType';
49
+ create column family Invoices with comparator = 'UTF8Type';
50
+ create column family InvoiceRelationships with
51
+ comparator = 'UTF8Type' AND
52
+ column_type = 'Super' AND
53
+ subcomparator = 'TimeUUIDType';
54
+ create column family InvoicesByNumber with comparator = 'UTF8Type';
55
+ create column family Payments with comparator = 'UTF8Type';
56
+ create column family Appointments with comparator = 'UTF8Type';
data/lib/cassandra.rb CHANGED
@@ -12,7 +12,7 @@ here = File.expand_path(File.dirname(__FILE__))
12
12
 
13
13
  class Cassandra ; end
14
14
  unless Cassandra.respond_to?(:VERSION)
15
- require "#{here}/cassandra/0.6"
15
+ require "#{here}/cassandra/0.7"
16
16
  end
17
17
 
18
18
  $LOAD_PATH << "#{here}/../vendor/#{Cassandra.VERSION}/gen-rb"
@@ -14,6 +14,7 @@ class Cassandra
14
14
  remove(column_family, key, options)
15
15
  end
16
16
  end
17
+ alias truncate! clear_column_family!
17
18
 
18
19
  # Remove all rows in the keyspace. Supports options <tt>:consistency</tt> and
19
20
  # <tt>:timestamp</tt>.
@@ -44,18 +44,16 @@ class Cassandra
44
44
  # The main reason being that the batch function takes removes, but removes don't have that capability...so we'd need to change the remove
45
45
  # methods to use delete mutation calls...although that might have performance implications. We'll leave that refactoring for later.
46
46
  def _delete_mutation(cf, column, subcolumn, timestamp, options={})
47
-
48
47
  deletion_hash = {:timestamp => timestamp}
49
48
  if is_super(cf)
50
- deletion_hash[:super_column] = column if column
51
- deletion_hash[:predicate] = CassandraThrift::SlicePredicate.new(:column_names => [subcolumn]) if subcolumn
52
- else
53
- deletion_hash[:predicate] = CassandraThrift::SlicePredicate.new(:column_names => [column]) if column
49
+ deletion_hash[:super_column] = column if column
50
+ deletion_hash[:predicate] = CassandraThrift::SlicePredicate.new(:column_names => [subcolumn]) if subcolumn
51
+ else
52
+ deletion_hash[:predicate] = CassandraThrift::SlicePredicate.new(:column_names => [column]) if column
54
53
  end
55
54
  CassandraThrift::Mutation.new(
56
55
  :deletion => CassandraThrift::Deletion.new(deletion_hash)
57
- )
56
+ )
58
57
  end
59
-
60
58
  end
61
59
  end