<!--
   - Resin 4.0 configuration file for cluster environment.
  -->
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="urn:java:com.caucho.resin"
       xmlns:health="urn:java:com.caucho.health"
       xmlns:ee="urn:java:ee">

      <system-property propertyFile="/usr/local/legalmatch.prod/notify_lmram.prop"/>
      <system-property propertyFileCheckInterval="1"/>

  <character-encoding>iso-8859-1</character-encoding>

  <!-- property-based Resin configuration -->
  <resin:properties path="${__DIR__}/resin.properties" optional="true"/>
  <resin:properties path="cloud:/resin.properties"
                    optional="true" recover="true"/>

  <resin:if test="${properties_import_url}">
     <resin:properties path="${properties_import_url}"
                    optional="true" recover="true"/>
  </resin:if>


  <!-- Logging configuration for the JDK logging API starts -->
              
  <log-handler name="" level="all" path="stdout:"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>               
               
  <log-handler name="com.caucho.java" level="all"
               path="/usr/local/resin40/log/java.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>

  <log-handler name="com.caucho.loader" level="all"
               path="/usr/local/resin40/log/loader.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>

  <log-handler name="com.caucho.jsp" level="all"
               path="/usr/local/resin40/log/jsp.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>

  <log-handler name="com.caucho.server.port" level="all"
               path="/usr/local/resin40/log/port.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>

  <log-handler name="com.caucho.server.http" level="all"
               path="/usr/local/resin40/log/http.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>

  <log-handler name="com.caucho.server.webapp" level="all"
               path="/usr/local/resin40/log/webapp.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>

  <log-handler name="com.caucho.server.cache" level="all"
               path="/usr/local/resin40/log/cache.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>

  <log-handler name="com.caucho.sql" level="all"
               path="/usr/local/resin40/log/sql.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>

  <log-handler name="com.caucho.transaction" level="all"
               path="/usr/local/resin40/log/transaction.log"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>
 
  <!-- 
     - Alternative pseudo-TTCC log format
     -
     - <log-handler name="" level="all" path="stdout:"
     -           timestamp="%y-%m-%d %H:%M:%S.%s"
     -           format=" [${thread}] ${log.level} ${log.shortName} - ${log.message}"/>
    -->
   
  <!--
     - level='info' for production
     - 'fine' or 'finer' for development and troubleshooting
    -->
  <logger name="" level="${log_level?:'info'}"/>
  <logger name="com.caucho.java" level="info"/>
  <logger name="com.caucho.loader" level="info"/>
  <logger name="com.caucho.jsp" level="info"/>
  <logger name="com.caucho.server.port" level="info"/>
  <logger name="com.caucho.server.http" level="info"/>
  <logger name="com.caucho.server.webapp" level="info"/>
  <logger name="com.caucho.server.cache" level="info"/>
  <logger name="com.caucho.sql" level="info"/>
  <logger name="com.caucho.transaction" level="info"/>


  <!--
     - level='warning' per David's request 10-Dec-2013
    -->
  <logger name="org.hibernate" level="warning"/>
  <logger name="org.apache" level="warning"/>
  <logger name="org.velocity" level="warning"/>

  <!--
     - Default configuration applied to all clusters, including
     - HTTP, HTTPS, and /resin-admin configuration.
    -->
  <resin:import path="${__DIR__}/cluster-default.xml"/>
  
   <!--
     - health configuration
     - Moved to cluster-default.xml
   <resin:import path="${__DIR__}/health.xml"/>
   -->
 
  <!--
     - Remote management requires at least one enabled admin user.
    -->
  <resin:AdminAuthenticator>
    <user name="${admin_user}" password="${admin_password}"/>
    
    <resin:import path="${__DIR__}/admin-users.xml" optional="true"/>
    <resin:import path="cloud:/admin-users.xml" optional="true" recover="true"/>
  </resin:AdminAuthenticator>

  <!--
     - For clustered systems, create a password in as cluster_system_key
    -->
  <cluster-system-key>${cluster_system_key}</cluster-system-key>

  <!--
     - For production sites, change dependency-check-interval to something
     - like 600s, so it only checks for updates every 10 minutes.
    -->
  <dependency-check-interval>${dependency_check_interval?:'2s'}</dependency-check-interval>

  <!-- For resin.properties dynamic cluster joining -->
  <home-cluster>${home_cluster}</home-cluster>
  <home-server>${home_server}</home-server>
  <elastic-server>${elastic_server}</elastic-server>
  <elastic-dns>${elastic_dns}</elastic-dns>

  <!--
     - Configures the main application cluster.  Load-balancing configurations
     - will also have a web cluster.
    -->

  <!-- APP Cluster configuration Starts here -->

  <cluster id="app">
    <!-- define the servers in the cluster -->
    <!-- All ports point to 6808 in resin.properties -->
    <server-multi id-prefix="app-" address-list="${app_servers}" port="6808"/> 

    <host-default>
      <!-- creates the webapps directory for .war expansion -->
     <web-app-deploy path="webapps"
                    expand-preserve-fileset="WEB-INF/work/**"
                    multiversion-routing="${webapp_multiversion_routing}"
                    path-suffix="${elastic_webapp?resin.id:''}"/>
   </host-default>

    <!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
    <host-deploy path="hosts">
      <host-default>
        <resin:import path="host.xml" optional="true"/>
      </host-default>
    </host-deploy>

    <!-- the default host, matching any host name -->
    <host id="" root-directory=".">

      <!--
         - webapps can be overridden/extended in the resin.xml
        -->
      <web-app id="/" root-directory="webapps/ROOT"/>  

    </host>

  <!-- Custom Entry for Multple WatchDogs -->

  <!-- Custom Entry for Persistent Sessions Starts Here -->

   <web-app-default>

    <!-- LMS-2472 add distributed caching 
        <resin:ClusterCache ee:Named="myCache">
        <name>myCache</name>
        <modified-expire-timeout>1h</modified-expire-timeout>
    </resin:ClusterCache>
