org.hibernate.search.backend.impl.jgroups
Class JGroupsBackendQueueProcessor

java.lang.Object
  extended by org.hibernate.search.backend.impl.jgroups.JGroupsBackendQueueProcessor
All Implemented Interfaces:
BackendQueueProcessor

public class JGroupsBackendQueueProcessor
extends Object
implements BackendQueueProcessor

This index backend is able to switch dynamically between a standard Lucene index writing backend and one which sends work remotely over a JGroups channel.

Author:
Lukasz Moren, Sanne Grinovero (C) 2012 Red Hat Inc., Ales Justin

Field Summary
static String BLOCK_WAITING_ACK
          Configuration property specific the the backend instance.
static int DEFAULT_MESSAGE_TIMEOUT
          Default value for the MESSAGE_TIMEOUT_MS configuration property.
static String DELEGATE_BACKEND
          This JGroups backend is meant to delegate to a different backend on the master node.
protected  DirectoryBasedIndexManager indexManager
           
protected  String indexName
           
static String MESSAGE_TIMEOUT_MS
          Specifies the timeout defined on messages sent to other nodes via the JGroups Channel.
protected  MessageSender messageSender
           
 
Constructor Summary
JGroupsBackendQueueProcessor(NodeSelectorStrategy selectionStrategy)
           
 
Method Summary
 void applyStreamWork(LuceneWork singleOperation, IndexingMonitor monitor)
          Applies a single operation on the index, and different operations can be applied in parallel, even in parallel to a workList instance being processed by BackendQueueProcessor.applyWork(List, IndexingMonitor)
 void applyWork(List<LuceneWork> workList, IndexingMonitor monitor)
          Applies a list of operations to the index.
 boolean blocksForACK()
           
 void close()
          Used to shutdown and eventually release resources.
 org.jgroups.Address getAddress()
          Cluster's node address
 BackendQueueProcessor getDelegatedBackend()
           
 Lock getExclusiveWriteLock()
           
 long getMessageTimeout()
           
 void indexMappingChanged()
          Used to notify the backend that the number or type of indexed entities being indexed in this backend changed.
 void initialize(Properties props, WorkerBuildContext context, DirectoryBasedIndexManager indexManager)
          Used at startup, called once as first method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_WAITING_ACK

public static final String BLOCK_WAITING_ACK
Configuration property specific the the backend instance. When enabled the invoker thread will use JGroups in synchronous mode waiting for the ACK from the other parties; when disabled it is going to behave as fire and forget: delegates reliability to the JGroups configuration and returns immediately. The default value depends on the backend configuration: if it's set to async, then block_waiting_ack defaults to false.

See Also:
Environment.WORKER_EXECUTION, Constant Field Values

DELEGATE_BACKEND

public static final String DELEGATE_BACKEND
This JGroups backend is meant to delegate to a different backend on the master node. Generally this is expected to be the Lucene backend, but this property allows to specify a different implementation for the delegate.

See Also:
Constant Field Values

MESSAGE_TIMEOUT_MS

public static final String MESSAGE_TIMEOUT_MS
Specifies the timeout defined on messages sent to other nodes via the JGroups Channel. Value interpreted in milliseconds.

See Also:
Constant Field Values

DEFAULT_MESSAGE_TIMEOUT

public static final int DEFAULT_MESSAGE_TIMEOUT
Default value for the MESSAGE_TIMEOUT_MS configuration property.

See Also:
Constant Field Values

messageSender

protected MessageSender messageSender

indexName

protected String indexName

indexManager

protected DirectoryBasedIndexManager indexManager
Constructor Detail

JGroupsBackendQueueProcessor

public JGroupsBackendQueueProcessor(NodeSelectorStrategy selectionStrategy)
Method Detail

initialize

public void initialize(Properties props,
                       WorkerBuildContext context,
                       DirectoryBasedIndexManager indexManager)
Description copied from interface: BackendQueueProcessor
Used at startup, called once as first method.

Specified by:
initialize in interface BackendQueueProcessor
Parameters:
props - all configuration properties
context - context giving access to required meta data
indexManager - the index it is related to.

close

public void close()
Description copied from interface: BackendQueueProcessor
Used to shutdown and eventually release resources. No other method should be used after this one.

Specified by:
close in interface BackendQueueProcessor

getAddress

public org.jgroups.Address getAddress()
Cluster's node address

Returns:
Address

indexMappingChanged

public void indexMappingChanged()
Description copied from interface: BackendQueueProcessor
Used to notify the backend that the number or type of indexed entities being indexed in this backend changed. This could trigger some needed reconfiguration.

Specified by:
indexMappingChanged in interface BackendQueueProcessor

applyWork

public void applyWork(List<LuceneWork> workList,
                      IndexingMonitor monitor)
Description copied from interface: BackendQueueProcessor
Applies a list of operations to the index. A single list might be processed by applying elements in parallel threads, but no work should be started on a new workList until the previous one was fully processed. Work could be applied asynchronously according to capabilities and configuration of implementor. A null parameter is not acceptable, implementations should throw an IllegalArgumentException.

Specified by:
applyWork in interface BackendQueueProcessor
Parameters:
workList - list of Lucene work instance which need to be applied to the index
monitor - a IndexingMonitor object.

applyStreamWork

public void applyStreamWork(LuceneWork singleOperation,
                            IndexingMonitor monitor)
Description copied from interface: BackendQueueProcessor
Applies a single operation on the index, and different operations can be applied in parallel, even in parallel to a workList instance being processed by BackendQueueProcessor.applyWork(List, IndexingMonitor)

Specified by:
applyStreamWork in interface BackendQueueProcessor
Parameters:
singleOperation - single Lucene work instance to be applied to the index
monitor - a IndexingMonitor object.

getExclusiveWriteLock

public Lock getExclusiveWriteLock()
Specified by:
getExclusiveWriteLock in interface BackendQueueProcessor
Returns:
a Lock instance which will block index modifications when acquired

blocksForACK

public boolean blocksForACK()

getDelegatedBackend

public BackendQueueProcessor getDelegatedBackend()

getMessageTimeout

public long getMessageTimeout()


Copyright © 2006-2013 Red Hat Middleware, LLC. All Rights Reserved