cassandra 0.2.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,55 @@
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
+
18
+ cassandra_home=`pwd`/cassandra
19
+
20
+ # The directory where Cassandra's configs live (required)
21
+ CASSANDRA_CONF=`pwd`/conf
22
+
23
+ # This can be the path to a jar file, or a directory containing the
24
+ # compiled classes. NOTE: This isn't needed by the startup script,
25
+ # it's just used here in constructing the classpath.
26
+ cassandra_bin=$cassandra_home/build/classes
27
+ #cassandra_bin=$cassandra_home/build/cassandra.jar
28
+
29
+ # The java classpath (required)
30
+ CLASSPATH=$CASSANDRA_CONF:$cassandra_bin
31
+
32
+ for jar in $cassandra_home/lib/*.jar; do
33
+ CLASSPATH=$CLASSPATH:$jar
34
+ done
35
+
36
+ echo $cassandra_home
37
+
38
+ # Arguments to pass to the JVM
39
+ JVM_OPTS=" \
40
+ -ea \
41
+ -Xdebug \
42
+ -Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n \
43
+ -Xms128M \
44
+ -Xmx1G \
45
+ -XX:SurvivorRatio=8 \
46
+ -XX:TargetSurvivorRatio=90 \
47
+ -XX:+AggressiveOpts \
48
+ -XX:+UseParNewGC \
49
+ -XX:+UseConcMarkSweepGC \
50
+ -XX:CMSInitiatingOccupancyFraction=1 \
51
+ -XX:+CMSParallelRemarkEnabled \
52
+ -XX:+HeapDumpOnOutOfMemoryError \
53
+ -Dcom.sun.management.jmxremote.port=8080 \
54
+ -Dcom.sun.management.jmxremote.ssl=false \
55
+ -Dcom.sun.management.jmxremote.authenticate=false"
@@ -0,0 +1,38 @@
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 the root to INFO
18
+ # and the pattern to %c instead of %l. (%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.SimpleLayout
26
+
27
+ # rolling log file ("system.log
28
+ log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
29
+ log4j.appender.R.DatePattern='.'yyyy-MM-dd-HH
30
+ log4j.appender.R.layout=org.apache.log4j.PatternLayout
31
+ log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
32
+ # Edit the next line to point to your logs directory
33
+ log4j.appender.R.File=data/logs/system.log
34
+
35
+ # Application logging options
36
+ #log4j.logger.com.facebook=DEBUG
37
+ #log4j.logger.com.facebook.infrastructure.gms=DEBUG
38
+ #log4j.logger.com.facebook.infrastructure.db=DEBUG
@@ -0,0 +1,197 @@
1
+ <!--
2
+ ~ Licensed to the Apache Software Foundation (ASF) under one
3
+ ~ or more contributor license agreements. See the NOTICE file
4
+ ~ distributed with this work for additional information
5
+ ~ regarding copyright ownership. The ASF licenses this file
6
+ ~ to you under the Apache License, Version 2.0 (the
7
+ ~ "License"); you may not use this file except in compliance
8
+ ~ with the License. You may obtain a copy of the License at
9
+ ~
10
+ ~ http:/www.apache.org/licenses/LICENSE-2.0
11
+ ~
12
+ ~ Unless required by applicable law or agreed to in writing,
13
+ ~ software distributed under the License is distributed on an
14
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ ~ KIND, either express or implied. See the License for the
16
+ ~ specific language governing permissions and limitations
17
+ ~ under the License.
18
+ -->
19
+ <Storage>
20
+ <!--======================================================================-->
21
+ <!-- Basic Configuration -->
22
+ <!--======================================================================-->
23
+ <ClusterName>Test</ClusterName>
24
+
25
+ <!-- Tables and ColumnFamilies
26
+ Think of a table as a namespace, not a relational table.
27
+ (ColumnFamilies are closer in meaning to those.)
28
+
29
+ There is an implicit table named 'system' for Cassandra internals.
30
+ -->
31
+ <Tables>
32
+ <Table Name="Twitter">
33
+ <KeysCachedFraction>0.01</KeysCachedFraction>
34
+ <ColumnFamily CompareWith="UTF8Type" Name="Users" />
35
+ <ColumnFamily CompareWith="UTF8Type" Name="UserAudits" />
36
+ <ColumnFamily CompareWith="UTF8Type" CompareSubcolumnsWith="UUIDType" ColumnType="Super" Name="UserRelationships" />
37
+ <ColumnFamily CompareWith="UTF8Type" Name="Usernames" />
38
+ <ColumnFamily CompareWith="UTF8Type" Name="Statuses" />
39
+ <ColumnFamily CompareWith="UTF8Type" Name="StatusAudits" />
40
+ <ColumnFamily CompareWith="UTF8Type" CompareSubcolumnsWith="LongType" ColumnType="Super" Name="StatusRelationships" />
41
+ </Table>
42
+
43
+ <Table Name="Multiblog">
44
+ <KeysCachedFraction>0.01</KeysCachedFraction>
45
+ <ColumnFamily CompareWith="UTF8Type" Name="Blogs"/>
46
+ <ColumnFamily CompareWith="UTF8Type" Name="Comments"/>
47
+ </Table>
48
+ </Tables>
49
+
50
+ <!-- Partitioner: any IPartitioner may be used, including your own
51
+ as long as it is on the classpath. Out of the box,
52
+ Cassandra provides
53
+ org.apache.cassandra.dht.RandomPartitioner and
54
+ org.apache.cassandra.dht.OrderPreservingPartitioner.
55
+ Range queries require using OrderPreservingPartitioner or a subclass.
56
+
57
+ Achtung! Changing this parameter requires wiping your data directories,
58
+ since the partitioner can modify the sstable on-disk format.
59
+ -->
60
+ <Partitioner>org.apache.cassandra.dht.OrderPreservingPartitioner</Partitioner>
61
+
62
+ <!-- If you are using the OrderPreservingPartitioner and you know your key
63
+ distribution, you can specify the token for this node to use.
64
+ (Keys are sent to the node with the "closest" token, so distributing
65
+ your tokens equally along the key distribution space will spread
66
+ keys evenly across your cluster.) This setting is only checked the
67
+ first time a node is started.
68
+
69
+ This can also be useful with RandomPartitioner to force equal
70
+ spacing of tokens around the hash space, especially for
71
+ clusters with a small number of nodes. -->
72
+ <InitialToken></InitialToken>
73
+
74
+ <!-- RackAware: Setting this to true instructs Cassandra to try and place the replicas in
75
+ a different rack in the same datacenter and one in a different datacenter
76
+ -->
77
+ <RackAware>false</RackAware>
78
+
79
+ <!-- Number of replicas of the data-->
80
+ <ReplicationFactor>1</ReplicationFactor>
81
+
82
+ <!-- Directories: Specify where Cassandra should store different data on disk
83
+ Keep the data disks and the CommitLog disks separate for best performance
84
+ -->
85
+ <CommitLogDirectory>data/commitlog</CommitLogDirectory>
86
+ <DataFileDirectories>
87
+ <DataFileDirectory>data/data</DataFileDirectory>
88
+ </DataFileDirectories>
89
+ <CalloutLocation>data/callouts</CalloutLocation>
90
+ <BootstrapFileDirectory>data/bootstrap</BootstrapFileDirectory>
91
+ <StagingFileDirectory>data/staging</StagingFileDirectory>
92
+
93
+
94
+ <!-- Add names of hosts that are deemed contact points. Cassandra nodes use
95
+ this list of hosts to find each other and learn the topology of the ring.
96
+ -->
97
+ <Seeds>
98
+ <Seed>127.0.0.1</Seed>
99
+ </Seeds>
100
+
101
+ <!-- Miscellaneous -->
102
+
103
+ <!-- time to wait for a reply from other nodes before failing the command -->
104
+ <RpcTimeoutInMillis>5000</RpcTimeoutInMillis>
105
+ <!-- size to allow commitlog to grow to before creating a new segment -->
106
+ <CommitLogRotationThresholdInMB>128</CommitLogRotationThresholdInMB>
107
+
108
+
109
+ <!-- Local hosts and ports -->
110
+
111
+ <!-- Address to bind to and tell other nodes to connect to.
112
+ You _must_ change this if you want multiple nodes to be able
113
+ to communicate!
114
+
115
+ Leaving it blank leaves it up to InetAddress.getLocalHost().
116
+ This will always do the Right Thing *if* the node is properly
117
+ configured (hostname, name resolution, etc), and the Right
118
+ Thing is to use the address associated with the hostname (it
119
+ might not be). -->
120
+ <ListenAddress>localhost</ListenAddress>
121
+ <!-- TCP port, for commands and data -->
122
+ <StoragePort>7000</StoragePort>
123
+ <!-- UDP port, for membership communications (gossip) -->
124
+ <ControlPort>7001</ControlPort>
125
+
126
+ <!-- The address to bind the Thrift RPC service to. Unlike
127
+ ListenAddress above, you *can* specify 0.0.0.0 here if you want
128
+ Thrift to listen on all interfaces.
129
+
130
+ Leaving this blank has the same effect it does for ListenAddress,
131
+ (i.e. it will be based on the configured hostname of the node).
132
+ -->
133
+ <ThriftAddress>localhost</ThriftAddress>
134
+ <!-- Thrift RPC port (the port clients connect to). -->
135
+ <ThriftPort>9160</ThriftPort>
136
+
137
+
138
+ <!--======================================================================-->
139
+ <!-- Memory, Disk, and Performance -->
140
+ <!--======================================================================-->
141
+
142
+ <!-- Add column indexes to a row after its contents reach this size -->
143
+ <ColumnIndexSizeInKB>256</ColumnIndexSizeInKB>
144
+
145
+ <!--
146
+ The maximum amount of data to store in memory before flushing to
147
+ disk. Note: There is one memtable per column family, and this threshold
148
+ is based solely on the amount of data stored, not actual heap memory
149
+ usage (there is some overhead in indexing the columns).
150
+ -->
151
+ <MemtableSizeInMB>32</MemtableSizeInMB>
152
+
153
+ <!--
154
+ The maximum number of columns in millions to store in memory
155
+ before flushing to disk. This is also a per-memtable setting.
156
+ Use with MemtableSizeInMB to tune memory usage.
157
+ -->
158
+ <MemtableObjectCountInMillions>0.01</MemtableObjectCountInMillions>
159
+
160
+ <!-- Unlike most systems, in Cassandra writes are faster than
161
+ reads, so you can afford more of those in parallel.
162
+ A good rule of thumb is 2 concurrent reads per processor core.
163
+ You especially want more concurrentwrites if you are using
164
+ CommitLogSync + CommitLogSyncDelay. -->
165
+ <ConcurrentReads>8</ConcurrentReads>
166
+ <ConcurrentWrites>32</ConcurrentWrites>
167
+
168
+ <!-- Turn on CommitLogSync to improve durability.
169
+ When enabled, Cassandra won't ack writes until the commit log
170
+ has been synced to disk. This is less necessary in Cassandra
171
+ than in traditional databases since replication reduces the
172
+ odds of losing data from a failure after writing the log
173
+ entry but before it actually reaches the disk.
174
+ -->
175
+ <CommitLogSync>false</CommitLogSync>
176
+ <!-- Delay (in microseconds) during which additional commit log
177
+ entries may be written before fsync. This will increase
178
+ latency slightly, but can vastly improve throughput where
179
+ there are many writers. Set to zero to disable
180
+ (each entry will be synced individually).
181
+ Reasonable values range from a minimal 100 to even 10000
182
+ if throughput matters more than latency. (10000us = 10ms
183
+ write latency isn't even that bad by traditional db
184
+ standards.)
185
+ -->
186
+ <CommitLogSyncDelay>1000</CommitLogSyncDelay>
187
+
188
+
189
+ <!-- Time to wait before garbage-collection deletion markers.
190
+ Set this to a large enough value that you are confident
191
+ that the deletion marker will be propagated to all replicas
192
+ by the time this many seconds has elapsed, even in the
193
+ face of hardware failures. The default value is ten days.
194
+ -->
195
+ <GCGraceSeconds>864000</GCGraceSeconds>
196
+
197
+ </Storage>
data/lib/cassandra.rb CHANGED
@@ -1,160 +1,22 @@
1
- require 'properties'
2
- require 'tags'
3
1
 
4
- # Markaby-ish way to declare CSS
5
- class Cassandra
6
-
7
- METHODS = %w( class instance_eval send __send__ __id__ )
8
- instance_methods.each { |m| undef_method( m ) unless METHODS.include? m }
9
-
10
- attr_reader :data
11
-
12
- def initialize(sel=nil)
13
- @data = []
14
- @selectors = [ sel ]
15
- @properties = []
16
-
17
- # Primitive state machine
18
- # possible states are :closed_block, :chain, :open_block
19
- @state = :closed_block
20
- end
21
-
22
- def self.process(*args,&block)
23
- self.new.process(*args,&block)
24
- end
25
-
26
- def process(*args, &block)
27
- if block
28
- instance_eval(&block)
29
- else
30
- instance_eval(args.join("\n"))
31
- end
32
- self
33
- end
34
-
35
- def to_s
36
- @data.map do |sel|
37
- properties = sel.last.join("\n ")
38
- "#{sel.first} {\n #{properties}\n}\n"
39
- end.join
40
- end
41
-
42
-
43
-
44
- # Pushes an empty array on the properties stack and registers
45
- # that array (against the current selector) in @data
46
- def new_property_set
47
- @properties.push []
48
- @data << [@selectors[-1], @properties[-1] ]
49
- end
50
-
51
-
52
- # Declare a CSS selector using a block. May be chained and nested.
53
- def selector(sel)
54
- if block_given?
55
- open_block(sel)
56
- yield
57
- closed_block
58
- else
59
- chain(sel)
60
- end
61
- self
62
- end
63
-
64
- # Catch unknown methods and treat them as CSS class or id selectors.
65
- def method_missing(name, &block)
66
- sel = selectify(name)
67
- if block_given?
68
- open_block(sel)
69
- yield
70
- closed_block
71
- else
72
- chain(sel)
73
- end
74
- self
75
- end
76
-
77
- # bang methods represent CSS ids. Otherwise CSS classes.
78
- def selectify(method_name)
79
- matches = method_name.to_s.match( /([\w_]+)!$/)
80
- matches ? "##{matches[1]}" : ".#{method_name}"
81
- end
82
-
83
-
84
- # define tag methods that delegate to selector
85
- methods = HTML_TAGS.map do |tag|
86
- <<-METHOD
87
- def #{tag}(&block)
88
- selector('#{tag}', &block)
89
- end
90
- METHOD
91
- end.join; module_eval(methods)
92
-
93
- # define methods for CSS properties.
94
- CSS_PROPERTIES.each do |method_name|
95
- define_method method_name do |*args|
96
- css_attr = method_name.gsub('_', '-')
97
- property(css_attr, args)
98
- end
99
- end
100
-
101
- # Add a property declaration string to the current selector's properties array.
102
- def property(css_attr, *args)
103
- @properties[-1] << "#{css_attr}: #{args.join(' ')};"
104
- end
105
-
106
- ## State transitions
107
-
108
- # Push the accumulated selector and a new property array onto the
109
- # tops of their respected stacks
110
- def open_block(new_selector)
111
- case @state
112
- when :closed_block, :open_block
113
- combined_selector = [@selectors[-1], new_selector].compact.join(" ")
114
- @selectors.push combined_selector
115
- new_property_set
116
- when :chain
117
- @selectors[-1] = "#{@selectors[-1]}#{new_selector}"
118
- new_property_set
119
- else
120
- raise "You can't get to :open_block from #{@state.inspect}"
121
- end
122
-
123
- @state = :open_block
124
- end
125
-
126
- # Pushes accumulated selector on the stack without generating a new properties array.
127
- def chain(new_selector)
128
- case @state
129
- when :closed_block, :open_block
130
- combined_selector = [@selectors[-1], new_selector].compact.join(" ")
131
- @selectors.push( combined_selector)
132
- when :chain
133
- @selectors[-1] = "#{@selectors[-1]}#{new_selector}"
134
- else
135
- raise "You can't get to :chain from #{@state.inspect}"
136
- end
137
-
138
- @state = :chain
139
- end
140
-
141
- # Pop the selector string and property array for the closing block
142
- # off of their respective stacks
143
- def closed_block
144
- case @state
145
- when :open_block, :closed_block
146
- @selectors.pop
147
- @properties.pop
148
- else
149
- raise "You can't get to :closed_block from #{@state.inspect}"
150
- end
151
-
152
- @state = :closed_block
153
- end
154
-
155
-
156
-
157
-
158
- end
159
-
160
- Cssy = Cassy = Cassandra
2
+ require 'zlib'
3
+ require 'rubygems'
4
+ require 'thrift'
5
+
6
+ HERE = File.expand_path(File.dirname(__FILE__))
7
+
8
+ $LOAD_PATH << "#{HERE}/../vendor/gen-rb"
9
+ require "#{HERE}/../vendor/gen-rb/cassandra"
10
+
11
+ $LOAD_PATH << "#{HERE}"
12
+ require 'cassandra/array'
13
+ require 'cassandra/time'
14
+ require 'cassandra/comparable'
15
+ require 'cassandra/uuid'
16
+ require 'cassandra/long'
17
+ require 'cassandra/safe_client'
18
+ require 'cassandra/serialization'
19
+ require 'cassandra/ordered_hash'
20
+ require 'cassandra/constants'
21
+ require 'cassandra/helper'
22
+ require 'cassandra/cassandra'