Permalink
Browse files

First commit of WIP

  • Loading branch information...
1 parent fa45869 commit ac0b5152236d072f995085591ba2137832c1dca0 @b committed Mar 10, 2010
@@ -0,0 +1,32 @@
+set_unless[:cassandra][:cluster_name] = "Test Cluster"
+set_unless[:cassandra][:auto_bootstrap] = false
+set_unless[:cassandra][:keyspaces] = []
+set_unless[:cassandra][:authenticator] = "org.apache.cassandra.auth.AllowAllAuthenticator"
+set_unless[:cassandra][:partitioner] = "org.apache.cassandra.dht.RandomPartitioner"
+set_unless[:cassandra][:initial_token] = ""
+set_unless[:cassandra][:commit_log_dir] = "/var/lib/cassandra/commitlog"
+set_unless[:cassandra][:data_file_dirs] = ["/var/lib/cassandra/data"]
+set_unless[:cassandra][:callout_location] = "/var/lib/cassandra/callouts"
+set_unless[:cassandra][:staging_file_dir] = "/var/lib/cassandra/staging"
+set_unless[:cassandra][:seeds] = ["127.0.0.1"]
+set_unless[:cassandra][:rpc_timeout] = 5000
+set_unless[:cassandra][:commit_log_rotation_threshold] = 128
+set_unless[:cassandra][:listen_addr] = "localhost"
+set_unless[:cassandra][:storage_port] = 7000
+set_unless[:cassandra][:thrift_addr] = "localhost"
+set_unless[:cassandra][:thrift_port] = 9160
+set_unless[:cassandra][:thrift_framed_transport] = false
+set_unless[:cassandra][:disk_access_mode] = "auto"
+set_unless[:cassandra][:sliced_buffer_size] = 64
+set_unless[:cassandra][:flush_data_buffer_size] = 32
+set_unless[:cassandra][:flush_index_buffer_size] = 8
+set_unless[:cassandra][:column_index_size] = 64
+set_unless[:cassandra][:memtable_throughput] = 64
+set_unless[:cassandra][:binary_memtable_throughput] = 256
+set_unless[:cassandra][:memtable_ops] = 0.3
+set_unless[:cassandra][:memtable_flush_after] = 60
+set_unless[:cassandra][:concurrent_reads] = 8
+set_unless[:cassandra][:concurrent_writes] = 32
+set_unless[:cassandra][:commit_log_sync] = "periodic"
+set_unless[:cassandra][:commit_log_sync_period] = 10000
+set_unless[:cassandra][:gc_grace] = 864000
View
@@ -0,0 +1,22 @@
+maintainer "Benjamin Black"
+maintainer_email "b@b3k.us"
+license "Apache 2.0"
+description "Installs and configures the Cassandra distributed storage system"
+version "0.1"
+recipe "cassandra::autoconf", "Automatically configure nodes from chef-server information."
+
+%w{ubuntu debian}.each do |os|
+ supports os
+end
+
+attribute "cassandra",
+ :display_name => "Cassandra",
+ :description => "Hash of Cassandra attributes",
+ :type => "hash"
+
+attribute "cassandra/cluster_name",
+ :display_name => "Cassandra cluster name",
+ :description => "The name for the Cassandra cluster in which this node should participate. The default is 'Test Cluster'.",
+ :default => "Test Cluster"
+
+# Lots more goes here...
@@ -0,0 +1,56 @@
+#
+# Author:: Benjamin Black (<b@b3k.us>)
+# Cookbook Name:: cassandra
+# Recipe:: autoconf
+#
+# Copyright 2010, Benjamin Black
+#
+# Licensed 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.
+#
+
+# STRUCTURE OF THE CASSANDRA DATA BAG
+#
+# {:cassandra =>
+# {:clusters =>
+# {<cluster name> =>
+# {:keyspaces =>
+# [{:name => <keyspace name>,
+# :columns => [{<attrib> => <value>}, ...],
+# :replica_placement_strategy => <strategy>,
+# :replication_factor => <factor>,
+# :end_point_snitch => <snitch>
+# }],
+# :seeds =>
+# [<seed addr>, ...],
+# <other per cluster settings>
+# }
+# }
+# }
+# }
+#
+# COLUMN ATTRIBS
+#
+# Simple columns: {:name => <column name>, :compare_with => <comparison>}
+# Super columns: {:name => <column name>, :compare_with => <comparison>,
+# :column_type => "Super", :compare_subcolumns_with => <comparison>}
+#
+
+# Load cluster settings from chef-server
+cassandra_info = data_bag('cassandra')
+node[:cassandra].merge!(cassandra_info[:clusters][node[:cassandra][:cluster_name]])
+
+# Configure the various addrs for binding
+node[:cassandra][:listen_addr] = node[:ipaddress]
+node[:cassandra][:thrift_addr] = node[:ipaddress]
+
+include_recipe "cassandra::default"
@@ -0,0 +1,36 @@
+#
+# Author:: Benjamin Black (<b@b3k.us>)
+# Cookbook Name:: cassandra
+# Recipe:: default
+#
+# Copyright 2010, Benjamin Black
+#
+# Licensed 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 "cassandra" do
+ action :install
+end
+
+service "cassandra" do
+ supports :status => true, :restart => true, :reload => true
+ action [ :enable, :start ]
+end
+
+template "/etc/cassandra/storage-conf.xml" do
+ source "storage-conf.xml.erb"
+ owner "root"
+ group "root"
+ mode 0644
+ notifies :restart, resources(:service => "cassandra")
+end
@@ -0,0 +1,61 @@
+<!-- Generated by Chef for <%= @node[:fqdn] %> -->
+<Storage>
+ <ClusterName><%= @node[:cassandra][:cluster_name] %></ClusterName>
+ <AutoBootstrap><%= @node[:cassandra][:auto_bootstrap] %></AutoBootstrap>
+ <Keyspaces>
+ <% @node[:cassandra][:keyspaces].each do |keyspace| %>
+ <Keyspace Name="<%= keyspace[:name] %>">
+ <% keyspace[:columns].each do |column| %>
+ <ColumnFamily <%= (column.keys.map do |attrib|
+ (attrib.to_s.split('_').map do |part|
+ part.capitalize
+ end).join('') + "=\"" + column[attrib] + "\""
+ end).join(' ') %> />
+ <% end %>
+ <ReplicaPlacementStrategy><%= keyspace[:replica_placement_strategy] %></ReplicaPlacementStrategy>
+ <ReplicationFactor><%= keyspace[:replication_factor] %></ReplicationFactor>
+ <EndPointSnitch><%= keyspace[:end_point_snitch] %></EndPointSnitch>
+ </Keyspace>
+ <% end %>
+ </Keyspaces>
+ <Authenticator><%= @node[:cassandra][:authenticator] %></Authenticator>
+ <Partitioner><%= @node[:cassandra][:partitioner] %></Partitioner>
+ <InitialToken><%= @node[:cassandra][:initial_token] %></InitialToken>
+ <CommitLogDirectory><%= @node[:cassandra][:commit_log_dir] %></CommitLogDirectory>
+ <DataFileDirectories>
+ <% @node[:cassandra][:data_file_dirs].each do |dir| %>
+ <DataFileDirectory><%= dir %></DataFileDirectory>
+ <% end %>
+ </DataFileDirectories>
+ <CalloutLocation><%= @node[:cassandra][:callout_location] %></CalloutLocation>
+ <StagingFileDirectory><%= @node[:cassandra][:staging_file_dir] %></StagingFileDirectory>
+ <Seeds>
+ <% @node[:cassandra][:seeds].each do |seed| %>
+ <Seed><%= seed %></Seed>
+ <% end %>
+ </Seeds>
+ <RpcTimeoutInMillis><%= @node[:cassandra][:rpc_timeout] %></RpcTimeoutInMillis>
+ <CommitLogRotationThresholdInMB><%= @node[:cassandra][:commit_log_rotation_threshold] %></CommitLogRotationThresholdInMB>
+ <ListenAddress><%= @node[:cassandra][:listen_addr] %></ListenAddress>
+ <StoragePort><%= @node[:cassandra][:storage_port] %></StoragePort>
+ <ThriftAddress><%= @node[:cassandra][:thrift_addr] %></ThriftAddress>
+ <ThriftPort><%= @node[:cassandra][:thrift_port] %></ThriftPort>
+ <ThriftFramedTransport><%= @node[:cassandra][:thrift_framed_transport] %></ThriftFramedTransport>
+ <DiskAccessMode><%= @node[:cassandra][:disk_access_mode] %></DiskAccessMode>
+ <SlicedBufferSizeInKB><%= @node[:cassandra][:sliced_buffer_size] %></SlicedBufferSizeInKB>
+ <FlushDataBufferSizeInMB><%= @node[:cassandra][:flush_data_buffer_size] %></FlushDataBufferSizeInMB>
+ <FlushIndexBufferSizeInMB><%= @node[:cassandra][:flush_index_buffer_size] %></FlushIndexBufferSizeInMB>
+ <ColumnIndexSizeInKB><%= @node[:cassandra][:column_index_size] %></ColumnIndexSizeInKB>
+ <MemtableThroughputInMB><%= @node[:cassandra][:memtable_throughput] %></MemtableThroughputInMB>
+ <BinaryMemtableThroughputInMB><%= @node[:cassandra][:binary_memtable_throughput] %></BinaryMemtableThroughputInMB>
+ <MemtableOperationsInMillions><%= @node[:cassandra][:memtable_ops] %></MemtableOperationsInMillions>
+ <MemtableFlushAfterMinutes><%= @node[:cassandra][:memtable_flush_after] %></MemtableFlushAfterMinutes>
+ <ConcurrentReads><%= @node[:cassandra][:concurrent_reads] %></ConcurrentReads>
+ <ConcurrentWrites><%= @node[:cassandra][:concurrent_writes] %></ConcurrentWrites>
+ <CommitLogSync><%= @node[:cassandra][:commit_log_sync] %></CommitLogSync>
+ <CommitLogSyncPeriodInMS><%= @node[:cassandra][:commit_log_sync_period] %></CommitLogSyncPeriodInMS>
+ <% unless @node[:cassandra][:commit_log_sync_batch_window].nil? %>
+ <CommitLogSyncBatchWindowInMS><%= @node[:cassandra][:commit_log_sync_batch_window] %></CommitLogSyncBatchWindowInMS>
+ <% end %>
+ <GCGraceSeconds><%= @node[:cassandra][:gc_grace] %></GCGraceSeconds>
+</Storage>

0 comments on commit ac0b515

Please sign in to comment.