use of org.opensearch.common.lease.Releasable in project OpenSearch by opensearch-project.
the class IndexingPressureTests method testAvoidDoubleAccounting.
public void testAvoidDoubleAccounting() {
IndexingPressure indexingPressure = new IndexingPressure(settings);
try (Releasable coordinating = indexingPressure.markCoordinatingOperationStarted(10, false);
Releasable primary = indexingPressure.markPrimaryOperationLocalToCoordinatingNodeStarted(15)) {
IndexingPressureStats stats = indexingPressure.stats();
assertEquals(10, stats.getCurrentCoordinatingBytes());
assertEquals(15, stats.getCurrentPrimaryBytes());
assertEquals(10, stats.getCurrentCombinedCoordinatingAndPrimaryBytes());
}
IndexingPressureStats stats = indexingPressure.stats();
assertEquals(0, stats.getCurrentCoordinatingBytes());
assertEquals(0, stats.getCurrentPrimaryBytes());
assertEquals(0, stats.getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals(10, stats.getTotalCoordinatingBytes());
assertEquals(15, stats.getTotalPrimaryBytes());
assertEquals(10, stats.getTotalCombinedCoordinatingAndPrimaryBytes());
}
use of org.opensearch.common.lease.Releasable 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();
}
use of org.opensearch.common.lease.Releasable 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();
}
use of org.opensearch.common.lease.Releasable 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();
}
use of org.opensearch.common.lease.Releasable 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();
}
Aggregations