def __is_active_master(): """ Finds if this node is the active master """ import params return params.hostname == common.get_local_hawq_site_property( "hawq_master_address_host")
def __is_standby_host(): """ Finds if this node is the standby host """ import params return params.hostname == common.get_local_hawq_site_property( "hawq_standby_address_host")
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
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
def __get_standby_host(): """ Returns the name of the HAWQ Standby Master host from hawq-site.xml, or None if no standby is configured """ standby_host = common.get_local_hawq_site_property( "hawq_standby_address_host") return None if standby_host is None or standby_host.lower( ) == 'none' else standby_host
def __init__(self): self.active_master_host = common.get_local_hawq_site_property("hawq_master_address_host")
def __init__(self): self.active_master_host = common.get_local_hawq_site_property( "hawq_master_address_host")