apiVersion: v1
kind: ConfigMap
metadata:
  name: flink-config
  labels:
    app: flink
data:
  flink-conf.yaml: |+
    jobmanager.rpc.address: flink-jobmanager
    {{ if .Values.less_resources }}
    taskmanager.numberOfTaskSlots: 10
    {{ else }}
    taskmanager.numberOfTaskSlots: 1
    {{ end }}
    blob.server.port: 6124
    jobmanager.rpc.port: 6123
    taskmanager.rpc.port: 6122
    jobmanager.memory.process.size: 1024m
    taskmanager.memory.process.size: 1024m
    taskmanager.memory.managed.size: 0m
    restart-strategy: fixed-delay
    restart-strategy.fixed-delay.attempts: 30
    restart-strategy.fixed-delay.delay: 10 s
    web.timeout: 60000
    state.checkpoints.dir: s3://{{ .Values.flink.highAvailability.bucket }}/{{ .Values.flink.highAvailability.checkpointsDir }}
    state.savepoints.dir: s3://{{ .Values.flink.highAvailability.bucket }}/{{ .Values.flink.highAvailability.savepointsDir }}
    execution.checkpointing.interval: 60 s
    s3.endpoint: {{ .Values.minio.httpurl }}
    s3.path.style.access: true
    s3.access-key: {{ .Values.minio.accesskey }}
    s3.secret-key: {{ .Values.minio.secretkey }}
    cluster.evenly-spread-out-slots: {{ .Values.flink.highAvailability.evenlySpreadOut }}
    kubernetes.cluster-id: {{ .Values.flink.highAvailability.clusterId }}
    kubernetes.namespace: {{.Release.Namespace}}
    high-availability: org.apache.flink.kubernetes.highavailability.KubernetesHaServicesFactory
    high-availability.storageDir: s3://{{ .Values.flink.highAvailability.bucket }}/{{ .Values.flink.highAvailability.recoveryDir }}

  log4j.properties: |+
    monitorInterval=30
    # This affects logging for both user code and Flink
    rootLogger.level = INFO
    rootLogger.appenderRef.file.ref = MainAppender

    # Uncomment this if you want to _only_ change Flink's logging
    #logger.flink.name = org.apache.flink
    #logger.flink.level = INFO

    # The following lines keep the log level of common libraries/connectors on
    # log level INFO. The root logger does not override this. You have to manually
    # change the log levels here.
    logger.akka.name = akka
    logger.akka.level = INFO
    logger.kafka.name= org.apache.kafka
    logger.kafka.level = INFO
    logger.hadoop.name = org.apache.hadoop
    logger.hadoop.level = INFO
    logger.zookeeper.name = org.apache.zookeeper
    logger.zookeeper.level = INFO

    # Log all infos in the given file
    appender.main.name = MainAppender
    appender.main.type = Console
    appender.main.append = true
    #appender.main.fileName = ${sys:log.file}
    #appender.main.filePattern = ${sys:log.file}.%i
    appender.main.layout.type = PatternLayout
    appender.main.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
    appender.main.policies.type = Policies
    #appender.main.policies.size.type = SizeBasedTriggeringPolicy
    #appender.main.policies.size.size = 100MB
    #appender.main.policies.startup.type = OnStartupTriggeringPolicy
    appender.main.strategy.type = DefaultRolloverStrategy
    #appender.main.strategy.max = ${env:MAX_LOG_FILE_NUMBER:-10}

    # Suppress the irrelevant (wrong) warnings from the Netty channel handler
    logger.netty.name = org.apache.flink.shaded.akka.org.jboss.netty.channel.DefaultChannelPipeline
    logger.netty.level = OFF

  sql-client-defaults.yaml: |+
    tables: []
    functions:
      - name: epoch2sql
        from: class
        class: info.oisp.Epoch2SQLTimestamp
      - name: getJsonField
        from: class
        class: info.oisp.GetJsonField
    catalogs: [] # empty list
    execution:
      planner: blink
      type: streaming
      time-characteristic: event-time
      periodic-watermarks-interval: 200
      result-mode: table
      max-table-result-rows: 1000000
      parallelism: 1
      max-parallelism: 128
      min-idle-state-retention: 0
      max-idle-state-retention: 0
      current-catalog: default_catalog
      current-database: default_database
      restart-strategy:
        type: fallback
    deployment:
      response-timeout: 5000
      gateway-address: ""
      gateway-port: 0
