Search in sources :

Example 16 with IndexingPressurePerShardStats

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

the class ShardIndexingPressureTests method testReplicaShardLimitIncreaseEvaluateSecondaryParam.

public void testReplicaShardLimitIncreaseEvaluateSecondaryParam() {
    ShardIndexingPressure shardIndexingPressure = new ShardIndexingPressure(settings, clusterService);
    Index index = new Index("IndexName", "UUID");
    ShardId shardId = new ShardId(index, 0);
    try (Releasable replica = shardIndexingPressure.markReplicaOperationStarted(shardId, 11 * 1024, false)) {
        assertEquals(11 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentReplicaBytes());
        assertEquals((long) (11 * 1024 / 0.85), shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentReplicaLimits());
    }
    IndexingPressurePerShardStats shardStoreStats = shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId);
    assertNull(shardStoreStats);
    IndexingPressurePerShardStats shardStats = shardIndexingPressure.coldStats().getIndexingPressureShardStats(shardId);
    assertEquals(0, shardStats.getCurrentReplicaBytes());
    assertEquals(11 * 1024, shardStats.getTotalReplicaBytes());
    assertEquals(15, shardStats.getCurrentReplicaLimits());
}
Also used : ShardId(org.opensearch.index.shard.ShardId) Releasable(org.opensearch.common.lease.Releasable) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Example 17 with IndexingPressurePerShardStats

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

the class IndexingPressureServiceTests method testPrimaryOperationForShardIndexingPressure.

public void testPrimaryOperationForShardIndexingPressure() {
    IndexingPressureService service = new IndexingPressureService(settings, clusterService);
    Index index = new Index("IndexName", "UUID");
    ShardId shardId = new ShardId(index, 0);
    Releasable releasable = service.markPrimaryOperationStarted(shardId, 1024, false);
    IndexingPressurePerShardStats shardStats = service.shardStats(CommonStatsFlags.ALL).getIndexingPressureShardStats(shardId);
    assertEquals(1024, shardStats.getCurrentPrimaryBytes());
    releasable.close();
}
Also used : ShardId(org.opensearch.index.shard.ShardId) Releasable(org.opensearch.common.lease.Releasable) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Example 18 with IndexingPressurePerShardStats

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

the class IndexingPressureServiceTests method testReplicaOperationForShardIndexingPressure.

public void testReplicaOperationForShardIndexingPressure() {
    IndexingPressureService service = new IndexingPressureService(settings, clusterService);
    Index index = new Index("IndexName", "UUID");
    ShardId shardId = new ShardId(index, 0);
    Releasable releasable = service.markReplicaOperationStarted(shardId, 1024, false);
    IndexingPressurePerShardStats shardStats = service.shardStats(CommonStatsFlags.ALL).getIndexingPressureShardStats(shardId);
    assertEquals(1024, shardStats.getCurrentReplicaBytes());
    releasable.close();
}
Also used : ShardId(org.opensearch.index.shard.ShardId) Releasable(org.opensearch.common.lease.Releasable) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Example 19 with IndexingPressurePerShardStats

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

the class IndexingPressureServiceTests method testCoordinatingOperationForShardIndexingPressure.

public void testCoordinatingOperationForShardIndexingPressure() {
    IndexingPressureService service = new IndexingPressureService(settings, clusterService);
    Index index = new Index("IndexName", "UUID");
    ShardId shardId = new ShardId(index, 0);
    BulkItemRequest[] items = new BulkItemRequest[1];
    DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "foo", "bar");
    items[0] = new BulkItemRequest(0, writeRequest);
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, WriteRequest.RefreshPolicy.NONE, items);
    Releasable releasable = service.markCoordinatingOperationStarted(shardId, bulkShardRequest::ramBytesUsed, false);
    IndexingPressurePerShardStats shardStats = service.shardStats(CommonStatsFlags.ALL).getIndexingPressureShardStats(shardId);
    assertEquals(bulkShardRequest.ramBytesUsed(), shardStats.getCurrentCoordinatingBytes());
    releasable.close();
}
Also used : ShardId(org.opensearch.index.shard.ShardId) BulkShardRequest(org.opensearch.action.bulk.BulkShardRequest) BulkItemRequest(org.opensearch.action.bulk.BulkItemRequest) Releasable(org.opensearch.common.lease.Releasable) IndexRequest(org.opensearch.action.index.IndexRequest) IndexingPressurePerShardStats(org.opensearch.index.stats.IndexingPressurePerShardStats)

Example 20 with IndexingPressurePerShardStats

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

the class IndexingPressureServiceTests method testLocalPrimaryOperationForIndexingPressure.

public void testLocalPrimaryOperationForIndexingPressure() {
    IndexingPressureService service = new IndexingPressureService(settings, clusterService);
    Index index = new Index("IndexName", "UUID");
    ShardId shardId = new ShardId(index, 0);
    Settings.Builder updated = Settings.builder();
    clusterSettings.updateDynamicSettings(Settings.builder().put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), false).build(), Settings.builder().put(settings), updated, getTestClass().getName());
    clusterSettings.applySettings(updated.build());
    Releasable releasable = service.markPrimaryOperationLocalToCoordinatingNodeStarted(shardId, 1024);
    IndexingPressurePerShardStats shardStats = service.shardStats(CommonStatsFlags.ALL).getIndexingPressureShardStats(shardId);
    assertNull(shardStats);
    IndexingPressureStats nodeStats = service.nodeStats();
    assertEquals(1024, nodeStats.getCurrentPrimaryBytes());
    releasable.close();
}
Also used : ShardId(org.opensearch.index.shard.ShardId) Releasable(org.opensearch.common.lease.Releasable) IndexingPressureStats(org.opensearch.index.stats.IndexingPressureStats) 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