Esempio n. 1
0
def stop_cassandra_process():
  """
  Stop the protocol listeners for gossip, thrift and binary
  Stop any compaction and index building
  Stop backups
  Now drain
  Should be safe to kill now
  Kill the process of CassandraDaemon assuming there is the process
  """
  run("%(nodetool)s disablebinary" % env)
  run("%(nodetool)s disablethrift" % env)
  run("%(nodetool)s disablegossip" % env)
  run("%(nodetool)s disablebackup" % env)
  run("%(nodetool)s stop compaction" % env)
  run("%(nodetool)s stop index_build" % env)
  run("%(nodetool)s drain" % env)
  r = deployments.pkill('CassandraDaemon', 30, wait_secs=30)
  if r != 0:
    raise Exception("could not kill existing CassandraDaemon")
Esempio n. 2
0
def _switch_cassandra_running_build(casssandra_target_running_build):
  """ 'Hot switch' the cassandra running build with a replaced build.
      Steps:
        1. Terminate CassandraDaemon
        2. Relink cassandra_latest to deployed build
        3. Restart CassandraDaemon
  """
  print yellow("Switching to build: " + casssandra_target_running_build)
  print green("Terminating CassandraDaemon")
  r = deployments.pkill('CassandraDaemon', 30, wait_secs=30)
  if r != 0:
    raise Exception("could not kill existing CassandraDaemon")

  with cd("%(root)s" % env):
    run("unlink cassandra_latest")
    run("ln -s %(casssandra_target_running_build)s cassandra_latest" % locals())
    run("mkdir -p %(cassandra_dir)s" % env)

  _start_cassandra_process()
Esempio n. 3
0
def push_cassandra_config(pagedb_hosts, seed, project, roleval):
  """
  Generates yaml configuration and pushes to each node. Assumes cassandra is already installed on each node
  """
  hosts = pagedb_hosts.split(";")
  i = 0
  num = len(hosts)
  print hosts, num
  for host in hosts:
    # token range for Murmur3Partitioner is [-2**63, 2**63-1]
#    token = (i * (2**64) / num) - (2**63)
#    i = i + 1
    with settings(host_string=host, user="******"):
      with settings(warn_only=True):
        r = deployments.pkill('CassandraDaemon',30)
        if r != 0:
          raise Exception("could not kill existing CassandraDaemon")

      _push_cassandra_config(seed, project, roleval)
      _start_cassandra()
      print green("Waiting 2 min after starting cassandra node %s" % str(host))
      time.sleep(120)
    pass
Esempio n. 4
0
def _start_cassandra():
  with settings(warn_only=True):
    r = deployments.pkill('CassandraDaemon', 30)
    if r != 0:
      raise Exception("could not kill existing CassandraDaemon")
  run("nohup /mnt/cassandra_latest/bin/cassandra > /dev/null &", pty=False)