Hey all,

I'm trying to write a puppet module to deploy the cassandra database
automatically. I'm using puppet templates to provide the IP address to the
listen_address parameter of the cassandra.yaml file like so:

listen_address: <%= ipaddress %>

So far that part's working beautifully! However in cassandra there is the
concept of the 'initial_token' which is based on another concept called
'partition type' which is used to dictate what data goes where in a
cassandra cluster.

Now in determining the 'inital_token' you generally use a mathematical
formula which you can read some more about here if I've managed to pique
anyone's curiosity:

http://www.datastax.com/documentation/cassandra/1.2/cassandra/configuration/configGenTokens_c.html

The type of data partition I'm using is called 'murmur3' and it uses this
algorithm to determine a nodes' initial_token it uses to join a cassandra
cluster.

The murmur3 token generation process is described like this:

Use this method for generating tokens when you are *not* using virtual
nodes (vnodes) and using the
Murmur3Partitioner<http://www.datastax.com/documentation/cassandra/1.2/cassandra/architecture/architecturePartitionerM3P_c.html#concept_ds_ns5_spf_fk>
(default).
This partitioner uses a maximum possible range of hash values from -2 63 to
+2 63 -1. To calculate tokens for this partitioner:

python -c 'print [str(((2**64 / number_of_tokens) * i) - 2**63) for i
in range(number_of_tokens)]'

For example, to generate tokens for 6 nodes:

python -c 'print [str(((2**64 / 6) * i) - 2**63) for i in range(6)]'

The command displays the token for each node:

[ '-9223372036854775808', '-6148914691236517206', '-3074457345618258604',
  '-2' , '3074457345618258600', '6148914691236517202' ]


What I'm struggling to do is to come up with a way to express this
idea in puppet terms that I can use in a puppet template so that I can
have the template automatically generate an answer to the
initial_token question such that it will turn up the the
cassandra.yaml file like so:

intial_token: -9223372036854775808


I am definitely up for any suggestions anyone may have for this rather
fascinating problem!


Thanks

Tim







-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOZy0enLe60PgmTut-2A6oXct_h1LWRvPidee4E0SA2HfkUH8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to