apiVersion: v1
kind: ConfigMap
metadata:
  name: hive-config
data:
  hive-site.xml: |
    <configuration>
      <property>
        <name>hive.server2.enable.doAs</name>
        <value>false</value>
      </property>
      <property>
        <name>hive.server2.use.SSL</name>
        <value>false</value>
      </property>
      <property>
        <name>hive.server2.authentication</name>
        <value>NOSASL</value>
      </property>
      <property>
        <name>hive.metastore.metrics.enabled</name>
        <value>true</value>
      </property>
      <property>
        <name>hive.server2.metrics.enabled</name>
        <value>true</value>
      </property>
      <property>
        <name>hive.service.metrics.reporter</name>
        <value>JMX</value>
      </property>
      <property>
        <name>hive.server2.thrift.bind.host</name>
{{- if and .Values.hive.spec.server.config.tls.enabled .Values.useIPV6Networking }}
        <value>[::1]</value>
{{- else if .Values.hive.spec.server.config.tls.enabled }}
        <value>127.0.0.1</value>
{{- else if .Values.useIPV6Networking }}
        <value>[::]</value>
{{- else }}
        <value>0.0.0.0</value>
{{- end }}
      </property>
      <property>
        <name>hive.metastore.thrift.bind.host</name>
{{- if and .Values.hive.spec.metastore.config.tls.enabled .Values.useIPV6Networking }}
        <value>[::1]</value>
{{- else if .Values.hive.spec.metastore.config.tls.enabled }}
        <value>127.0.0.1</value>
{{- else if .Values.useIPV6Networking }}
        <value>[::]</value>
{{- else }}
        <value>0.0.0.0</value>
{{- end }}
      </property>
      <property>
        <name>hive.metastore.uris</name>
{{- if and .Values.hive.spec.metastore.config.tls.enabled .Values.useIPV6Networking }}
        <value>thrift://[::1]:9083</value>
{{- else if .Values.hive.spec.metastore.config.tls.enabled }}
        <value>thrift://localhost:9083</value>
{{- else }}
        <value>thrift://hive-metastore:9083</value>
{{- end }}
      </property>
      <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>{{ .Values.hive.spec.config.db.url }}</value>
      </property>
      <property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>{{ .Values.hive.spec.config.db.driver }}</value>
      </property>
{{- if .Values.hive.spec.config.db.username }}
      <property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>{{ .Values.hive.spec.config.db.username }}</value>
      </property>
{{- end }}
{{- if .Values.hive.spec.config.db.password }}
      <property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>{{ .Values.hive.spec.config.db.password }}</value>
      </property>
{{- end }}
      <property>
        <name>datanucleus.schema.autoCreateAll</name>
        <value>{{ .Values.hive.spec.config.db.autoCreateMetastoreSchema }}</value>
      </property>
      <property>
        <name>hive.metastore.schema.verification</name>
        <value>{{ .Values.hive.spec.config.db.enableMetastoreSchemaVerification }}</value>
      </property>
{{- if .Values.hive.spec.config.defaultFileFormat }}
      <property>
        <name>hive.default.fileformat</name>
        <value>{{ .Values.hive.spec.config.defaultFileFormat }}</value>
      </property>
{{- end }}
{{- if .Values.hive.spec.config.metastoreWarehouseDir }}
      <property>
        <name>hive.metastore.warehouse.dir</name>
        <value>{{ .Values.hive.spec.config.metastoreWarehouseDir }}</value>
      </property>
{{- end }}
{{- if .Values.hive.spec.config.metastoreClientSocketTimeout }}
      <property>
        <name>hive.metastore.client.socket.timeout</name>
        <value>{{ .Values.hive.spec.config.metastoreClientSocketTimeout }}</value>
      </property>
{{- end }}
    </configuration>


  hive-log4j2.properties: |
    status = INFO
    name = HiveLog4j2
    packages = org.apache.hadoop.hive.ql.log

    # list of properties
    property.hive.log.level = INFO
    property.hive.root.logger = console
    property.hive.log.dir = ${sys:java.io.tmpdir}/${sys:user.name}
    property.hive.log.file = hive.log

    # list of all appenders
    appenders = console

    # console appender
    appender.console.type = Console
    appender.console.name = console
    appender.console.target = SYSTEM_ERR
    appender.console.layout.type = PatternLayout
    appender.console.layout.pattern = %d{yy/MM/dd HH:mm:ss} [%t]: %p %c{2}: %m%n

    # list of all loggers
    loggers = NIOServerCnxn, ClientCnxnSocketNIO, DataNucleus, Datastore, JPOX

    logger.NIOServerCnxn.name = org.apache.zookeeper.server.NIOServerCnxn
    logger.NIOServerCnxn.level = WARN

    logger.ClientCnxnSocketNIO.name = org.apache.zookeeper.ClientCnxnSocketNIO
    logger.ClientCnxnSocketNIO.level = WARN

    logger.DataNucleus.name = DataNucleus
    logger.DataNucleus.level = ERROR

    logger.Datastore.name = Datastore
    logger.Datastore.level = ERROR

    logger.JPOX.name = JPOX
    logger.JPOX.level = ERROR

    # root logger
    rootLogger.level = ${sys:hive.log.level}
    rootLogger.appenderRefs = root
    rootLogger.appenderRef.root.ref = ${sys:hive.root.logger}

  hive-exec-log4j2.properties: |
    status = INFO
    name = HiveLog4j2
    packages = org.apache.hadoop.hive.ql.log

    # list of properties
    property.hive.log.level = INFO
    property.hive.root.logger = console
    property.hive.log.dir = ${sys:java.io.tmpdir}/${sys:user.name}
    property.hive.log.file = hive.log

    # list of all appenders
    appenders = console

    # console appender
    appender.console.type = Console
    appender.console.name = console
    appender.console.target = SYSTEM_ERR
    appender.console.layout.type = PatternLayout
    appender.console.layout.pattern = %d{yy/MM/dd HH:mm:ss} [%t]: %p %c{2}: %m%n

    # list of all loggers
    loggers = NIOServerCnxn, ClientCnxnSocketNIO, DataNucleus, Datastore, JPOX

    logger.NIOServerCnxn.name = org.apache.zookeeper.server.NIOServerCnxn
    logger.NIOServerCnxn.level = WARN

    logger.ClientCnxnSocketNIO.name = org.apache.zookeeper.ClientCnxnSocketNIO
    logger.ClientCnxnSocketNIO.level = WARN

    logger.DataNucleus.name = DataNucleus
    logger.DataNucleus.level = ERROR

    logger.Datastore.name = Datastore
    logger.Datastore.level = ERROR

    logger.JPOX.name = JPOX
    logger.JPOX.level = ERROR

    # root logger
    rootLogger.level = ${sys:hive.log.level}
    rootLogger.appenderRefs = root
    rootLogger.appenderRef.root.ref = ${sys:hive.root.logger}
