Permalink
Browse files

Change to default OPP and be Rackspace aware for address selection

  • Loading branch information...
1 parent ff6f3e2 commit 0d38579f0fb3ffc408e33654cad27b2f25d01c87 @b committed Mar 21, 2010
@@ -2,7 +2,7 @@
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][:partitioner] = "org.apache.cassandra.dht.OrderPreservingPartitioner"
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"]
@@ -5,6 +5,7 @@
version "0.1"
recipe "cassandra::autoconf", "Automatically configure nodes from chef-server information."
recipe "cassandra::ec2snitch", "Automatically configure properties snitch for clusters on EC2."
+depends "java"
%w{ubuntu debian}.each do |os|
supports os
@@ -46,13 +46,25 @@
# they belong (nodes are in exactly 1 cluster in this version of the cookbook), and may optionally be
# tagged with [:cassandra][:seed] set to true if a node is to act as a seed.
clusters = data_bag_item('cassandra', 'clusters')
-node[:cassandra] = Chef::Mixin::DeepMerge.deep_merge!(node[:cassandra], clusters[node[:cassandra][:cluster_name]])
+clusters[node[:cassandra][:cluster_name]].each_pair do |k, v|
+ node[:cassandra][k] = v
+end
+
+local_addr = "" ; seeds = []
+if node[:rackspace]
+ local_addr = node[:rackspace][:private_ip]
+ seeds = search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND cassandra_seed:true").map {|n| n['rackspace']['private_ip']}
+ seeds = ["127.0.0.1"] unless seeds.length > 0
+else
+ local_addr = node[:ipaddress]
+ seeds = search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND cassandra_seed:true").map {|n| n['ipaddress']}
+ seeds = ["127.0.0.1"] unless seeds.length > 0
+end
-seeds = search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND cassandra_seed:true").map {|n| n['ipaddress']}
node[:cassandra][:seeds] = seeds
# Configure the various addrs for binding
-node[:cassandra][:listen_addr] = node[:ipaddress]
-node[:cassandra][:thrift_addr] = node[:ipaddress]
+node[:cassandra][:listen_addr] = local_addr
+node[:cassandra][:thrift_addr] = local_addr
include_recipe "cassandra::default"
@@ -18,6 +18,8 @@
# limitations under the License.
#
+include_recipe "java"
+
package "cassandra" do
action :install
end
@@ -18,8 +18,8 @@
# limitations under the License.
#
-# To use this, you MUST install contrib/property_snitch and set the keyspace[:end_point_snitch]
-# to org.apache.cassandra.locator.PropertyFileEndPointSnitch. See contrib/property_snitch/README.txt
+# To use this, you MUST install contrib/property_snitch and set the keyspace[:e
+# to org.apache.cassandra.locator.PropertyFileEndPointSnitch. See contrib/prop
# in the cassandra distribution for details.
@topo_map = search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND ec2:placement_availability_zone").map do |n|

0 comments on commit 0d38579

Please sign in to comment.