Package org.opensearch.test.gateway
Class TestGatewayAllocator
java.lang.Object
org.opensearch.gateway.GatewayAllocator
org.opensearch.test.gateway.TestGatewayAllocator
- All Implemented Interfaces:
org.opensearch.cluster.routing.allocation.ExistingShardsAllocator
public class TestGatewayAllocator
extends org.opensearch.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
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TestGatewayAllocator() -
Method Summary
Modifier and Type Method Description voidaddKnownAllocation(org.opensearch.cluster.routing.ShardRouting shard)manually add a specific shard to the allocations the gateway keeps track ofvoidafterPrimariesBeforeReplicas(org.opensearch.cluster.routing.allocation.RoutingAllocation allocation)voidallocateUnassigned(org.opensearch.cluster.routing.ShardRouting shardRouting, org.opensearch.cluster.routing.allocation.RoutingAllocation allocation, org.opensearch.cluster.routing.allocation.ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler)voidapplyFailedShards(java.util.List<org.opensearch.cluster.routing.allocation.FailedShard> failedShards, org.opensearch.cluster.routing.allocation.RoutingAllocation allocation)voidapplyStartedShards(java.util.List<org.opensearch.cluster.routing.ShardRouting> startedShards, org.opensearch.cluster.routing.allocation.RoutingAllocation allocation)voidbeforeAllocation(org.opensearch.cluster.routing.allocation.RoutingAllocation allocation)
-
Constructor Details
-
TestGatewayAllocator
public TestGatewayAllocator()
-
-
Method Details
-
applyStartedShards
public void applyStartedShards(java.util.List<org.opensearch.cluster.routing.ShardRouting> startedShards, org.opensearch.cluster.routing.allocation.RoutingAllocation allocation)- Specified by:
applyStartedShardsin interfaceorg.opensearch.cluster.routing.allocation.ExistingShardsAllocator- Overrides:
applyStartedShardsin classorg.opensearch.gateway.GatewayAllocator
-
applyFailedShards
public void applyFailedShards(java.util.List<org.opensearch.cluster.routing.allocation.FailedShard> failedShards, org.opensearch.cluster.routing.allocation.RoutingAllocation allocation)- Specified by:
applyFailedShardsin interfaceorg.opensearch.cluster.routing.allocation.ExistingShardsAllocator- Overrides:
applyFailedShardsin classorg.opensearch.gateway.GatewayAllocator
-
beforeAllocation
public void beforeAllocation(org.opensearch.cluster.routing.allocation.RoutingAllocation allocation)- Specified by:
beforeAllocationin interfaceorg.opensearch.cluster.routing.allocation.ExistingShardsAllocator- Overrides:
beforeAllocationin classorg.opensearch.gateway.GatewayAllocator
-
afterPrimariesBeforeReplicas
public void afterPrimariesBeforeReplicas(org.opensearch.cluster.routing.allocation.RoutingAllocation allocation)- Specified by:
afterPrimariesBeforeReplicasin interfaceorg.opensearch.cluster.routing.allocation.ExistingShardsAllocator- Overrides:
afterPrimariesBeforeReplicasin classorg.opensearch.gateway.GatewayAllocator
-
allocateUnassigned
public void allocateUnassigned(org.opensearch.cluster.routing.ShardRouting shardRouting, org.opensearch.cluster.routing.allocation.RoutingAllocation allocation, org.opensearch.cluster.routing.allocation.ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler)- Specified by:
allocateUnassignedin interfaceorg.opensearch.cluster.routing.allocation.ExistingShardsAllocator- Overrides:
allocateUnassignedin classorg.opensearch.gateway.GatewayAllocator
-
addKnownAllocation
public void addKnownAllocation(org.opensearch.cluster.routing.ShardRouting shard)manually add a specific shard to the allocations the gateway keeps track of
-