Package org.elasticsearch.test.gateway
Class TestGatewayAllocator
java.lang.Object
org.elasticsearch.gateway.GatewayAllocator
org.elasticsearch.test.gateway.TestGatewayAllocator
- All Implemented Interfaces:
org.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
public class TestGatewayAllocator
extends org.elasticsearch.gateway.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 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
org.elasticsearch.cluster.routing.allocation.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
Constructors Constructor Description TestGatewayAllocator()
-
Method Summary
Modifier and Type Method Description void
addKnownAllocation(org.elasticsearch.cluster.routing.ShardRouting shard)
manually add a specific shard to the allocations the gateway keeps track ofvoid
afterPrimariesBeforeReplicas(org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation)
void
allocateUnassigned(org.elasticsearch.cluster.routing.ShardRouting shardRouting, org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation, org.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler)
void
applyFailedShards(java.util.List<org.elasticsearch.cluster.routing.allocation.FailedShard> failedShards, org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation)
void
applyStartedShards(java.util.List<org.elasticsearch.cluster.routing.ShardRouting> startedShards, org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation)
void
beforeAllocation(org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation)
Methods inherited from class org.elasticsearch.gateway.GatewayAllocator
cleanCaches, explainUnassignedShardAllocation, getNumberOfInFlightFetches, innerAllocatedUnassigned
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
TestGatewayAllocator
public TestGatewayAllocator()
-
-
Method Details
-
applyStartedShards
public void applyStartedShards(java.util.List<org.elasticsearch.cluster.routing.ShardRouting> startedShards, org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation)- Specified by:
applyStartedShards
in interfaceorg.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
- Overrides:
applyStartedShards
in classorg.elasticsearch.gateway.GatewayAllocator
-
applyFailedShards
public void applyFailedShards(java.util.List<org.elasticsearch.cluster.routing.allocation.FailedShard> failedShards, org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation)- Specified by:
applyFailedShards
in interfaceorg.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
- Overrides:
applyFailedShards
in classorg.elasticsearch.gateway.GatewayAllocator
-
beforeAllocation
public void beforeAllocation(org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation)- Specified by:
beforeAllocation
in interfaceorg.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
- Overrides:
beforeAllocation
in classorg.elasticsearch.gateway.GatewayAllocator
-
afterPrimariesBeforeReplicas
public void afterPrimariesBeforeReplicas(org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation)- Specified by:
afterPrimariesBeforeReplicas
in interfaceorg.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
- Overrides:
afterPrimariesBeforeReplicas
in classorg.elasticsearch.gateway.GatewayAllocator
-
allocateUnassigned
public void allocateUnassigned(org.elasticsearch.cluster.routing.ShardRouting shardRouting, org.elasticsearch.cluster.routing.allocation.RoutingAllocation allocation, org.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler)- Specified by:
allocateUnassigned
in interfaceorg.elasticsearch.cluster.routing.allocation.ExistingShardsAllocator
- Overrides:
allocateUnassigned
in classorg.elasticsearch.gateway.GatewayAllocator
-
addKnownAllocation
public void addKnownAllocation(org.elasticsearch.cluster.routing.ShardRouting shard)manually add a specific shard to the allocations the gateway keeps track of
-