Search in sources :

Example 21 with IndexingPressurePerShardStats

use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.

the class TransportWriteActionForIndexingPressureTests method testIndexingPressureOperationStartedForReplicaNode.

public void testIndexingPressureOperationStartedForReplicaNode() {
    final ShardId shardId = new ShardId("test", "_na_", 0);
    final ClusterState state = state(shardId.getIndexName(), true, ShardRoutingState.STARTED, ShardRoutingState.STARTED);
    setState(clusterService, state);
    final ShardRouting replicaRouting = state.getRoutingTable().shardRoutingTable(shardId).replicaShards().get(0);
    final ReplicationTask task = maybeTask();
    final Settings settings = Settings.builder().put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), false).build();
    this.indexingPressureService = new IndexingPressureService(settings, clusterService);
    TestAction action = new TestAction(settings, "internal:testAction", transportService, clusterService, shardStateAction, threadPool);
    action.handleReplicaRequest(new TransportReplicationAction.ConcreteReplicaRequest<>(new TestRequest(), replicaRouting.allocationId().getId(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong()), createTransportChannel(new PlainActionFuture<>()), task);
    IndexingPressurePerShardStats shardStats = this.indexingPressureService.shardStats(CommonStatsFlags.ALL).getIndexingPressureShardStats(shardId);
    assertPhase(task, "finished");
    assertTrue(Objects.isNull(shardStats));
}
Also used : ShardId(org.opensearch.index.shard.ShardId) ClusterState(org.opensearch.cluster.ClusterState) IndexingPressureService(org.opensearch.index.IndexingPressureService) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardIndexingPressureSettings(org.opensearch.index.ShardIndexingPressureSettings) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Example 22 with IndexingPressurePerShardStats

use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.

the class TransportWriteActionForIndexingPressureTests method testIndexingPressureOperationStartedForPrimaryShard.

public void testIndexingPressureOperationStartedForPrimaryShard() {
    final ShardId shardId = new ShardId("test", "_na_", 0);
    final ClusterState state = state(shardId.getIndexName(), true, ShardRoutingState.STARTED, ShardRoutingState.STARTED);
    setState(clusterService, state);
    final ShardRouting replicaRouting = state.getRoutingTable().shardRoutingTable(shardId).replicaShards().get(0);
    final ReplicationTask task = maybeTask();
    final Settings settings = Settings.builder().put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), true).build();
    this.indexingPressureService = new IndexingPressureService(settings, clusterService);
    TestAction action = new TestAction(settings, "internal:testActionWithExceptions", transportService, clusterService, shardStateAction, threadPool);
    action.handlePrimaryRequest(new TransportReplicationAction.ConcreteReplicaRequest<>(new TestRequest(), replicaRouting.allocationId().getId(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong()), createTransportChannel(new PlainActionFuture<>()), task);
    CommonStatsFlags statsFlag = new CommonStatsFlags();
    statsFlag.includeAllShardIndexingPressureTrackers(true);
    IndexingPressurePerShardStats shardStats = this.indexingPressureService.shardStats(statsFlag).getIndexingPressureShardStats(shardId);
    assertPhase(task, "finished");
    assertTrue(!Objects.isNull(shardStats));
    assertEquals(100, shardStats.getTotalPrimaryBytes());
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) IndexingPressureService(org.opensearch.index.IndexingPressureService) CommonStatsFlags(org.opensearch.action.admin.indices.stats.CommonStatsFlags) ShardId(org.opensearch.index.shard.ShardId) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardIndexingPressureSettings(org.opensearch.index.ShardIndexingPressureSettings) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Example 23 with IndexingPressurePerShardStats

use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.

the class TransportWriteActionForIndexingPressureTests method testIndexingPressureOperationStartedForLocalPrimaryNode.

public void testIndexingPressureOperationStartedForLocalPrimaryNode() {
    final ShardId shardId = new ShardId("test", "_na_", 0);
    final ClusterState state = state(shardId.getIndexName(), true, ShardRoutingState.STARTED, ShardRoutingState.STARTED);
    setState(clusterService, state);
    final ShardRouting replicaRouting = state.getRoutingTable().shardRoutingTable(shardId).replicaShards().get(0);
    final ReplicationTask task = maybeTask();
    final Settings settings = Settings.builder().put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), false).build();
    this.indexingPressureService = new IndexingPressureService(settings, clusterService);
    TestAction action = new TestAction(settings, "internal:testAction", transportService, clusterService, shardStateAction, threadPool);
    action.handlePrimaryRequest(new TransportReplicationAction.ConcreteShardRequest<>(new TestRequest(), replicaRouting.allocationId().getId(), randomNonNegativeLong(), true, true), createTransportChannel(new PlainActionFuture<>()), task);
    IndexingPressurePerShardStats shardStats = this.indexingPressureService.shardStats(CommonStatsFlags.ALL).getIndexingPressureShardStats(shardId);
    assertPhase(task, "finished");
    assertTrue(Objects.isNull(shardStats));
}
Also used : ShardId(org.opensearch.index.shard.ShardId) ClusterState(org.opensearch.cluster.ClusterState) IndexingPressureService(org.opensearch.index.IndexingPressureService) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardIndexingPressureSettings(org.opensearch.index.ShardIndexingPressureSettings) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Example 24 with IndexingPressurePerShardStats

