Fórum

How does "lucene.replicate.write" work?

narf dark, modificado 9 Anos atrás.

How does "lucene.replicate.write" work?

Junior Member Postagens: 46 Data de Entrada: 12/11/12 Postagens Recentes
Hi,
So i've been spending a fair amount of time in the Liferay source code trying to figure out how exactly Lucene "reindex" events get distributed/communicated to peer nodes in the cluster. Lets take a simple use case of what it is I need pointers to in the source code of Liferay (which is completely void of any sort of documentation, comments inline)

Lets say we have a 2 node liferay cluster configured with cluster.link.enabled=true and lucene.replicate.write=true. Each node in the cluster is reading/writing to its own local Lucene index on disk.

a) On Liferay server NODE1, some user (via the UI) goes to "users" management screen and changes Joe's title attribute and hits save

b) This is saved in the database and indexed locally in Lucene via the IndexableAdvice AOP process, executing on NODE1

c) How does NODE2 receive the message (triggered by the action that occurred on NODE1) that "hey peers: you need to reindex model object 'user' w/ identifier N".

I really am having trouble finding the code path where this ultimately results in a "message" being sent to cluster peers (via any transport RMI/jgroups does not matter) stating something to the effect of "hey peers: you need to reindex model object 'user' w/ identifier N".

I checked the ModelListeners triggered from BasePersistenceImpl as well and don't see anything there. I dug around looking for how "lucene.replicate.write" (and its LUCENE_REPLICATE_WRITE constant variants) are utilized but only see it referenced from LuceneHelperImpl.isLoadIndexFromClusterEnabled() and that in turn seems to be utilized from the following more general/aggregate functions of loading an entire index from a peer or telling another peer to completely re-index everything rather than individual "events"

  • the admin portlet (EditServerAction) when an instruction to reindex the entire index is issued (and relayed on to cluster peers)
  • triggered by calls to LoadIndexClusterListener for JOIN events only, where it seems to trigger a stream read of another peer's raw index data?


Does Liferay have any documentation on the class architecture, in particular how index operation "events" are distributed to cluster peers? There literally is zero documentation in the source code itself which is frustrating.
narf dark, modificado 9 Anos atrás.

RE: How does "lucene.replicate.write" work?

Junior Member Postagens: 46 Data de Entrada: 12/11/12 Postagens Recentes
bump
thumbnail
Amos Fong, modificado 9 Anos atrás.

RE: How does "lucene.replicate.write" work?

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
I haven't dug into the code lately, but this is what I remember after a quick glance.

A ClusterBridgeMessageListener is registered to the same message bus destination used for index writing. So when messages to reindex an object is sent on the message bus to lucene's listener, the ClusterBridgeMessageListener will also receive it and send a multicast message out to all other nodes. The other node's ClusterForwardMessageListener will receive it and send it along its local message bus.

Hope that helps you trace the code for lucene replication.
narf dark, modificado 9 Anos atrás.

RE: How does "lucene.replicate.write" work?

Junior Member Postagens: 46 Data de Entrada: 12/11/12 Postagens Recentes
Thanks for the reply

A ClusterBridgeMessageListener is registered to the same message bus destination used for index writing


Yeah I guess I just don't see where any "message" is being sent along a message bus when reindex is called

a) Some code invokes UserLocalServiceBaseImpl.update(user) which is annotated w/ @Indexable

b) This in-turn calls UserPersistenceImpl[BasePersistenceImpl].update() (which triggers ModelListeners, which appear to do nothing related to indexing or message sending at least UserListener does not)

b) After returning, IndexableAdvice.afterReturning() is invoked which calls Indexer[UserIndexer].reindex() -> doReindex() which just appears to update any existing user Document via SearchEngineUtil.updateDocument()

Can anyone shed light on this? Where is the design documentation for Liferay?
narf dark, modificado 9 Anos atrás.

RE: How does "lucene.replicate.write" work?

Junior Member Postagens: 46 Data de Entrada: 12/11/12 Postagens Recentes
Is it this?


<!-- Advice -->

<bean class="com.liferay.portal.spring.aop.DynamicProxyCreator$Register">
<constructor-arg>
<bean class="com.liferay.portal.messaging.proxy.MessagingProxyBeanMatcher">
<property name="beanClass" value="com.liferay.portal.kernel.messaging.proxy.BaseMultiDestinationProxyBean" />
<property name="beanNamePattern" value="com.liferay.portal.kernel.search.*ProxyBean" />
</bean>
</constructor-arg>
<constructor-arg>
<bean class="com.liferay.portal.messaging.proxy.MultiDestinationMessagingProxyInvocationHandler" factory-method="getInvocationHandlerFactory" />
</constructor-arg>
</bean>

<!-- Proxy -->

<bean id="com.liferay.portal.kernel.search.IndexSearcherProxyBean" class="com.liferay.portal.kernel.search.IndexSearcherProxyBean">
<property name="messageSender" ref="com.liferay.portal.kernel.messaging.sender.MessageSender" />
<property name="synchronousMessageSender" ref="com.liferay.portal.kernel.messaging.sender.DirectSynchronousMessageSender" />
</bean>
<bean id="com.liferay.portal.kernel.search.IndexWriterProxyBean" class="com.liferay.portal.kernel.search.IndexWriterProxyBean">
<property name="messageSender" ref="com.liferay.portal.kernel.messaging.sender.MessageSender" />
<property name="synchronousMessageSender" ref="com.liferay.portal.kernel.messaging.sender.DirectSynchronousMessageSender" />
</bean>

<!-- Configurator -->

<bean id="searchEngineConfigurator.core" class="com.liferay.portal.kernel.search.DefaultSearchEngineConfigurator">
<property name="defaultSearchEngineId" value="SYSTEM_ENGINE" />
<property name="indexSearcher" ref="com.liferay.portal.kernel.search.IndexSearcherProxyBean" />
<property name="indexWriter" ref="com.liferay.portal.kernel.search.IndexWriterProxyBean" />
<property name="messageBus" ref="com.liferay.portal.kernel.messaging.MessageBus" />
<property name="searchEngines">
<util:map>
<entry key="GENERIC_ENGINE" value-ref="com.liferay.portal.search.generic.GenericSearchEngineImpl" />
<entry key="SYSTEM_ENGINE" value-ref="com.liferay.portal.search.lucene.LuceneSearchEngineImpl" />
</util:map>
</property>
</bean>
<bean id="com.liferay.portal.resiliency.spi.search.SPISearchEngineConfigurator" class="com.liferay.portal.resiliency.spi.search.SPISearchEngineConfigurator">
<property name="messageBus" ref="com.liferay.portal.kernel.messaging.MessageBus" />
</bean>