-->

      <session-config>   
        <use-persistent-store>true</use-persistent-store>
        <always-load-session>true</always-load-session>
      <session-timeout>30</session-timeout>  <!-- whatever is real one-->
      </session-config>
      <resource-deploy path="webapps"/>
      <redeploy-check-interval>60s</redeploy-check-interval>   
      <redeploy-mode>automatic</redeploy-mode>
      <dependency-check-interval>60s</dependency-check-interval>
    </web-app-default>

  <!-- Custom Entry for Persistent Sessions Ends Here -->
     
    <host-default>
      <!-- creates the webapps directory for .war expansion -->
       <web-app-deploy path="webapps"
                       expand-preserve-fileset="WEB-INF/work/**"
                       multiversion-routing="${webapp_multiversion_routing}"
                       path-suffix="${elastic_webapp?resin.id:''}"/>
    </host-default>
  
        <!-- Database Configuration Starts Here  -->

        <database>
        <close-dangling-connections>false</close-dangling-connections>
        <max-connections>110</max-connections>
        <max-idle-time>30s</max-idle-time>
        <max-active-time>1h</max-active-time>
        <max-pool-time>2h</max-pool-time>
        <save-allocation-stack-trace>true</save-allocation-stack-trace>
        <spy>true</spy>
        <jndi-name>jdbc/LMDB</jndi-name>
           <driver> 
                <type>com.mysql.jdbc.Driver</type> 
                <url>jdbc:mysql://192.168.1.62:3306/legalmatch?noAccessToProcedureBodies=true</url>
                <init-param useOldAliasMetadataBehavior="true"/>
                <init-param zeroDateTimeBehavior="convertToNull"/>
                <init-param connectionCollation="latin1_swedish_ci"/>
                <init-param useUnicode="true"/>
                <init-param useCompression="false"/>
                <init-param useCursorFetch="true"/>
            </driver> 
        <connection-wait-time>5m</connection-wait-time>
        <ping-table>legalmatch.persistent_session</ping-table>
        <ping>true</ping>
        <ping-interval>0s</ping-interval>
        </database>
        
        <database>
        <close-dangling-connections>false</close-dangling-connections>
        <max-connections>110</max-connections>
        <max-idle-time>30s</max-idle-time>
        <max-active-time>1h</max-active-time>
        <max-pool-time>2h</max-pool-time>
        <save-allocation-stack-trace>true</save-allocation-stack-trace>
        <spy>true</spy>
        <jndi-name>jdbc/RAMDB</jndi-name>
           <driver> 
                <type>com.mysql.jdbc.Driver</type> 
                <url>jdbc:mysql://192.168.1.61:3306/legalmatch?noAccessToProcedureBodies=true</url>
                <init-param useOldAliasMetadataBehavior="true"/>
                <init-param zeroDateTimeBehavior="convertToNull"/>
                <init-param connectionCollation="latin1_swedish_ci"/>
                <init-param useUnicode="true"/>
                <init-param useCompression="false"/>
                <init-param useCursorFetch="true"/>
            </driver> 
        <connection-wait-time>5m</connection-wait-time>
        <ping-table>legalmatch.persistent_session</ping-table>
        <ping>true</ping>
        <ping-interval>0s</ping-interval>
        </database>

        <database>
        <close-dangling-connections>false</close-dangling-connections>
        <max-connections>110</max-connections>
        <max-idle-time>30s</max-idle-time>
        <max-active-time>1h</max-active-time>
        <max-pool-time>2h</max-pool-time>
        <save-allocation-stack-trace>true</save-allocation-stack-trace>
        <spy>true</spy>
        <jndi-name>jdbc/RPTDB</jndi-name>
           <driver> 
                <type>com.mysql.jdbc.Driver</type> 
                <url>jdbc:mysql://192.168.1.62:3306/legalmatch?noAccessToProcedureBodies=true</url>
                <init-param useOldAliasMetadataBehavior="true"/>
                <init-param zeroDateTimeBehavior="convertToNull"/>
                <init-param connectionCollation="latin1_swedish_ci"/>
                <init-param useUnicode="true"/>
                <init-param useCompression="false"/>
                <init-param useCursorFetch="true"/>
            </driver> 
        <connection-wait-time>5m</connection-wait-time>
        <ping-table>legalmatch.persistent_session</ping-table>
        <ping>true</ping>
        <ping-interval>0s</ping-interval>
        </database>
        
        <database>
        <close-dangling-connections>false</close-dangling-connections>
        <max-connections>110</max-connections>
        <max-idle-time>30s</max-idle-time>
        <max-active-time>1h</max-active-time>
        <max-pool-time>2h</max-pool-time>
        <save-allocation-stack-trace>true</save-allocation-stack-trace>
        <spy>true</spy>
        <jndi-name>jdbc/LMTRKDB</jndi-name>
           <driver> 
                <type>com.mysql.jdbc.Driver</type> 
                <url>jdbc:mysql://192.168.1.62:3306/legalmatch?noAccessToProcedureBodies=true</url>
          
                <init-param useOldAliasMetadataBehavior="true"/>
                <init-param zeroDateTimeBehavior="convertToNull"/>
                <init-param connectionCollation="latin1_swedish_ci"/>
                <init-param useUnicode="true"/>
                <init-param useCompression="false"/>
                <init-param useCursorFetch="true"/>
            </driver> 
        <connection-wait-time>5m</connection-wait-time>
        <ping-table>legalmatch.persistent_session</ping-table>
        <ping>true</ping>
        <ping-interval>0s</ping-interval>
        </database>

        <!-- Database Configuration Ends Here -->

    <resin:if test="${resin_doc}">
      <host id="${resin_doc_host}" root-directory="${resin_doc_host}">
        <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>
      </host>
    </resin:if>
  </cluster>


  <!-- APP Cluster configuration Ends here -->

  <cluster id="web">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="web-" address-list="${web_servers}" port="6810"/>


    <host id="" root-directory="web">
      <web-app id="">
        <resin:LoadBalance regexp="" cluster="app"/>
      </web-app>
      
      <web-app id="/async">
        <resin:LoadBalance regexp="" cluster="app"/>
      </web-app>
    </host>
  </cluster>

  <cluster id="memcached" xmlns:memcache="urn:java:com.caucho.memcached">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="memcached-" address-list="${memcached_servers}" port="6820">
      <!-- listen for the memcache protocol -->
      <listen port="${memcached_port?:11211}"
              keepalive-timeout="600s" socket-timeout="600s">
        <memcache:MemcachedProtocol/>
      </listen>
    </server-multi>
  </cluster>
  
  <cluster id="proxycache">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="proxycache-" address-list="${proxycache_servers}" port="6830"/>

    <host id="" root-directory="proxycache">
      <web-app id="">
        <resin:HttpProxy regexp=".*">
          <!-- backend HTTP servers to proxy to -->
          <addresses>${backend_servers}</addresses>
        </resin:HttpProxy>
      </web-app>
    </host>
  </cluster>

</resin>
