<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/util
            http://www.springframework.org/schema/util/spring-util.xsd">

    <bean abstract="false"  id="ignIgniteConfiguration" class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="discoverySpi">
            <ref bean="ignTcpDiscoverySpi"/>
        </property>
        <property name="communicationSpi">
            <ref bean="ignTcpCommunicationSpi"/>
        </property>

        <property name="gridLogger">
            <bean class="org.apache.ignite.logger.log4j2.Log4J2Logger">
                <constructor-arg type="java.lang.String" value="/test/nao/server/config/ignite-log4j2.xml"/>
            </bean>
        </property>

        <property name="metricExporterSpi">
          <list>
            <bean class="org.apache.ignite.spi.metric.jmx.JmxMetricExporterSpi"/>
          </list>
        </property>

        <property name="consistentId"            value="#{systemProperties['IGNITE_CLUSTER_NAME'] + '_' + localhostInetAddress.hostName}"/>
        <property name="workDirectory"           value="/test/nao/server/work"/>
        <property name="metricsLogFrequency"     value="0"/>
        <property name="failureDetectionTimeout" value="30000"/>
        <property name="peerClassLoadingEnabled" value="true"/>
        <property name="autoActivationEnabled"   value="false"/>
        
        <property name="dataStorageConfiguration">
            <ref bean="ignDataStorageConfiguration"/>
        </property>

        <property name="connectorConfiguration">
            <ref bean="ignConnectorConfiguration"/>
        </property>
        <property name="clientConnectorConfiguration">
            <ref bean="ignClientConnectorConfiguration"/>
        </property>
        <property name="transactionConfiguration">
            <ref bean="ignTransactionConfiguration"/>
        </property>

        <property name="snapshotThreadPoolSize"  value="10"/>

        <property name="snapshotPath" value="/test/nao/backup/snapshot"/>
    </bean>

    <!-- ############# inc/bean/ ############# -->

    <!--TcpDiscoverySpi-->
    <bean id="ignTcpDiscoverySpi" class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
        <property name="localPort"      value="47700"/>
        <property name="localPortRange" value="9"/>
        <property name="connectionRecoveryTimeout" value="30000"/>
        <property name="localAddress"          value="10.40.6.208"/>
        <property name="ipFinder">
            <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                <property name="addresses">
                    <list>
                        <value>10.40.6.208</value>
                    </list>
                </property>
            </bean>
        </property>
    </bean>
    <bean id="ignTcpCommunicationSpi" class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
        <property name="localPort"             value="47900"/>
        <property name="localPortRange"        value="9"/>
        <property name="localAddress"          value="10.40.6.208"/>
    </bean>

    <bean id="ignConnectorConfiguration" class="org.apache.ignite.configuration.ConnectorConfiguration">
        <property name="host"          value="0.0.0.0"/>
        <property name="port"          value="11211"/>
	    <property name="idleTimeout"   value="180000"/>

    </bean>

    <bean id="ignClientConnectorConfiguration" class="org.apache.ignite.configuration.ClientConnectorConfiguration">
        <property name="host"           value="0.0.0.0"/>
        <property name="thinClientEnabled" value="true"/>
        <property name="thinClientConfiguration" ref="thinClientConfiguration"/>
    </bean>
    
    <bean id="thinClientConfiguration" class="org.apache.ignite.configuration.ThinClientConfiguration">
        <property name="maxActiveComputeTasksPerConnection" value="100"/>
    </bean>

    <bean id="ignTransactionConfiguration"  class="org.apache.ignite.configuration.TransactionConfiguration">
        <property name="defaultTxIsolation"              value="READ_COMMITTED"/>
        <property name="defaultTxTimeout"                value="300000"/>
        <property name="txTimeoutOnPartitionMapExchange" value="10000"/>
    </bean>

    <bean id="ignDefaultDataRegionConfiguration" class="org.apache.ignite.configuration.DataRegionConfiguration">
        <property name="name"                       value="default"/>
        <property name="maxSize"                    value="#{2L * 1024L * 1024L * 1024L}"/>
        <property name="metricsEnabled"                    value="false"/>
        <property name="persistenceEnabled"                    value="true"/>
    </bean>

    <bean id="ignDataStorageConfiguration" class="org.apache.ignite.configuration.DataStorageConfiguration">
        <property name="walMode" value="LOG_ONLY"/>

        <property name="defragmentationThreadPoolSize" value="12"/>

        <property name="checkpointThreads" value="2"/>

        <property name="defaultDataRegionConfiguration">
            <ref bean="ignDefaultDataRegionConfiguration"/>
        </property>
        
        <property name="pageSize" value="#{1 * 1024}"/>

        <property name="checkpointFrequency" value="60000"/>

        <property name="storagePath" value="/test/nao/server/work/data"/>

        <property name="walArchivePath" value="/test/nao/server/work/wal_archive"/>
        
        <property name="walPath" value="/test/nao/server/work/wal"/>

        <property name="maxWalArchiveSize" value="#{10L * 1024 * 1024 * 1024}"/>

        <property name="metricsEnabled" value="false"/>
        <property name="metricsRateTimeInterval" value="60000"/>
        <property name="walCompactionEnabled" value="false"/>
    </bean>

    <bean id="localhostInetAddress" class="java.net.InetAddress" factory-method="getLocalHost"/>
</beans>
