Search in sources :

Example 11 with IndexingPressureService

use of org.opensearch.index.IndexingPressureService in project OpenSearch by opensearch-project.

the class RetentionLeaseSyncActionTests method testRetentionLeaseSyncActionOnPrimary.

public void testRetentionLeaseSyncActionOnPrimary() {
    final IndicesService indicesService = mock(IndicesService.class);
    final Index index = new Index("index", "uuid");
    final IndexService indexService = mock(IndexService.class);
    when(indicesService.indexServiceSafe(index)).thenReturn(indexService);
    final int id = randomIntBetween(0, 4);
    final IndexShard indexShard = mock(IndexShard.class);
    when(indexService.getShard(id)).thenReturn(indexShard);
    final ShardId shardId = new ShardId(index, id);
    when(indexShard.shardId()).thenReturn(shardId);
    final RetentionLeaseSyncAction action = new RetentionLeaseSyncAction(Settings.EMPTY, transportService, clusterService, indicesService, threadPool, shardStateAction, new ActionFilters(Collections.emptySet()), new IndexingPressureService(Settings.EMPTY, clusterService), new SystemIndices(emptyMap()));
    final RetentionLeases retentionLeases = mock(RetentionLeases.class);
    final RetentionLeaseSyncAction.Request request = new RetentionLeaseSyncAction.Request(indexShard.shardId(), retentionLeases);
    action.dispatchedShardOperationOnPrimary(request, indexShard, ActionTestUtils.assertNoFailureListener(result -> {
        // the retention leases on the shard should be persisted
        verify(indexShard).persistRetentionLeases();
        // we should forward the request containing the current retention leases to the replica
        assertThat(result.replicaRequest(), sameInstance(request));
        // we should start with an empty replication response
        assertNull(result.finalResponseIfSuccessful.getShardInfo());
    }));
}
Also used : ThreadPool(org.opensearch.threadpool.ThreadPool) TestThreadPool(org.opensearch.threadpool.TestThreadPool) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IndexShard(org.opensearch.index.shard.IndexShard) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) ActionListener(org.opensearch.action.ActionListener) ShardStateAction(org.opensearch.cluster.action.shard.ShardStateAction) Collections.emptyMap(java.util.Collections.emptyMap) ClusterServiceUtils.createClusterService(org.opensearch.test.ClusterServiceUtils.createClusterService) Index(org.opensearch.index.Index) IndexingPressureService(org.opensearch.index.IndexingPressureService) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) IndicesService(org.opensearch.indices.IndicesService) Settings(org.opensearch.common.settings.Settings) Mockito.when(org.mockito.Mockito.when) TransportReplicationAction(org.opensearch.action.support.replication.TransportReplicationAction) IndexService(org.opensearch.index.IndexService) TransportService(org.opensearch.transport.TransportService) Mockito.verify(org.mockito.Mockito.verify) IOUtils(org.opensearch.core.internal.io.IOUtils) ShardId(org.opensearch.index.shard.ShardId) ActionFilters(org.opensearch.action.support.ActionFilters) SystemIndices(org.opensearch.indices.SystemIndices) ActionTestUtils(org.opensearch.action.support.ActionTestUtils) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) ClusterService(org.opensearch.cluster.service.ClusterService) CapturingTransport(org.opensearch.test.transport.CapturingTransport) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) IndexingPressureService(org.opensearch.index.IndexingPressureService) IndexService(org.opensearch.index.IndexService) IndexShard(org.opensearch.index.shard.IndexShard) IndicesService(org.opensearch.indices.IndicesService) Index(org.opensearch.index.Index) ActionFilters(org.opensearch.action.support.ActionFilters) ShardId(org.opensearch.index.shard.ShardId) SystemIndices(org.opensearch.indices.SystemIndices)

Aggregations

IndexingPressureService (org.opensearch.index.IndexingPressureService)11 ShardId (org.opensearch.index.shard.ShardId)10 PlainActionFuture (org.opensearch.action.support.PlainActionFuture)9 Settings (org.opensearch.common.settings.Settings)8 ClusterState (org.opensearch.cluster.ClusterState)7 ShardRouting (org.opensearch.cluster.routing.ShardRouting)7 ClusterSettings (org.opensearch.common.settings.ClusterSettings)7 ShardIndexingPressureSettings (org.opensearch.index.ShardIndexingPressureSettings)6 IndexingPressurePerShardStats (org.opensearch.index.stats.IndexingPressurePerShardStats)6 ActionFilters (org.opensearch.action.support.ActionFilters)5 SystemIndices (org.opensearch.indices.SystemIndices)5 ActionListener (org.opensearch.action.ActionListener)4 ClusterService (org.opensearch.cluster.service.ClusterService)4 Index (org.opensearch.index.Index)4 IndexService (org.opensearch.index.IndexService)4 IndexShard (org.opensearch.index.shard.IndexShard)4 IndicesService (org.opensearch.indices.IndicesService)4 Collections.emptyMap (java.util.Collections.emptyMap)3 CommonStatsFlags (org.opensearch.action.admin.indices.stats.CommonStatsFlags)3 ShardStateAction (org.opensearch.cluster.action.shard.ShardStateAction)3