6 Replies Latest reply on Nov 9, 2012 4:34 AM by hardy.ferentschik

    Hibernate search FSSlaveDirectoryProvider not working

      I am trying to share the lucene hibernate search indexes between 2 app servers.

       

      I have done the configuration documented in the reference guide. But it does not seem to be working.

       

      My 2 app servers can write to indexes. These needs to be synchronized periodically.

       

      For the master my persistence.xml is like this

       

            <properties>

               <property name="hibernate.dialect" value="com.imagitek.prodagioap.persistence.SQLServer2008Dialect"/>

               <property name="hibernate.hbm2ddl.auto" value="update"/>

               <property name="hibernate.show_sql" value="false"/>

               <property name="hibernate.format_sql" value="true"/>

               <property name="jboss.entity.manager.factory.jndi.name" value="java:/prodagioAPEntityManagerFactory"/>

              

       

       

                          <property name="hibernate.search.default.sourceBase" value="\\VICTOR\indexes-master"/>

                          <property name="hibernate.search.default.indexBase" value="/ProdagioSoftware/prodagioIndexes"/>

                          <property name="hibernate.search.default.refresh" value="300"/>

                          <property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSMasterDirectoryProvider"/>

                           <property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>

                           <property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/>

                           <property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/>

                           <property name="hibernate.ejb.event.flush-entity" value="com.imagitek.prodagioap.persistence.ProdagioFlushEntityEventListener"/>

                           <property name="hibernate.default_batch_fetch_size" value="20" />

                           <property name="hibernate.ejb.interceptor" value="com.imagitek.prodagioap.persistence.AuditInterceptor" />

            </properties>

       

       

      For slave the persistence.xml is given below

           <properties>

               <property name="hibernate.dialect" value="com.imagitek.prodagioap.persistence.SQLServer2008Dialect"/>

               <property name="hibernate.hbm2ddl.auto" value="update"/>

               <property name="hibernate.show_sql" value="false"/>

               <property name="hibernate.format_sql" value="true"/>

               <property name="jboss.entity.manager.factory.jndi.name" value="java:/prodagioAPEntityManagerFactory"/>

                          

                          <property name="hibernate.search.default.sourceBase" value="/ProdagioSoftware/indexes-master"/>

                          <property name="hibernate.search.default.indexBase" value="/ProdagioSoftware/prodagioIndexes"/>

                          <property name="hibernate.search.default.refresh" value="300"/>

                          <property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSSlaveDirectoryProvider"/>

                          

                           <property name="hibernate.search.worker.backend" value="jms"/>

                           <property name="hibernate.search.worker.jms.connection_factory" value="/ConnectionFactory"/>

                           <property name="hibernate.search.worker.jms.queue" value="queue/hibernatesearch"/>

                          

                           <property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>

                           <property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/>

                           <property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/>

                           <property name="hibernate.ejb.event.flush-entity" value="com.imagitek.prodagioap.persistence.ProdagioFlushEntityEventListener"/>

                           <property name="hibernate.default_batch_fetch_size" value="20" />

                           <property name="hibernate.ejb.interceptor" value="com.imagitek.prodagioap.persistence.AuditInterceptor" />

            </properties>

         </persistence-unit>

       

      Master is updating the local indexes. Slave is not even updating its local indexes. That is the issue I am facing. Please help?

        • 1. Re: Hibernate search FSSlaveDirectoryProvider not working
          hardy.ferentschik

          Do you get any exceptions? How do you know that master is updating the local indexes? Have you opened/inspected them with Luke? If you turn on debug trace on each of the applications can you see something relevant? For example you should be able to see log messages from the directory providers.

           

          Are the path configurations correct? You are usng different type of values for sourceBase between master and slave.

           

          On a side note, you should not need to have to add the Search listeners explicitly. Search will be automatically enabled when on the classpath.

          • 2. Re: Hibernate search FSSlaveDirectoryProvider not working

            Thanks for your response.

             

            I do not get any exceptions. If I make any changes in the master app, I am able to search for that criteria and it works. But in slave it is not the case. I make any changes, then I search for the changed criteria in slave it does not bring back when I search for it.

             

             

            SourceBase is correct. That directory is shared. In one file I use the share name and in the other I use exact path/name.

             

            Can you tell me how to turn the traces on?

            • 3. Re: Hibernate search FSSlaveDirectoryProvider not working
              hardy.ferentschik

              If I make any changes in the master app, I am able to search for that criteria and it works.

                     How do you make changes to the master app? Normally the master app is fed via the JMS queue, but it sounds like you are doing something else.

               

              But in slave it is not the case. I make any changes, then I search for the changed criteria in slave it does not bring back when I search for it.

                     I guess you are waiting the required time in this case. Your refresh period is 300 seconds so it might take up to 5 minutes before the change appears. That said, I think it is important to figure out whether the problem is on the indexing side or on the symchronization side. Again, debug trace should be able to help. Turn it on for a slave. First of all you should get message from FSSlaveDirectoryProvider on whether the provider started properly. Then when you index you should get some output regarding indexing work getting created and submitted. Also check your queue listeners. Does it receive work. I assume that is code you have written yourself (or extended from the provided base class), so you have to add some intstrumentation yourself.

              SourceBase is correct. That directory is shared. In one file I use the share name and in the other I use exact path/name.

              I am still a little suspicious about the file paths. Wouldn't you have to escape the backward slashes when useinf UNC paths? Meaning something like \\\\VICTOR\\indexes-master. You can test this yourself by creating a File using the path you are specifying in the properties file. Does it work?

              • 4. Re: Hibernate search FSSlaveDirectoryProvider not working

                Thanks for your reply. Hardy I spend som time and identified the actual issue. For master the synchronization mechanism is Lucene. The slave syncronization process is "jms". That is where I have problem. When I persist an object, the jms message is passed to the queue correctly. I can see in the web console, in that queue one message getting added. But for whatever reason the message driven bean is not recognized as a consumer. I think the issue is, our application is deployed as a war in jboss 5.0.EAP, I guess the application needs to be deployed as an EAR file to actually activate the message driven bean. This is what I am going try now. Any light in this direction will be appreciated. Am I in the right direction or am I following a wrong path? What do you think

                 

                My message driven bean is defined like this

                 

                @MessageDriven(name="hibernatesearch", activationConfig = {

                                @ActivationConfigProperty(propertyName="destinationType",

                                                          propertyValue="javax.jms.Queue"),

                                @ActivationConfigProperty(propertyName="destination",

                                                          propertyValue="queue/hibernatesearch"),

                                @ActivationConfigProperty(propertyName="DLQMaxResent", propertyValue="1")

                             } )

                //@JndiName("mDBSearchController")

                public class MDBSearchController extends AbstractJMSHibernateSearchController  implements MessageListener

                {

                 

                 

                          @Override

                          protected Session getSession()

                          {

                                    EntityManager em = (EntityManager)Component.getInstance("entityManager");

                                    Session session = (Session)em.getDelegate();

                                    return session;

                          }

                 

                 

                          @Override

                          protected void cleanSessionIfNeeded(Session session)

                          {

                                    session.close();

                 

                          }

                 

                 

                }

                • 5. Re: Hibernate search FSSlaveDirectoryProvider not working
                  hardy.ferentschik

                  I am no expert with message driven bean deplyoment. I guess it also depends on the EJB version as you say. See for example - http://stackoverflow.com/questions/7693726/are-there-limitations-on-deploying-an-mdb-in-a-jboss-war

                  You would need EJB 3.1 which supports EJB deployment in war files. What version is used as part of JBoss 5.0.EAP?

                  • 6. Re: Hibernate search FSSlaveDirectoryProvider not working
                    hardy.ferentschik

                    FYI, I did a quick check and I think in your case you indeed would need an ejb-jar.