Chapter 09/circuit-oneops-1-master/components/cookbooks/spark-v1/recipes/spark_helper.rb
# Determines whether this recipe is being run on a Spark master.
#
# INPUT:
#
# RETURNS:
# A boolean value indicating whether this is a Spark master
#
Determines whether this recipe is being run on a Spark master.
INPUT.

A boolean value indicating whether this is a Spark master
Determines whether this recipe is being run on a Spark master . INPUT . A boolean value indicating whether this is a Spark master
def check_is_spark_master()
  isSparkMaster = false
  if node.workorder.payLoad.has_key?("cassDef")
    sparkInfo = get_spark_info_cassandra()
    isSparkMaster = sparkInfo[:is_spark_master]
  else
    configName = node['app_name']
    isSparkMaster = true
    dependentCiClass = "bom.oneops.1." + configName.slice(0,1).capitalize + configName.slice(1..-1)
    spark_configs=node.workorder.payLoad.DependsOn.reject{ |d| d['ciClassName'] != dependentCiClass }
    if (!spark_configs.nil? && !spark_configs[0].nil?)
      isSparkMaster = false
    end
  end
  if isSparkMaster
    Chef::Log.debug("check_is_spark_master: #{node.workorder.rfcCi.ciName} IS the Spark master")
  else
    Chef::Log.debug("check_is_spark_master: #{node.workorder.rfcCi.ciName} is NOT the Spark master")
  end
  return isSparkMaster
end
def check_is_spark_master ( ) isSparkMaster = false if node . workorder . payLoad . has_key? ( "cassDef" ) sparkInfo = get_spark_info_cassandra ( ) isSparkMaster = sparkInfo [ :is_spark_master ] else configName = node [ 'app_name' ] isSparkMaster = true dependentCiClass = "bom.oneops.1." + configName . slice ( 0 , 1 ) . capitalize + configName . slice ( 1 .. - 1 ) spark_configs = node . workorder . payLoad . DependsOn . reject { | d | d [ 'ciClassName' ] != dependentCiClass } if ( ! spark_configs . nil? && ! spark_configs [ 0 ] . nil? ) isSparkMaster = false end end if isSparkMaster Chef :: Log . debug ( "check_is_spark_master: #{node.workorder.rfcCi.ciName} IS the Spark master" ) else Chef :: Log . debug ( "check_is_spark_master: #{node.workorder.rfcCi.ciName} is NOT the Spark master" ) end return isSparkMaster end
Determines whether this recipe is being run on a Spark master.
Determines whether this recipe is being run on a Spark master .
# Assume that this is a Spark master unless dependent configurations are found # Construct the name of dependent classes to look for. # See if there are any spark configurations this is dependent on. # Dependent configurations were found, so this is not a Spark master