################################################################################
#   Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved
#
#   Licensed under the Apache License, Version 2.0 (the \"License\");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an \"AS IS\" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
################################################################################

  # Carbon Configuration Parameters
wso2.carbon:
    # value to uniquely identify a server
  id: wso2-sp
    # server name
  name: WSO2 Stream Processor
    # ports used by this server
  ports:
      # port offset
    offset: 0

  # Configuration used for the databridge communication
databridge.config:
    # No of worker threads to consume events
    # THIS IS A MANDATORY FIELD
  workerThreads: 10
    # Maximum amount of messages that can be queued internally in MB
    # THIS IS A MANDATORY FIELD
  maxEventBufferCapacity: 10000000
    # Queue size; the maximum number of events that can be stored in the queue
    # THIS IS A MANDATORY FIELD
  eventBufferSize: 2000
    # Keystore file path
    # THIS IS A MANDATORY FIELD
  keyStoreLocation : ${sys:carbon.home}/resources/security/wso2carbon.jks
    # Keystore password
    # THIS IS A MANDATORY FIELD
  keyStorePassword : wso2carbon
    # Session Timeout value in mins
    # THIS IS A MANDATORY FIELD
  clientTimeoutMin: 30
    # Data receiver configurations
    # THIS IS A MANDATORY FIELD
  dataReceivers:
  -
      # Data receiver configuration
    dataReceiver:
        # Data receiver type
        # THIS IS A MANDATORY FIELD
      type: Thrift
        # Data receiver properties
      properties:
        tcpPort: '7611'
        sslPort: '7711'

  -
      # Data receiver configuration
    dataReceiver:
        # Data receiver type
        # THIS IS A MANDATORY FIELD
      type: Binary
        # Data receiver properties
      properties:
        tcpPort: '9611'
        sslPort: '9711'
        tcpReceiverThreadPoolSize: '100'
        sslReceiverThreadPoolSize: '100'
        hostName: 0.0.0.0

  # Configuration of the Data Agents - to publish events through databridge
data.agent.config:
    # Data agent configurations
    # THIS IS A MANDATORY FIELD
  agents:
  -
      # Data agent configuration
    agentConfiguration:
        # Data agent name
        # THIS IS A MANDATORY FIELD
      name: Thrift
        # Data endpoint class
        # THIS IS A MANDATORY FIELD
      dataEndpointClass: org.wso2.carbon.databridge.agent.endpoint.thrift.ThriftDataEndpoint
        # Data publisher strategy
      publishingStrategy: async
        # Trust store path
      trustStorePath: '${sys:carbon.home}/resources/security/client-truststore.jks'
        # Trust store password
      trustStorePassword: 'wso2carbon'
        # Queue Size
      queueSize: 32768
        # Batch Size
      batchSize: 200
        # Core pool size
      corePoolSize: 1
        # Socket timeout in milliseconds
      socketTimeoutMS: 30000
        # Maximum pool size
      maxPoolSize: 1
        # Keep alive time in pool
      keepAliveTimeInPool: 20
        # Reconnection interval
      reconnectionInterval: 30
        # Max transport pool size
      maxTransportPoolSize: 250
        # Max idle connections
      maxIdleConnections: 250
        # Eviction time interval
      evictionTimePeriod: 5500
        # Min idle time in pool
      minIdleTimeInPool: 5000
        # Secure max transport pool size
      secureMaxTransportPoolSize: 250
        # Secure max idle connections
      secureMaxIdleConnections: 250
        # secure eviction time period
      secureEvictionTimePeriod: 5500
        # Secure min idle time in pool
      secureMinIdleTimeInPool: 5000
        # SSL enabled protocols
      sslEnabledProtocols: TLSv1,TLSv1.1,TLSv1.2
        # Ciphers
      ciphers: SSL_RSA_WITH_RC4_128_MD5,SSL_RSA_WITH_RC4_128_SHA,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA
  -
      # Data agent configuration
    agentConfiguration:
        # Data agent name
        # THIS IS A MANDATORY FIELD
      name: Binary
        # Data endpoint class
        # THIS IS A MANDATORY FIELD
      dataEndpointClass: org.wso2.carbon.databridge.agent.endpoint.binary.BinaryDataEndpoint
        # Data publisher strategy
      publishingStrategy: async
        # Trust store path
      trustStorePath: '${sys:carbon.home}/resources/security/client-truststore.jks'
        # Trust store password
      trustStorePassword: 'wso2carbon'
        # Queue Size
      queueSize: 32768
        # Batch Size
      batchSize: 200
        # Core pool size
      corePoolSize: 1
        # Socket timeout in milliseconds
      socketTimeoutMS: 30000
        # Maximum pool size
      maxPoolSize: 1
        # Keep alive time in pool
      keepAliveTimeInPool: 20
        # Reconnection interval
      reconnectionInterval: 30
        # Max transport pool size
      maxTransportPoolSize: 250
        # Max idle connections
      maxIdleConnections: 250
        # Eviction time interval
      evictionTimePeriod: 5500
        # Min idle time in pool
      minIdleTimeInPool: 5000
        # Secure max transport pool size
      secureMaxTransportPoolSize: 250
        # Secure max idle connections
      secureMaxIdleConnections: 250
        # secure eviction time period
      secureEvictionTimePeriod: 5500
        # Secure min idle time in pool
      secureMinIdleTimeInPool: 5000
        # SSL enabled protocols
      sslEnabledProtocols: TLSv1,TLSv1.1,TLSv1.2
        # Ciphers
      ciphers: SSL_RSA_WITH_RC4_128_MD5,SSL_RSA_WITH_RC4_128_SHA,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA

  # Deployment configuration parameters
