From 36ad3b246a3769b51c5262c489de9544dfb5049b Mon Sep 17 00:00:00 2001 From: kimchy Date: Sun, 22 Aug 2010 12:35:59 +0300 Subject: [PATCH] addlow to add node allocation ot the module --- .idea/dictionaries/kimchy.xml | 1 + .../allocation/ShardAllocationModule.java | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.idea/dictionaries/kimchy.xml b/.idea/dictionaries/kimchy.xml index 5dfc0237f8a..835c47c52c5 100644 --- a/.idea/dictionaries/kimchy.xml +++ b/.idea/dictionaries/kimchy.xml @@ -81,6 +81,7 @@ millis mmap multi + multibinder multicast multiline mvel diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/ShardAllocationModule.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/ShardAllocationModule.java index 94eed7b08bf..8f00e2aff67 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/ShardAllocationModule.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/ShardAllocationModule.java @@ -19,26 +19,38 @@ package org.elasticsearch.cluster.routing.allocation; +import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.Multibinder; import org.elasticsearch.common.settings.Settings; +import java.util.List; + /** * @author kimchy (shay.banon) */ public class ShardAllocationModule extends AbstractModule { + private List> allocations = Lists.newArrayList(); + public ShardAllocationModule(Settings settings) { } + public void addNodeAllocation(Class nodeAllocation) { + allocations.add(nodeAllocation); + } + @Override protected void configure() { bind(ShardsAllocation.class).asEagerSingleton(); bind(PreferUnallocatedStrategy.class).to(PreferUnallocatedShardUnassignedStrategy.class).asEagerSingleton(); - Multibinder decidersBinder = Multibinder.newSetBinder(binder(), NodeAllocation.class); - decidersBinder.addBinding().to(SameShardNodeAllocation.class); - decidersBinder.addBinding().to(ReplicaAfterPrimaryActiveNodeAllocation.class); - decidersBinder.addBinding().to(ThrottlingNodeAllocation.class); + Multibinder allocationMultibinder = Multibinder.newSetBinder(binder(), NodeAllocation.class); + allocationMultibinder.addBinding().to(SameShardNodeAllocation.class); + allocationMultibinder.addBinding().to(ReplicaAfterPrimaryActiveNodeAllocation.class); + allocationMultibinder.addBinding().to(ThrottlingNodeAllocation.class); + for (Class allocation : allocations) { + allocationMultibinder.addBinding().to(allocation); + } bind(NodeAllocations.class).asEagerSingleton(); }