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_NAMEFields inherited from interface org.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
EXISTING_SHARDS_ALLOCATOR_SETTING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKnownAllocation(ShardRouting shard) manually add a specific shard to the allocations the gateway keeps track ofvoidafterPrimariesBeforeReplicas(RoutingAllocation allocation, Predicate<ShardRouting> isRelevantShardPredicate) voidallocateUnassigned(ShardRouting shardRouting, RoutingAllocation allocation, ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler) voidapplyFailedShards(List<FailedShard> failedShards, RoutingAllocation allocation) voidapplyStartedShards(List<ShardRouting> startedShards, RoutingAllocation allocation) voidbeforeAllocation(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:
applyStartedShardsin interfaceExistingShardsAllocator- Overrides:
applyStartedShardsin classGatewayAllocator
-
applyFailedShards
- Specified by:
applyFailedShardsin interfaceExistingShardsAllocator- Overrides:
applyFailedShardsin classGatewayAllocator
-
beforeAllocation
- Specified by:
beforeAllocationin interfaceExistingShardsAllocator- Overrides:
beforeAllocationin classGatewayAllocator
-
afterPrimariesBeforeReplicas
public void afterPrimariesBeforeReplicas(RoutingAllocation allocation, Predicate<ShardRouting> isRelevantShardPredicate) - Specified by:
afterPrimariesBeforeReplicasin interfaceExistingShardsAllocator- Overrides:
afterPrimariesBeforeReplicasin classGatewayAllocator
-
allocateUnassigned
public void allocateUnassigned(ShardRouting shardRouting, RoutingAllocation allocation, ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler) - Specified by:
allocateUnassignedin interfaceExistingShardsAllocator- Overrides:
allocateUnassignedin classGatewayAllocator
-
explainUnassignedShardAllocation
public AllocateUnassignedDecision explainUnassignedShardAllocation(ShardRouting unassignedShard, RoutingAllocation routingAllocation) - Specified by:
explainUnassignedShardAllocationin interfaceExistingShardsAllocator- Overrides:
explainUnassignedShardAllocationin classGatewayAllocator
-
addKnownAllocation
manually add a specific shard to the allocations the gateway keeps track of
-