示例#1
0
文件: hive_site.py 项目: yjkim/hue
def get_metastore():
  """
  get_metastore() -> (is_local, host, port, kerberos_principal)

  Look at both hive-site.xml and beeswax.conf, and return the metastore information.

  hive-site.xml supersedes beeswax.conf.
  - If hive-site says local metastore (default), then get host & port from beeswax.conf.
  - If hive-site says remote, then use the URI specified there, so that we don't need to
    configure things twice.
  """
  global _METASTORE_LOC_CACHE
  if not _METASTORE_LOC_CACHE:
    kerberos_principal = security_util.get_kerberos_principal(get_conf().get(_CNF_METASTORE_KERBEROS_PRINCIPAL, None))
    kerberos_principal_components = security_util.get_components(kerberos_principal)
    thrift_uris = get_conf().get(_CNF_METASTORE_URIS)
    is_local = thrift_uris is None or thrift_uris == ''
    if is_local:
      host = beeswax.conf.BEESWAX_META_SERVER_HOST.get()
      port = beeswax.conf.BEESWAX_META_SERVER_PORT.get()
    else:
      thrift_uri = thrift_uris.split(",")[0]
      host, port = 'undefined', '0'
      match = _THRIFT_URI_RE.match(thrift_uri)
      if not match:
        LOG.fatal('Cannot understand remote metastore uri "%s"' % thrift_uri)
      else:
        host, port = match.groups()
      if str(get_conf().get(_CNF_METASTORE_SASL, 'false')).lower() == 'true' and len(kerberos_principal_components) == 3:
        host = kerberos_principal_components[1]
    _METASTORE_LOC_CACHE = (is_local, host, int(port), kerberos_principal)
  return _METASTORE_LOC_CACHE
示例#2
0
def get_metastore():
    """
  get_metastore() -> (is_local, host, port, kerberos_principal)

  Look at both hive-site.xml and beeswax.conf, and return the metastore information.

  hive-site.xml supersedes beeswax.conf.
  - If hive-site says local metastore (default), then get host & port from beeswax.conf.
  - If hive-site says remote, then use the URI specified there, so that we don't need to
    configure things twice.
  """
    global _METASTORE_LOC_CACHE
    if not _METASTORE_LOC_CACHE:
        kerberos_principal = security_util.get_kerberos_principal(
            get_conf().get(_CNF_METASTORE_KERBEROS_PRINCIPAL, None))
        kerberos_principal_components = security_util.get_components(
            kerberos_principal)
        thrift_uri = get_conf().get(_CNF_METASTORE_URIS)
        is_local = thrift_uri is None or thrift_uri == ''
        if is_local:
            host = beeswax.conf.BEESWAX_META_SERVER_HOST.get()
            port = beeswax.conf.BEESWAX_META_SERVER_PORT.get()
        else:
            host, port = 'undefined', '0'
            match = _THRIFT_URI_RE.match(thrift_uri)
            if not match:
                LOG.fatal('Cannot understand remote metastore uri "%s"' %
                          (thrift_uri, ))
            else:
                host, port = match.groups()
            if str(get_conf().get(_CNF_METASTORE_SASL, 'false')).lower(
            ) == 'true' and len(kerberos_principal_components) == 3:
                host = kerberos_principal_components[1]
        _METASTORE_LOC_CACHE = (is_local, host, int(port), kerberos_principal)
    return _METASTORE_LOC_CACHE
示例#3
0
def get_server_principal():
    thrift_principal = get_conf().get(_CNF_HBASE_THRIFT_KERBEROS_PRINCIPAL,
                                      None)
    principal = get_conf().get(_CNF_HBASE_THRIFT_SPNEGO_PRINCIPAL,
                               thrift_principal)
    components = get_components(principal)
    if components is not None:
        return components[0]
示例#4
0
def get_metastore():
    """
  get_metastore() -> (is_local, host, port, kerberos_principal)

  Look at both hive-site.xml and beeswax.conf, and return the metastore information.

  hive-site.xml supersedes beeswax.conf.
  - If hive-site says local metastore (default), then get host & port from beeswax.conf.
  - If hive-site says remote, then use the URI specified there, so that we don't need to
    configure things twice.
  """
    global _METASTORE_LOC_CACHE
    if not _METASTORE_LOC_CACHE:
        thrift_uris = get_conf().get(_CNF_METASTORE_URIS)
        is_local = thrift_uris is None or thrift_uris == ''

        if is_local:
            cluster_conf = cluster.get_cluster_conf_for_job_submission()
            use_sasl = cluster_conf is not None and cluster_conf.SECURITY_ENABLED.get(
            )
            host = beeswax.conf.BEESWAX_META_SERVER_HOST.get()
            port = beeswax.conf.BEESWAX_META_SERVER_PORT.get()
            kerberos_principal = security_util.get_kerberos_principal(
                KERBEROS.HUE_PRINCIPAL.get(), socket.getfqdn())
        else:
            use_sasl = str(get_conf().get(_CNF_METASTORE_SASL,
                                          'false')).lower() == 'true'
            thrift_uri = thrift_uris.split(",")[0]
            host, port = 'undefined', '0'
            match = _THRIFT_URI_RE.match(thrift_uri)
            if not match:
                LOG.fatal('Cannot understand remote metastore uri "%s"' %
                          thrift_uri)
            else:
                host, port = match.groups()
            kerberos_principal = security_util.get_kerberos_principal(
                get_conf().get(_CNF_METASTORE_KERBEROS_PRINCIPAL, None),
                socket.getfqdn())

        kerberos_principal_components = security_util.get_components(
            kerberos_principal)
        if use_sasl and len(kerberos_principal_components) == 3:
            host = kerberos_principal_components[1]

        _METASTORE_LOC_CACHE = (is_local, host, int(port), kerberos_principal)
    return _METASTORE_LOC_CACHE
示例#5
0
def get_server_principal():
  principal = get_conf().get(_CNF_HBASE_THRIFT_KERBEROS_PRINCIPAL, None)
  components = get_components(principal)
  if components is not None:
    return components[0]