From 1ff348ed7f5bab9726765a1e60e8a43ec93bcf71 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 17 Aug 2016 15:48:12 -0700 Subject: Plugins: Make custom allocation deciders use pull based extensions This change converts AllocationDecider registration from push based on ClusterModule to implementing with a new ClusterPlugin interface. AllocationDecider instances are allowed to use only Settings and ClusterSettings. --- .../benchmark/routing/allocation/Allocators.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'benchmarks') diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/Allocators.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/Allocators.java index 9b1cfaabf9..ad06f75074 100644 --- a/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/Allocators.java +++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/Allocators.java @@ -38,6 +38,8 @@ import org.elasticsearch.gateway.GatewayAllocator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -72,7 +74,7 @@ public final class Allocators { public static AllocationService createAllocationService(Settings settings) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { - return createAllocationService(settings, new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings + return createAllocationService(settings, new ClusterSettings(Settings.EMPTY, ClusterSettings .BUILT_IN_CLUSTER_SETTINGS)); } @@ -85,19 +87,9 @@ public final class Allocators { public static AllocationDeciders defaultAllocationDeciders(Settings settings, ClusterSettings clusterSettings) throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException { - List list = new ArrayList<>(); - // Keep a deterministic order of allocation deciders for the benchmark - for (Class deciderClass : ClusterModule.DEFAULT_ALLOCATION_DECIDERS) { - try { - Constructor constructor = deciderClass.getConstructor(Settings.class, ClusterSettings - .class); - list.add(constructor.newInstance(settings, clusterSettings)); - } catch (NoSuchMethodException e) { - Constructor constructor = deciderClass.getConstructor(Settings.class); - list.add(constructor.newInstance(settings)); - } - } - return new AllocationDeciders(settings, list.toArray(new AllocationDecider[0])); + Collection deciders = + ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList()); + return new AllocationDeciders(settings, deciders); } -- cgit v1.2.3