Package org.elasticsearch.test.gateway
Class TestGatewayAllocator
- java.lang.Object
-
- org.elasticsearch.gateway.GatewayAllocator
-
- org.elasticsearch.test.gateway.TestGatewayAllocator
-
public class TestGatewayAllocator extends GatewayAllocator
A gateway allocator implementation that keeps an in memory list of started shard allocation that are used as replies to the, normally async, fetch data requests. The in memory list is adapted when shards are started and failed. Nodes leaving and joining the cluster do not change the list of shards the class tracks but rather serves as a filter to what is returned by fetch data. Concretely - fetch data will only return shards that were started on nodes that are currently part of the cluster. For now only primary shard related data is fetched. Replica request always get an empty response. This class is useful to use in unit tests that require the functionality ofGatewayAllocator
but do not have all the infrastructure required to use it.
-
-
Constructor Summary
Constructors Constructor Description TestGatewayAllocator()
-
Method Summary
Modifier and Type Method Description void
addKnownAllocation(ShardRouting shard)
manually add a specific shard to the allocations the gateway keeps track ofvoid
allocateUnassigned(RoutingAllocation allocation)
void
applyFailedShards(RoutingAllocation allocation, java.util.List<FailedShard> failedShards)
void
applyStartedShards(RoutingAllocation allocation, java.util.List<ShardRouting> startedShards)
-
Methods inherited from class org.elasticsearch.gateway.GatewayAllocator
decideUnassignedShardAllocation, getNumberOfInFlightFetch, innerAllocatedUnassigned
-
-
-
-
Method Detail
-
applyStartedShards
public void applyStartedShards(RoutingAllocation allocation, java.util.List<ShardRouting> startedShards)
- Overrides:
applyStartedShards
in classGatewayAllocator
-
applyFailedShards
public void applyFailedShards(RoutingAllocation allocation, java.util.List<FailedShard> failedShards)
- Overrides:
applyFailedShards
in classGatewayAllocator
-
allocateUnassigned
public void allocateUnassigned(RoutingAllocation allocation)
- Overrides:
allocateUnassigned
in classGatewayAllocator
-
addKnownAllocation
public void addKnownAllocation(ShardRouting shard)
manually add a specific shard to the allocations the gateway keeps track of
-
-