2

我是编写使用 Hibernate Search 的 Web 应用程序的团队的一员,我们最近尝试开始使用 JGroups 来保持不同节点上的 Lucene 索引彼此同步。

但是,我一直无法完成设置此设置的最基本的第一步,并且文档似乎很稀疏

<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="myFactory">
<property name="dataSource" ref="myDataSource"/>
<property name="persistenceXmlLocation" value="/WEB-INF/persistence.xml"/>
<property name="persistenceUnitName" value="persistenceUnit"/>
<property name="jpaVendorAdapter" ref="vendorAdapter"/>
<property name="jpaProperties">
    <props>
        <prop key="hibernate.search.worker.backend.jgroups.configurationFile">jgroups-config.xml</prop>
        <prop key="hibernate.search.default.directory_provider">infinispan</prop>
        <prop key="hibernate.search.default.indexBase">indexes</prop>
        <prop key="hibernate.search.default.worker.backend">jgroups</prop>
        <prop key="hibernate.search.services.jgroups.clusterName">MyCluster</prop>
        <prop key="hibernate.search.error_handler">log</prop>
        <prop key="hibernate.search.lucene_version">LUCENE_36</prop>
        <prop key="hibernate.search.generate_statistics">true</prop>
        <prop key="hibernate.search.jmx_enabled">true</prop>
    </props>
</property>

这里的关键属性是hibernate.search.worker.backend.jgroups.configurationFile我们最终需要的 jgroups 配置文件的名称。我尝试将此文件放在 WEB-INF 和 JBoss 模块目录结构中的 props 文件中(其他文件位于并成功加载),但它只是没有被拾取。

在日志中我可以看到:

16:34:57,609 INFO  [org.hibernate.search.backend.impl.jgroups.JGroupsChannelProvider] (MSC service thread 1-1) HSEARCH000005: Starting JGroups Channel
16:34:57,609 INFO  [org.hibernate.search.backend.impl.jgroups.JGroupsChannelProvider] (MSC service thread 1-1) HSEARCH000011: Unable to use any JGroups configuration mechanisms provided in properties { hibernate.search.default.worker.backend=jgroups, hibernate.search.default.directory_provider=infinispan, hibernate.search.worker.backend.jgroups.configurationFile=jgroups-config.xml}. Using default JGroups configuration file!
16:34:59,427 INFO  [stdout] (MSC service thread 1-1) 
16:34:59,427 INFO  [stdout] (MSC service thread 1-1) -------------------------------------------------------------------
16:34:59,428 INFO  [stdout] (MSC service thread 1-1) GMS: address=LDNLPT1271-PC-17149, cluster=CrisisHubCluster, physical address=172.26.10.169:58147
16:34:59,428 INFO  [stdout] (MSC service thread 1-1) -------------------------------------------------------------------
16:35:02,448 INFO  [org.hibernate.search.backend.impl.jgroups.JGroupsMasterMessageListener] (MSC service thread 1-1) HSEARCH000015: Received new cluster view: [LDNLPT1271-PC-17149|0] [LDNLPT1271-PC-17149]
16:35:02,450 INFO  [org.hibernate.search.backend.impl.jgroups.JGroupsChannelProvider] (MSC service thread 1-1) HSEARCH000006: Connected to cluster [ MyCluster ]. The node address is LDNLPT1271-PC-17149
16:35:02,513 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (CacheStartThread,HibernateSearch-Infinispan-cluster,LuceneIndexesMetadata) ISPN000078: Starting JGroups Channel
16:35:02,514 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (CacheStartThread,HibernateSearch-Infinispan-cluster,LuceneIndexesMetadata) ISPN000088: Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration!

我已经截断了属性列表,Unable to use any JGroups configuration mechanisms provided in properties因为它会占用几页,但是如果您查看该行,您会看到它列出了属性,同时它说它找不到它。

因此,它没有获取配置文件位置,而是使用默认值。

这里有没有人在 Hibernate Search 中使用过 jgroups?您是否设法提供了自定义 jgroups 配置文件?你是怎么做到的?

4

1 回答 1

3

对。我必须下载 Hibernate Search 源并逐步启动服务器才能找到它。我使用的是 Hibernate 4.2,我所指的文档版本主要是针对3.2.

在这两个版本之间,有人将属性从 重命名hibernate.search.worker.backend.jgroups.configurationFilehibernate.search.services.jgroups.configurationFile

于 2013-07-12T10:47:30.910 回答