<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   
   <!--
      The thread pool to use for index rebuilding and recovery
   -->
   <bean id="indexTrackerThreadPoolExecutor" class="org.alfresco.util.ThreadPoolExecutorFactoryBean">
	  <property name="poolName">
	  	<value>indexTrackerThread</value>
	  </property>
      <property name="corePoolSize">
         <value>${index.recovery.maximumPoolSize}</value>
      </property>
      <property name="maximumPoolSize">
         <value>${index.recovery.maximumPoolSize}</value>
      </property>
      <property name="workQueueSize">
         <value>100</value>
      </property>
   </bean>

   <bean id="indexRecoveryComponentBase" abstract="true" >
      <property name="threadPoolExecutor">
         <ref bean="indexTrackerThreadPoolExecutor" />
      </property>
      <property name="transactionService">
         <ref bean="transactionService" />
      </property>
      <property name="indexer">
         <ref bean="indexerComponent" />
      </property>
      <property name="ftsIndexer">
         <ref bean="LuceneFullTextSearchIndexer" />
      </property>
      <property name="searcher">
         <ref bean="searchService" />
      </property>
      <property name="nodeService">
          <ref bean="nodeService" />
      </property>
      <property name="nodeDaoService">
          <ref bean="nodeDaoService" />
      </property>
      <property name="tenantService">
         <ref bean="tenantService" />
      </property>
      <property name="storesToIgnore">
         <list>
            <value>${version.store.version2Store}</value>
            <value>${version.store.deprecated.lightWeightVersionStore}</value>
         </list>
      </property>
   </bean>
   
   <!-- index recovery and validation -->
   <bean
         id="indexRecoveryComponent"
         class="org.alfresco.repo.node.index.FullIndexRecoveryComponent"
         parent="indexRecoveryComponentBase">
      <property name="recoveryMode">
         <value>${index.recovery.mode}</value>
      </property>
      <property name="stopOnError">
         <value>${index.recovery.stopOnError}</value>
      </property>
      <property name="maxTransactionsPerLuceneCommit">
         <value>${index.tracking.maxTransactionsPerLuceneCommit}</value>
      </property>
      <property name="indexTracker">
         <ref bean="admIndexTrackerComponent" />
      </property>
   </bean>
	
   <bean
         id="avmIndexRecoveryComponent"
         class="org.alfresco.repo.node.index.AVMFullIndexRecoveryComponent"
         parent="indexRecoveryComponentBase">
      <property name="recoveryMode">
          <value>${index.recovery.mode}</value>
      </property>
	   <property name="avmService">
          <ref bean="avmService" />
      </property>
	   <property name="avmSnapShotTriggeredIndexingMethodInterceptor">
		   <ref bean="avmSnapShotTriggeredIndexingMethodInterceptor" />
      </property>
   </bean>
	

   <!-- Index tracking -->
   <!--
      This is the default index tracker component.  It is used during bootstrap when incremental recovery
      is required.
   -->
   <bean
         id="admIndexTrackerComponent"
         class="org.alfresco.repo.node.index.IndexTransactionTracker"
         parent="indexRecoveryComponentBase">
      <property name="nodeIndexer">
         <ref bean="nodeIndexer"/>
      </property>
      <property name="maxTxnDurationMinutes">
         <value>${index.tracking.maxTxnDurationMinutes}</value>
      </property>
      <property name="reindexLagMs">
         <value>${index.tracking.reindexLagMs}</value>
      </property>
      <property name="maxRecordSetSize">
         <value>${index.tracking.maxRecordSetSize}</value>
      </property>
      <property name="maxTransactionsPerLuceneCommit">
         <value>${index.tracking.maxTransactionsPerLuceneCommit}</value>
      </property>
      <property name="disableInTransactionIndexing">
         <value>${index.tracking.disableInTransactionIndexing}</value>
      </property>
   </bean>

    <!-- Schedule index tracking for ADM -->
    <bean id="admIndexTrackerTrigger" class="org.alfresco.util.CronTriggerBean">
        <property name="jobDetail">
            <bean class="org.springframework.scheduling.quartz.JobDetailBean">
                <property name="jobClass">
                    <value>org.alfresco.repo.node.index.IndexRecoveryJob</value>
                </property>
                <property name="jobDataAsMap">
                    <map>
                        <entry key="indexRecoveryComponent">
                            <ref bean="admIndexTrackerComponent" />
                        </entry>
                        <entry key="clusterName">
                            <value>${alfresco.cluster.name}</value>
                        </entry>
                    </map>
                </property>
            </bean>
        </property>
        <property name="scheduler">
            <ref bean="schedulerFactory" />
        </property>
        <property name="cronExpression">
            <value>${index.tracking.adm.cronExpression}</value>
        </property>
    </bean>

    <!--===========================-->
    <!-- AVM (WCM) index tracking  -->
    <!--===========================-->

    <bean
          id="avmIndexTrackerComponent"
          class="org.alfresco.repo.node.index.AVMRemoteSnapshotTracker"
          parent="indexRecoveryComponentBase">
	   <property name="avmService">
          <ref bean="avmService" />
      </property>
	   <property name="avmSnapShotTriggeredIndexingMethodInterceptor">
		   <ref bean="avmSnapShotTriggeredIndexingMethodInterceptor" />
      </property>
    </bean>

    <!-- Schedule index tracking for AVM -->
    <bean id="avmIndexTrackerTrigger" class="org.alfresco.util.CronTriggerBean">
        <property name="jobDetail">
            <bean class="org.springframework.scheduling.quartz.JobDetailBean">
                <property name="jobClass">
                    <value>org.alfresco.repo.node.index.IndexRecoveryJob</value>
                </property>
                <property name="jobDataAsMap">
                    <map>
                        <entry key="indexRecoveryComponent">
                            <ref bean="avmIndexTrackerComponent" />
                        </entry>
                        <entry key="clusterName">
                            <value>${alfresco.cluster.name}</value>
                        </entry>
                    </map>
                </property>
            </bean>
        </property>
        <property name="scheduler">
            <ref bean="schedulerFactory" />
        </property>
        <property name="cronExpression">
            <value>${index.tracking.avm.cronExpression}</value>
        </property>
    </bean>
    
   <!-- Failed FTS reindexer -->
   <!--
      Bean that triggers full text indexing for content that was previously flagged with:
        nitf: Not Indexed Transformation Failed
        nicm: Not Indexed Content Missing
        nint: Not Indexed No Transformation
      Use a CronTriggerBean and Quartz scheduler to trigger as required
   -->
   <bean
         id="missingFullTextReindexComponent"
         class="org.alfresco.repo.node.index.MissingContentReindexComponent"
         parent="indexRecoveryComponentBase">
   </bean>

</beans>