com.senseidb.search.node
Class AbstractConsistentHashBroker<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult>

java.lang.Object
  extended by com.senseidb.search.node.AbstractSenseiBroker<REQUEST,RESULT>
      extended by com.senseidb.search.node.AbstractConsistentHashBroker<REQUEST,RESULT>
Type Parameters:
REQUEST -
RESULT -
All Implemented Interfaces:
com.linkedin.norbert.javacompat.cluster.ClusterListener
Direct Known Subclasses:
SenseiBroker, SenseiSysBroker

public abstract class AbstractConsistentHashBroker<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult>
extends AbstractSenseiBroker<REQUEST,RESULT>

Author:
"Xiaoyang Gu"

Field Summary
protected  SenseiLoadBalancer _loadBalancer
           
protected  com.linkedin.norbert.network.Serializer<REQUEST,RESULT> _serializer
           
protected  long _timeout
           
 
Fields inherited from class com.senseidb.search.node.AbstractSenseiBroker
_networkClient, _partitions
 
Constructor Summary
AbstractConsistentHashBroker(com.linkedin.norbert.javacompat.network.PartitionedNetworkClient<Integer> networkClient, com.linkedin.norbert.network.Serializer<REQUEST,RESULT> serializer)
           
 
Method Summary
 RESULT browse(REQUEST req)
          The method that provides the search service.
<T> T
customizeRequest(REQUEST request)
           
protected  RESULT doBrowse(com.linkedin.norbert.javacompat.network.PartitionedNetworkClient<Integer> networkClient, REQUEST req, it.unimi.dsi.fastutil.ints.IntSet partitions)
           
abstract  RESULT getEmptyResultInstance()
           
protected  it.unimi.dsi.fastutil.ints.IntSet getPartitions(Set<com.linkedin.norbert.javacompat.cluster.Node> nodes)
           
abstract  String getRouteParam(REQUEST req)
           
abstract  long getTimeoutMillis()
           
abstract  RESULT mergeResults(REQUEST request, List<RESULT> resultList)
          Merge results on the client/broker side.
<T> T
restoreRequest(REQUEST request, T state)
           
abstract  void setTimeoutMillis(long timeoutMillis)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.linkedin.norbert.javacompat.cluster.ClusterListener
handleClusterConnected, handleClusterDisconnected, handleClusterNodesChanged, handleClusterShutdown
 

Field Detail

_timeout

protected long _timeout

_serializer

protected final com.linkedin.norbert.network.Serializer<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult> _serializer

_loadBalancer

protected volatile SenseiLoadBalancer _loadBalancer
Constructor Detail

AbstractConsistentHashBroker

public AbstractConsistentHashBroker(com.linkedin.norbert.javacompat.network.PartitionedNetworkClient<Integer> networkClient,
                                    com.linkedin.norbert.network.Serializer<REQUEST,RESULT> serializer)
                             throws com.linkedin.norbert.NorbertException
Parameters:
networkClient -
clusterClient -
routerFactory -
serializer - The serializer used to serialize/deserialize request/response pairs
scatterGatherHandler -
Throws:
com.linkedin.norbert.NorbertException
Method Detail

customizeRequest

public <T> T customizeRequest(REQUEST request)

restoreRequest

public <T> T restoreRequest(REQUEST request,
                            T state)

getPartitions

protected it.unimi.dsi.fastutil.ints.IntSet getPartitions(Set<com.linkedin.norbert.javacompat.cluster.Node> nodes)

getEmptyResultInstance

public abstract RESULT getEmptyResultInstance()
Specified by:
getEmptyResultInstance in class AbstractSenseiBroker<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult>
Returns:
an empty result instance. Used when the request cannot be properly processed or when the true result is empty.

browse

public RESULT browse(REQUEST req)
                                           throws SenseiException
The method that provides the search service.

Overrides:
browse in class AbstractSenseiBroker<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult>
Parameters:
req -
Returns:
Throws:
SenseiException

mergeResults

public abstract RESULT mergeResults(REQUEST request,
                                    List<RESULT> resultList)
Merge results on the client/broker side. It likely works differently from the one in the search node.

Parameters:
request - the original request object
resultList - the list of results from all the requested partitions.
Returns:
one single result instance that is merged from the result list.

getRouteParam

public abstract String getRouteParam(REQUEST req)

doBrowse

protected RESULT doBrowse(com.linkedin.norbert.javacompat.network.PartitionedNetworkClient<Integer> networkClient,
                          REQUEST req,
                          it.unimi.dsi.fastutil.ints.IntSet partitions)
Specified by:
doBrowse in class AbstractSenseiBroker<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult>

shutdown

public void shutdown()
Overrides:
shutdown in class AbstractSenseiBroker<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult>

setTimeoutMillis

public abstract void setTimeoutMillis(long timeoutMillis)
Specified by:
setTimeoutMillis in class AbstractSenseiBroker<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult>

getTimeoutMillis

public abstract long getTimeoutMillis()
Specified by:
getTimeoutMillis in class AbstractSenseiBroker<REQUEST extends AbstractSenseiRequest,RESULT extends AbstractSenseiResult>


Copyright © 2010-2012. All Rights Reserved.