http://senseidb.github.com/sensei/cluster.html
sensei中在node上层有一个broker的概念,会拦截data-event和query request.
每个broker都会从zookeeper那里得到一份shard-id to node-id map.
在索引的时候:
broker接受到事件的时候,会使用ShardingStrategy分发事件。
sensei.sharding.strategy定义进行分发的类。
在查询的时候:
broker接受到请求,会使用LoadBalancerFactory得到LoadBalancerFactory进行分桶。把不同的请求打到不同的node.
sensei.search.router.factory配置进行分发的类。
Under the hood
Each Sensei node reports to Zookeeper, our cluster manager, its state and which shards it has. Zookeeper propagates this information through-out the entire cluster, especially to the brokers. The brokers maintains an inverse map of shard id to node id list. This list is kept up to date with cluster topology changes from newly introduced nodes and/or node failures.
Sharding Strategy
At indexing time, the ShardingStrategy is applied from the data events streamed-in from the gateway for each node. So only data-events belong to a specific shard is added. ShardingStrategy can be configured with sensei.sharding.strategy setting in the sensei.properties file.
Load Balancer Factory
At query time, the broker uses the SenseiLoadBalancerFactory to get a SenseiLoadBalancer and generates a routing map to get a list of nodes to send the requests to. By default, broker uses consistent hash on the routing parameter provided by the request. Load balancer factory can be configured with sensei.search.router.factory setting in the sensei.properties file.