Package org.elasticsearch.test.gateway
Class TestGatewayAllocator
java.lang.Object
org.elasticsearch.gateway.GatewayAllocator
org.elasticsearch.test.gateway.TestGatewayAllocator
- All Implemented Interfaces:
ExistingShardsAllocator
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 of
GatewayAllocator
but do
not have all the infrastructure required to use it.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
ExistingShardsAllocator.UnassignedAllocationHandler
-
Field Summary
Fields inherited from class org.elasticsearch.gateway.GatewayAllocator
ALLOCATOR_NAME
Fields inherited from interface org.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
EXISTING_SHARDS_ALLOCATOR_SETTING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addKnownAllocation
(ShardRouting shard) manually add a specific shard to the allocations the gateway keeps track ofvoid
afterPrimariesBeforeReplicas
(RoutingAllocation allocation) void
allocateUnassigned
(ShardRouting shardRouting, RoutingAllocation allocation, ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler) void
applyFailedShards
(List<FailedShard> failedShards, RoutingAllocation allocation) void
applyStartedShards
(List<ShardRouting> startedShards, RoutingAllocation allocation) void
beforeAllocation
(RoutingAllocation allocation) explainUnassignedShardAllocation
(ShardRouting unassignedShard, RoutingAllocation routingAllocation) Methods inherited from class org.elasticsearch.gateway.GatewayAllocator
cleanCaches, getNumberOfInFlightFetches, innerAllocatedUnassigned
-
Constructor Details
-
TestGatewayAllocator
public TestGatewayAllocator()
-
-
Method Details
-
applyStartedShards
- Specified by:
applyStartedShards
in interfaceExistingShardsAllocator
- Overrides:
applyStartedShards
in classGatewayAllocator
-
applyFailedShards
- Specified by:
applyFailedShards
in interfaceExistingShardsAllocator
- Overrides:
applyFailedShards
in classGatewayAllocator
-
beforeAllocation
- Specified by:
beforeAllocation
in interfaceExistingShardsAllocator
- Overrides:
beforeAllocation
in classGatewayAllocator
-
afterPrimariesBeforeReplicas
- Specified by:
afterPrimariesBeforeReplicas
in interfaceExistingShardsAllocator
- Overrides:
afterPrimariesBeforeReplicas
in classGatewayAllocator
-
allocateUnassigned
public void allocateUnassigned(ShardRouting shardRouting, RoutingAllocation allocation, ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler) - Specified by:
allocateUnassigned
in interfaceExistingShardsAllocator
- Overrides:
allocateUnassigned
in classGatewayAllocator
-
explainUnassignedShardAllocation
public AllocateUnassignedDecision explainUnassignedShardAllocation(ShardRouting unassignedShard, RoutingAllocation routingAllocation) - Specified by:
explainUnassignedShardAllocation
in interfaceExistingShardsAllocator
- Overrides:
explainUnassignedShardAllocation
in classGatewayAllocator
-
addKnownAllocation
manually add a specific shard to the allocations the gateway keeps track of
-