wso2.artifact.deployment:
    # Scheduler update interval
  updateInterval: 5

  # Persistence Configuration
state.persistence:
  enabled: true
  intervalInMin: 1
  revisionsToKeep: 3
  class: org.wso2.carbon.stream.processor.core.persistence.DBPersistenceStore
  # config:
    # location: siddhi-app-persistence
  config:
    datasource: WSO2_ANALYTICS_DB
    table: PERSISTENCE_TABLE

  # Secure Vault Configuration
wso2.securevault:
  secretRepository:
    type: org.wso2.carbon.secvault.repository.DefaultSecretRepository
    parameters:
      privateKeyAlias: wso2carbon
      keystoreLocation: ${sys:carbon.home}/resources/security/securevault.jks
      secretPropertiesFile: ${sys:carbon.home}/conf/${sys:wso2.runtime}/secrets.properties
  masterKeyReader:
    type: org.wso2.carbon.secvault.reader.DefaultMasterKeyReader
    parameters:
      masterKeyReaderFile: ${sys:carbon.home}/conf/${sys:wso2.runtime}/master-keys.yaml

# This is the main configuration for metrics
wso2.metrics:
  # Enable Metrics
  enabled: true

  # Metrics JMX Configuration
  jmx:
    # Register MBean when initializing Metrics
    registerMBean: true
    # MBean Name
    name: org.wso2.carbon:type=Metrics

  reservoir:
    # Reservoir Type used for Histogram and Timer
    # Available types are EXPONENTIALLY_DECAYING, UNIFORM, SLIDING_WINDOW, SLIDING_TIME_WINDOW & HDR_HISTOGRAM
    type: EXPONENTIALLY_DECAYING
    # Parameters for reservoir implementations
    parameters:
      # The number of measurements to store in SLIDING_WINDOW reservoir or
      # number of samples to keep in UNIFORM reservoir
      size: 1028
      # The window of time in SLIDING_TIME_WINDOW reservoir
      window: 1
      # The unit of window in SLIDING_TIME_WINDOW reservoir. See java.util.concurrent.TimeUnit
      windowUnit: HOURS
      # The precision to use in the Recorder to be used in HDR_HISTOGRAM reservoir
      numberOfSignificantValueDigits: 2
      # Reset the HdrHistogram when taking a snapshot
      resetOnSnapshot: false

  # Metrics reporting configurations
  # The JMX, Console, CSV and SLF4J reporters are in the Metrics Core feature.
  reporting:
    jmx:
      - # The name for the JMX Reporter
        name: JMX

        # Enable JMX Reporter
        enabled: true

    console:
      - # The name for the Console Reporter
        name: Console

        # Enable Console Reporter
        enabled: false

        # Polling Period in seconds.
        # This is the period for polling metrics from the metric registry and printing in the console
        pollingPeriod: 5

    csv:
      - # The name for the CSV Reporter
        name: CSV

        # Enable CSV Reporter
        enabled: false

        # The location for CSV files. There is a CSV file for each metric.
        location: ${carbon.home}/wso2/default/logs/metrics/

        # Polling Period in seconds.
        # This is the period for polling metrics from the metric registry and update CSV files in the given location
        pollingPeriod: 10

    slf4j:
      - # The name for the SLF4J Reporter
        name: SLF4J

        # Enable SLF4J Reporter
        enabled: false

        # The Logger name
        loggerName: metrics

        # The Marker name
        # markerName: metrics

        # Polling Period in seconds.
        # This is the period for polling metrics from the metric registry and logging to the configured logger
        pollingPeriod: 15

wso2.metrics.jdbc:
  # Data Source Configurations for JDBC Reporters
  dataSource:
    # Default Data Source Configuration
    - &JDBC01
      # The "lookupDataSource" flag specifies whether the datasource should be looked up via JNDI.
      # If this is set to true the data source should be configured.
      # If this is set to false, the datasource will be created by the properties defined in "dataSourceProperties"
      lookupDataSource: true

      # JNDI name of the data source to be used by the JDBC Reporter.
      # This data source should be defined in a *-datasources.xml file in conf/datasources directory.
      dataSourceName: java:comp/env/jdbc/WSO2MetricsDB

      # Schedule regular deletion of metrics data older than a set number of days.
      # It is recommended that you enable this job to ensure your metrics tables do not get extremely large.
      # Deleting data older than seven days should be sufficient.
      scheduledCleanup:
        # Enable scheduled cleanup to delete Metrics data in the database.
        enabled: true

        # The scheduled job will cleanup all data older than the specified days
        daysToKeep: 7

        # This is the period for each cleanup operation in seconds.
        scheduledCleanupPeriod: 86400

  # The JDBC Reporter is in the Metrics JDBC Core feature
  reporting:
    # The JDBC Reporter configurations will be ignored if the Metrics JDBC Core feature is not available in runtime
    jdbc:
      - # The name for the JDBC Reporter
        name: JDBC

        # Enable JDBC Reporter
        enabled: true

        # Source of Metrics, which will be used to identify each metric in database -->
        # Commented to use the hostname by default
        # source: Carbon

        # Alias referring to the Data Source configuration
        dataSource: *JDBC01

        # Polling Period in seconds.
        # This is the period for polling metrics from the metric registry and updating the database with the values
        pollingPeriod: 30
