Пример #1
0
class CassandraTokensTestCase(unittest.TestCase):
    def setUp(self):
        self.cassandraToken = CassandraTokens()

    def tearDown(self):
        self.cassandraToken = None

    def testGenerateRing(self):
        self.cassandraToken.nodes(7)
        self.cassandraToken.generateRing()
        expectedRing = [
            0L,
            24305883351495604533098186245126300818L,
            48611766702991209066196372490252601636L,
            72917650054486813599294558735378902454L,
            97223533405982418132392744980505203272L,
            121529416757478022665490931225631504090L,
            145835300108973627198589117470757804908L,
        ]
        self.assertEqual(expectedRing, self.cassandraToken.ring)

    def testCalculate10NodesLastToken(self):
        self.cassandraToken.nodes(10)
        token = self.cassandraToken.calculateToken(9)
        expectedToken = 153127065114422308558518573344295695154L
        self.assertEqual(expectedToken, token)

    def testCalculate1NodeToken1(self):
        self.cassandraToken.nodes(1)
        token = self.cassandraToken.calculateToken(0)
        expectedToken = 0L
        self.assertEqual(expectedToken, token)
Пример #2
0
#!/usr/bin/python

#
# A simple script to generate a set of tokens that can be used in a apache cassandra cluster.
# The script relys on the module "cassandrautil" to be available.
#
# The scripts asks for a cluster size then prints that many keys
# 
# Based on benjamin black cassandra summit talk (http://www.slideshare.net/benjaminblack/cassandra-summit-2010-operations-troubleshooting-intro).
# Author: Artie Copeland <*****@*****.**>
# Distributed under the GNU General Public License, version 3.0.
# Latest version: http://github.com/yestech/yessandbox/blob/master/cassandra-gen-tokens.py
#
# 
#

from cassandrautil import CassandraTokens

nodes = int(raw_input("How many nodes in the cluster -> "))
t = CassandraTokens()
t.nodes(nodes)
t.generateRing()
t.printTokens()
t.printNodes()
t.printRing()


Пример #3
0
 def setUp(self):
     self.cassandraToken = CassandraTokens()