AppController/lib/cassandra_helper.rb
# Starts Cassandra, and waits for it to start the Thrift service locally.
#
# Args:
#   clear_datastore: Remove any pre-existent data in the database.
#   needed: The number of nodes required for quorum.
Starts Cassandra, and waits for it to start the Thrift service locally.
Args:
clear_datastore: Remove any pre-existent data in the database.
needed: The number of nodes required for quorum.
Starts Cassandra and waits for it to start the Thrift service locally . Args : clear_datastore : Remove any pre - existent data in the database . needed : The number of nodes required for quorum .
def start_cassandra(clear_datastore, needed)
  if clear_datastore
    Djinn.log_info("Erasing datastore contents")
    Djinn.log_run("rm -rf /opt/appscale/cassandra*")
    Djinn.log_run("rm /var/log/appscale/cassandra/system.log")
  end
  start_cmd = "#{CASSANDRA_EXECUTABLE} start -p #{PID_FILE}"
  stop_cmd = "/bin/bash -c 'kill -s SIGTERM `cat #{PID_FILE}`'"
  MonitInterface.start(:cassandra, start_cmd, stop_cmd, [9999], nil, nil, nil,
                       PID_FILE, START_TIMEOUT)
  Djinn.log_info('Waiting for Cassandra to start')
  sleep(SMALL_WAIT) until system("#{NODETOOL} status > /dev/null 2>&1")
  while true
    output = `"#{NODETOOL}" status`
    nodes_ready = 0
    output.split("\n").each{ |line|
      nodes_ready += 1 if line.start_with?('UN')
    }
    Djinn.log_debug("#{nodes_ready} nodes are up. #{needed} are needed.")
    break if nodes_ready >= needed
    sleep(SMALL_WAIT)
  end
end
def start_cassandra ( clear_datastore , needed ) if clear_datastore Djinn . log_info ( "Erasing datastore contents" ) Djinn . log_run ( "rm -rf /opt/appscale/cassandra*" ) Djinn . log_run ( "rm /var/log/appscale/cassandra/system.log" ) end start_cmd = "#{CASSANDRA_EXECUTABLE} start -p #{PID_FILE}" stop_cmd = "/bin/bash -c 'kill -s SIGTERM `cat #{PID_FILE}`'" MonitInterface . start ( :cassandra , start_cmd , stop_cmd , [ 9999 ] , nil , nil , nil , PID_FILE , START_TIMEOUT ) Djinn . log_info ( 'Waiting for Cassandra to start' ) sleep ( SMALL_WAIT ) until system ( "#{NODETOOL} status > /dev/null 2>&1" ) while true output = ` " #{ NODETOOL } " status ` nodes_ready = 0 output . split ( "\n" ) . each { | line | nodes_ready += 1 if line . start_with? ( 'UN' ) } Djinn . log_debug ( "#{nodes_ready} nodes are up. #{needed} are needed." ) break if nodes_ready >= needed sleep ( SMALL_WAIT ) end end
Starts Cassandra, and waits for it to start the Thrift service locally.
Starts Cassandra and waits for it to start the Thrift service locally .
# Ensure enough Cassandra nodes are available.
clear_datastore
<not_specific>
needed
<not_specific>