AppController/djinn.rb
# Checks if the primary database node is ready. For Cassandra, this is needed
# because the seed node needs to start before the other nodes.
# Args:
#   secret: A string that authenticates the caller.
# Returns:
#   A string indicating whether or not the primary database node is ready.
Checks if the primary database node is ready. For Cassandra, this is needed
because the seed node needs to start before the other nodes.
Args:
secret: A string that authenticates the caller.
Returns:
A string indicating whether or not the primary database node is ready.
Checks if the primary database node is ready . For Cassandra this is needed because the seed node needs to start before the other nodes . Args : secret : A string that authenticates the caller . Returns : A string indicating whether or not the primary database node is ready .
def primary_db_is_up(secret)
    return BAD_SECRET_MSG unless valid_secret?(secret)
    primary_ip = get_db_master.private_ip
    unless my_node.is_db_master?
      Djinn.log_debug("Asking #{primary_ip} if database is ready.")
      acc = AppControllerClient.new(get_db_master.private_ip, @@secret)
      begin
        return acc.primary_db_is_up()
      rescue FailedNodeException
        Djinn.log_warn("Unable to ask #{primary_ip} if database is ready.")
        return NOT_READY
      end
    end
    lock_obtained = NODETOOL_LOCK.try_lock
    begin
      return NOT_READY unless lock_obtained
      output = `"#{NODETOOL}" status`
      ready = false
      output.split("\n").each{ |line|
        ready = true if line.start_with?('UN') && line.include?(primary_ip)
      }
      return "#{ready}"
    ensure
      NODETOOL_LOCK.unlock
    end
  end
def primary_db_is_up ( secret ) return BAD_SECRET_MSG unless valid_secret? ( secret ) primary_ip = get_db_master . private_ip unless my_node . is_db_master? Djinn . log_debug ( "Asking #{primary_ip} if database is ready." ) acc = AppControllerClient . new ( get_db_master . private_ip , @@secret ) begin return acc . primary_db_is_up ( ) rescue FailedNodeException Djinn . log_warn ( "Unable to ask #{primary_ip} if database is ready." ) return NOT_READY end end lock_obtained = NODETOOL_LOCK . try_lock begin return NOT_READY unless lock_obtained output = ` " #{ NODETOOL } " status ` ready = false output . split ( "\n" ) . each { | line | ready = true if line . start_with? ( 'UN' ) && line . include? ( primary_ip ) } return "#{ready}" ensure NODETOOL_LOCK . unlock end end
Checks if the primary database node is ready.
Checks if the primary database node is ready .
secret
<not_specific>