Esempio n. 1
0
def get_pid_file():
  """
  Fetches the pid file, which will be used to get the status of the HAWQ Master, Standby
  or Segments
  """

  config = Script.get_config()
  
  component_name = config['componentName']
  component = "master" if component_name in ["HAWQMASTER", "HAWQSTANDBY"] else "segment"
  hawq_pid_file = os.path.join(hawq_constants.hawq_pid_dir, "hawq-{0}.pid".format(component))

  File(hawq_pid_file, action='delete')
  utils.create_dir_as_hawq_user(hawq_constants.hawq_pid_dir)

  #Get hawq_master_directory or hawq_segment_directory value from hawq-site.xml depending 
  #on the component
  hawq_site_directory_property = "hawq_{0}_directory".format(component)
  
  #hawq-site content from Ambari server will not be available when the 
  #command type is STATUS_COMMAND. Hence, reading it directly from the local file
  postmaster_pid_file = os.path.join(common.get_local_hawq_site_property(
      hawq_site_directory_property), hawq_constants.postmaster_pid_filename)

  pid = ""
  if os.path.exists(postmaster_pid_file):
    with open(postmaster_pid_file, 'r') as fh:
      pid = fh.readline().strip()

  if not pid:
    raise Fail("Failed to fetch pid from {0}".format(postmaster_pid_file))

  File(hawq_pid_file, content=pid, owner=hawq_constants.hawq_user, group=hawq_constants.hawq_user)

  return hawq_pid_file
Esempio n. 2
0
def create_temp_dirs(dir_paths):
  """
  Creates the temp directories (hawq_master_temp_dir or hawq_segment_temp_dir) for HAWQ
  """
  for path in dir_paths.split(','):
    if path != "":
      utils.create_dir_as_hawq_user(path)
Esempio n. 3
0
def get_pid_file():
  """
  Fetches the pid file, which will be used to get the status of the HAWQ Master, Standby
  or Segments
  """

  config = Script.get_config()
  
  component_name = config['componentName']
  component = "master" if component_name in ["HAWQMASTER", "HAWQSTANDBY"] else "segment"
  hawq_pid_file = os.path.join(hawqconstants.hawq_pid_dir, "hawq-{0}.pid".format(component))

  File(hawq_pid_file, action='delete')
  utils.create_dir_as_hawq_user(hawqconstants.hawq_pid_dir)

  #Get hawq_master_directory or hawq_segment_directory value from hawq-site.xml depending 
  #on the component
  hawq_site_directory_property = "hawq_{0}_directory".format(component)
  
  #hawq-site content from Ambari server will not be available when the 
  #command type is STATUS_COMMAND. Hence, reading it directly from the local file
  postmaster_pid_file = os.path.join(common.get_local_hawq_site_property(
      hawq_site_directory_property), hawqconstants.postmaster_pid_filename)

  pid = ""
  if os.path.exists(postmaster_pid_file):
    with open(postmaster_pid_file, 'r') as fh:
      pid = fh.readline().strip()

  if not pid:
    raise Fail("Failed to fetch pid from {0}".format(postmaster_pid_file))

  File(hawq_pid_file, content=pid, owner=hawqconstants.hawq_user, group=hawqconstants.hawq_user)

  return hawq_pid_file
Esempio n. 4
0
def create_master_dir(dir_path):
    """
  Creates the master directory (hawq_master_dir or hawq_segment_dir) for HAWQ
  """
    utils.create_dir_as_hawq_user(dir_path)
    Execute("chmod 700 {0}".format(dir_path),
            user=hawq_constants.root_user,
            timeout=hawq_constants.default_exec_timeout)
  def __init_segment():
    import params

    # Create segment directories
    utils.create_dir_as_hawq_user(params.hawq_segment_dir)
    utils.create_dir_as_hawq_user(params.hawq_segment_temp_dir.split(','))

    # Initialize hawq segment
    utils.exec_hawq_operation(hawq_constants.INIT, "{0} -a -v".format(hawq_constants.SEGMENT))
Esempio n. 6
0
  def __init_segment():
    import params

    # Create segment directories
    utils.create_dir_as_hawq_user(params.hawq_segment_dir)
    utils.create_dir_as_hawq_user(params.hawq_segment_temp_dir.split(','))

    # Initialize hawq segment
    utils.exec_hawq_operation(hawq_constants.INIT, "{0} -a -v".format(hawq_constants.SEGMENT))
Esempio n. 7
0
def __create_local_dirs():
  """
  Creates the required local directories for HAWQ
  """
  import params
  # Create Master directories
  utils.create_dir_as_hawq_user(params.hawq_master_dir)
  utils.create_dir_as_hawq_user(params.hawq_master_temp_dir.split(','))

  Execute("chmod 700 {0}".format(params.hawq_master_dir), user=hawq_constants.root_user, timeout=hawq_constants.default_exec_timeout)
Esempio n. 8
0
    def __init_segment():
        import params

        # Create segment directories
        utils.create_dir_as_hawq_user(params.hawq_segment_dir)
        utils.create_dir_as_hawq_user(params.hawq_segment_temp_dir.split(','))

        Execute("chown {0}:{1} {2}".format(
            hawqconstants.hawq_user, hawqconstants.hawq_group,
            os.path.dirname(params.hawq_segment_dir)),
                user=hawqconstants.root_user,
                timeout=hawqconstants.default_exec_timeout)

        # Initialize hawq segment
        utils.exec_hawq_operation(hawqconstants.INIT,
                                  "{0} -a -v".format(hawqconstants.SEGMENT))
Esempio n. 9
0
def __set_osparams():
  """
  Updates parameters in sysctl.conf and limits.conf required by HAWQ.
  """
  # Create a temp scratchpad directory
  utils.create_dir_as_hawq_user(hawq_constants.hawq_tmp_dir)

  # Suse doesn't supports loading values from files in /etc/sysctl.d
  # So we will have to directly edit the sysctl file
  if System.get_instance().os_family == "suse":
    # Update /etc/sysctl.conf
    __update_sysctl_file_suse()
  else:
    # Update /etc/sysctl.d/hawq.conf
    __update_sysctl_file()

  __update_limits_file()
Esempio n. 10
0
def __set_osparams():
  """
  Updates parameters in sysctl.conf and limits.conf required by HAWQ.
  """
  # Create a temp scratchpad directory
  utils.create_dir_as_hawq_user(hawq_constants.hawq_tmp_dir)

  # Suse doesn't supports loading values from files in /etc/sysctl.d
  # So we will have to directly edit the sysctl file
  if System.get_instance().os_family == "suse":
    # Update /etc/sysctl.conf
    __update_sysctl_file_suse()
  else:
    # Update /etc/sysctl.d/hawq.conf
    __update_sysctl_file()

  __update_limits_file()