use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.

the class TransportWriteActionForIndexingPressureTests method testIndexingPressureOperationStartedForPrimaryNode.

public void testIndexingPressureOperationStartedForPrimaryNode() {
    final ShardId shardId = new ShardId("test", "_na_", 0);
    final ClusterState state = state(shardId.getIndexName(), true, ShardRoutingState.STARTED, ShardRoutingState.STARTED);
    setState(clusterService, state);
    final ShardRouting replicaRouting = state.getRoutingTable().shardRoutingTable(shardId).replicaShards().get(0);
    final ReplicationTask task = maybeTask();
    final Settings settings = Settings.builder().put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), false).build();
    this.indexingPressureService = new IndexingPressureService(settings, clusterService);
    TestAction action = new TestAction(settings, "internal:testActionWithExceptions", transportService, clusterService, shardStateAction, threadPool);
    action.handlePrimaryRequest(new TransportReplicationAction.ConcreteReplicaRequest<>(new TestRequest(), replicaRouting.allocationId().getId(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong()), createTransportChannel(new PlainActionFuture<>()), task);
    IndexingPressurePerShardStats shardStats = this.indexingPressureService.shardStats(CommonStatsFlags.ALL).getIndexingPressureShardStats(shardId);
    assertPhase(task, "finished");
    assertTrue(Objects.isNull(shardStats));
}
Also used : ShardId(org.opensearch.index.shard.ShardId) ClusterState(org.opensearch.cluster.ClusterState) IndexingPressureService(org.opensearch.index.IndexingPressureService) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardIndexingPressureSettings(org.opensearch.index.ShardIndexingPressureSettings) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Example 25 with IndexingPressurePerShardStats

use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.

the class TransportWriteActionForIndexingPressureTests method testIndexingPressureOperationStartedForLocalPrimaryShard.

public void testIndexingPressureOperationStartedForLocalPrimaryShard() {
    final ShardId shardId = new ShardId("test", "_na_", 0);
    final ClusterState state = state(shardId.getIndexName(), true, ShardRoutingState.STARTED, ShardRoutingState.STARTED);
    setState(clusterService, state);
    final ShardRouting replicaRouting = state.getRoutingTable().shardRoutingTable(shardId).replicaShards().get(0);
    final ReplicationTask task = maybeTask();
    final Settings settings = Settings.builder().put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), true).build();
    this.indexingPressureService = new IndexingPressureService(settings, clusterService);
    TestAction action = new TestAction(settings, "internal:testAction", transportService, clusterService, shardStateAction, threadPool);
    action.handlePrimaryRequest(new TransportReplicationAction.ConcreteShardRequest<>(new TestRequest(), replicaRouting.allocationId().getId(), randomNonNegativeLong(), true, true), createTransportChannel(new PlainActionFuture<>()), task);
    CommonStatsFlags statsFlag = new CommonStatsFlags();
    statsFlag.includeAllShardIndexingPressureTrackers(true);
    IndexingPressurePerShardStats shardStats = this.indexingPressureService.shardStats(statsFlag).getIndexingPressureShardStats(shardId);
    assertPhase(task, "finished");
    assertTrue(!Objects.isNull(shardStats));
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) IndexingPressureService(org.opensearch.index.IndexingPressureService) CommonStatsFlags(org.opensearch.action.admin.indices.stats.CommonStatsFlags) ShardId(org.opensearch.index.shard.ShardId) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardIndexingPressureSettings(org.opensearch.index.ShardIndexingPressureSettings) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Aggregations

ShardId (org.opensearch.index.shard.ShardId)43 IndexingPressurePerShardStats (org.opensearch.index.stats.IndexingPressurePerShardStats)43 Releasable (org.opensearch.common.lease.Releasable)31 ClusterSettings (org.opensearch.common.settings.ClusterSettings)18 Settings (org.opensearch.common.settings.Settings)18 IndexingPressureStats (org.opensearch.index.stats.IndexingPressureStats)18 PlainActionFuture (org.opensearch.action.support.PlainActionFuture)6 ClusterState (org.opensearch.cluster.ClusterState)6 ShardRouting (org.opensearch.cluster.routing.ShardRouting)6 IndexingPressureService (org.opensearch.index.IndexingPressureService)6 ShardIndexingPressureSettings (org.opensearch.index.ShardIndexingPressureSettings)6 CommonStatsFlags (org.opensearch.action.admin.indices.stats.CommonStatsFlags)5 ShardIndexingPressureStats (org.opensearch.index.stats.ShardIndexingPressureStats)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 OpenSearchRejectedExecutionException (org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException)2 BulkItemRequest (org.opensearch.action.bulk.BulkItemRequest)1 BulkRequest (org.opensearch.action.bulk.BulkRequest)1 BulkShardRequest (org.opensearch.action.bulk.BulkShardRequest)1