use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.
the class ShardIndexingPressureTests method testCoordinatingPrimaryShardRejectionSkippedInShadowModeViaSuccessfulRequestsParam.
public void testCoordinatingPrimaryShardRejectionSkippedInShadowModeViaSuccessfulRequestsParam() throws InterruptedException {
Settings settings = Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), "10KB").put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), true).put(ShardIndexingPressureMemoryManager.MAX_OUTSTANDING_REQUESTS.getKey(), 1).put(ShardIndexingPressureMemoryManager.SUCCESSFUL_REQUEST_ELAPSED_TIMEOUT.getKey(), "20ms").put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENFORCED.getKey(), false).build();
ShardIndexingPressure shardIndexingPressure = new ShardIndexingPressure(settings, clusterService);
Index index = new Index("IndexName", "UUID");
ShardId shardId = new ShardId(index, 0);
boolean randomBoolean = randomBoolean();
try (Releasable coordinating = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 1 * 1024, false);
Releasable primary = shardIndexingPressure.markPrimaryOperationStarted(shardId, 1 * 1024, false)) {
assertEquals(1 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCoordinatingBytes());
assertEquals(1 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryBytes());
assertEquals(2 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals((long) (2 * 1024 / 0.85), shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryAndCoordinatingLimits());
}
IndexingPressurePerShardStats shardStats = shardIndexingPressure.coldStats().getIndexingPressureShardStats(shardId);
assertEquals(0, shardStats.getCurrentCoordinatingBytes());
assertEquals(0, shardStats.getCurrentPrimaryBytes());
assertEquals(0, shardStats.getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals(1 * 1024, shardStats.getTotalCoordinatingBytes());
assertEquals(1 * 1024, shardStats.getTotalPrimaryBytes());
assertEquals(2 * 1024, shardStats.getTotalCombinedCoordinatingAndPrimaryBytes());
assertEquals(10, shardStats.getCurrentPrimaryAndCoordinatingLimits());
Thread.sleep(25);
// Total Bytes are 9*1024 and node limit is 10*1024
if (randomBoolean) {
try (Releasable coordinating = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 7 * 1024, false);
Releasable coordinating1 = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 1 * 1024, false)) {
Releasable coordinating2 = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 1 * 1024, false);
coordinating2.close();
}
} else {
try (Releasable primary = shardIndexingPressure.markPrimaryOperationStarted(shardId, 7 * 1024, false);
Releasable primary1 = shardIndexingPressure.markPrimaryOperationStarted(shardId, 1 * 1024, false)) {
Releasable primary2 = shardIndexingPressure.markPrimaryOperationStarted(shardId, 1 * 1024, false);
primary2.close();
}
}
shardStats = shardIndexingPressure.coldStats().getIndexingPressureShardStats(shardId);
if (randomBoolean) {
assertEquals(0, shardStats.getCoordinatingRejections());
assertEquals(0, shardStats.getCurrentCoordinatingBytes());
assertEquals(1, shardStats.getCoordinatingLastSuccessfulRequestLimitsBreachedRejections());
} else {
assertEquals(0, shardStats.getPrimaryRejections());
assertEquals(0, shardStats.getCurrentPrimaryBytes());
assertEquals(1, shardStats.getPrimaryLastSuccessfulRequestLimitsBreachedRejections());
}
IndexingPressureStats nodeStats = shardIndexingPressure.stats();
if (randomBoolean) {
assertEquals(0, nodeStats.getCoordinatingRejections());
assertEquals(0, nodeStats.getCurrentCoordinatingBytes());
} else {
assertEquals(0, nodeStats.getPrimaryRejections());
assertEquals(0, nodeStats.getCurrentPrimaryBytes());
}
}
use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.
the class ShardIndexingPressureTests method testCoordinatingPrimaryShardRejectionSkippedInShadowModeViaThroughputDegradationParam.
public void testCoordinatingPrimaryShardRejectionSkippedInShadowModeViaThroughputDegradationParam() throws InterruptedException {
Settings settings = Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), "10KB").put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), true).put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENFORCED.getKey(), false).put(ShardIndexingPressureMemoryManager.THROUGHPUT_DEGRADATION_LIMITS.getKey(), 1).put(ShardIndexingPressureSettings.REQUEST_SIZE_WINDOW.getKey(), 1).build();
ShardIndexingPressure shardIndexingPressure = new ShardIndexingPressure(settings, clusterService);
Index index = new Index("IndexName", "UUID");
ShardId shardId = new ShardId(index, 0);
boolean randomBoolean = randomBoolean();
try (Releasable coordinating = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 1 * 1024, false);
Releasable coordinating1 = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 3 * 1024, false);
Releasable primary = shardIndexingPressure.markPrimaryOperationStarted(shardId, 1 * 1024, false);
Releasable primary1 = shardIndexingPressure.markPrimaryOperationStarted(shardId, 3 * 1024, false)) {
assertEquals(4 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCoordinatingBytes());
assertEquals(4 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryBytes());
assertEquals(8 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals((long) (8 * 1024 / 0.85), shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryAndCoordinatingLimits());
// Adding delay in the current in flight request to mimic throughput degradation
Thread.sleep(100);
}
if (randomBoolean) {
Releasable coordinating = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 8 * 1024, false);
coordinating.close();
} else {
Releasable primary = shardIndexingPressure.markPrimaryOperationStarted(shardId, 8 * 1024, false);
primary.close();
}
IndexingPressurePerShardStats shardStats = shardIndexingPressure.coldStats().getIndexingPressureShardStats(shardId);
if (randomBoolean) {
assertEquals(0, shardStats.getCoordinatingRejections());
assertEquals(1, shardStats.getCoordinatingThroughputDegradationLimitsBreachedRejections());
assertEquals(0, shardStats.getCurrentCoordinatingBytes());
assertEquals(12 * 1024, shardStats.getTotalCoordinatingBytes());
} else {
assertEquals(0, shardStats.getPrimaryRejections());
assertEquals(1, shardStats.getPrimaryThroughputDegradationLimitsBreachedRejections());
assertEquals(0, shardStats.getCurrentPrimaryBytes());
assertEquals(12 * 1024, shardStats.getTotalPrimaryBytes());
}
assertEquals(10, shardStats.getCurrentPrimaryAndCoordinatingLimits());
assertEquals(0, shardStats.getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals(16 * 1024, shardStats.getTotalCombinedCoordinatingAndPrimaryBytes());
IndexingPressureStats nodeStats = shardIndexingPressure.stats();
if (randomBoolean) {
assertEquals(0, nodeStats.getCoordinatingRejections());
assertEquals(0, nodeStats.getCurrentCoordinatingBytes());
} else {
assertEquals(0, nodeStats.getPrimaryRejections());
assertEquals(0, nodeStats.getCurrentPrimaryBytes());
}
}
use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.
the class ShardIndexingPressureTests method testCoordinatingPrimaryShardLimitIncreaseEvaluateSecondaryParam.
public void testCoordinatingPrimaryShardLimitIncreaseEvaluateSecondaryParam() {
ShardIndexingPressure shardIndexingPressure = new ShardIndexingPressure(settings, clusterService);
Index index = new Index("IndexName", "UUID");
ShardId shardId = new ShardId(index, 0);
try (Releasable coordinating = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 4 * 1024, false);
Releasable primary = shardIndexingPressure.markPrimaryOperationStarted(shardId, 4 * 1024, false)) {
assertEquals(4 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCoordinatingBytes());
assertEquals(4 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryBytes());
assertEquals(8 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals((long) (8 * 1024 / 0.85), shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryAndCoordinatingLimits());
}
IndexingPressurePerShardStats shardStoreStats = shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId);
assertNull(shardStoreStats);
IndexingPressurePerShardStats shardStats = shardIndexingPressure.coldStats().getIndexingPressureShardStats(shardId);
assertEquals(0, shardStats.getCurrentCoordinatingBytes());
assertEquals(0, shardStats.getCurrentPrimaryBytes());
assertEquals(0, shardStats.getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals(4 * 1024, shardStats.getTotalCoordinatingBytes());
assertEquals(4 * 1024, shardStats.getTotalPrimaryBytes());
assertEquals(8 * 1024, shardStats.getTotalCombinedCoordinatingAndPrimaryBytes());
assertEquals(10, shardStats.getCurrentPrimaryAndCoordinatingLimits());
}
use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.
the class ShardIndexingPressureTests method testCoordinatingPrimaryShardLimitIncrease.
public void testCoordinatingPrimaryShardLimitIncrease() {
ShardIndexingPressure shardIndexingPressure = new ShardIndexingPressure(settings, clusterService);
Index index = new Index("IndexName", "UUID");
ShardId shardId = new ShardId(index, 0);
boolean randomBoolean = randomBoolean();
try (Releasable coordinating = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 2, false);
Releasable primary = shardIndexingPressure.markPrimaryOperationStarted(shardId, 2, false)) {
assertEquals(2, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCoordinatingBytes());
assertEquals(4, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals(10, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryAndCoordinatingLimits());
// Base Limit
if (randomBoolean) {
Releasable coordinating1 = shardIndexingPressure.markCoordinatingOperationStarted(shardId, 6, false);
assertEquals(8, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCoordinatingBytes());
assertEquals(10, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals(11, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryAndCoordinatingLimits());
// Increased Limit
coordinating1.close();
} else {
Releasable primary1 = shardIndexingPressure.markPrimaryOperationStarted(shardId, 6, false);
assertEquals(8, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryBytes());
assertEquals(10, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals(11, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentPrimaryAndCoordinatingLimits());
// Increased Limit
primary1.close();
}
}
IndexingPressurePerShardStats shardStoreStats = shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId);
assertNull(shardStoreStats);
IndexingPressurePerShardStats shardStats = shardIndexingPressure.coldStats().getIndexingPressureShardStats(shardId);
if (randomBoolean) {
assertEquals(0, shardStats.getCurrentCoordinatingBytes());
assertEquals(8, shardStats.getTotalCoordinatingBytes());
} else {
assertEquals(0, shardStats.getCurrentPrimaryBytes());
assertEquals(8, shardStats.getTotalPrimaryBytes());
}
assertEquals(0, shardStats.getCurrentCombinedCoordinatingAndPrimaryBytes());
assertEquals(10, shardStats.getTotalCombinedCoordinatingAndPrimaryBytes());
assertEquals(10, shardStats.getCurrentPrimaryAndCoordinatingLimits());
}
use of org.opensearch.index.stats.IndexingPressurePerShardStats in project OpenSearch by opensearch-project.
the class ShardIndexingPressureTests method testReplicaShardRejectionSkippedInShadowModeViaSuccessfulRequestsParam.
public void testReplicaShardRejectionSkippedInShadowModeViaSuccessfulRequestsParam() throws InterruptedException {
Settings settings = Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), "10KB").put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED.getKey(), true).put(ShardIndexingPressureMemoryManager.MAX_OUTSTANDING_REQUESTS.getKey(), 1).put(ShardIndexingPressureMemoryManager.SUCCESSFUL_REQUEST_ELAPSED_TIMEOUT.getKey(), "20ms").put(ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENFORCED.getKey(), false).build();
ShardIndexingPressure shardIndexingPressure = new ShardIndexingPressure(settings, clusterService);
Index index = new Index("IndexName", "UUID");
ShardId shardId = new ShardId(index, 0);
try (Releasable replica = shardIndexingPressure.markReplicaOperationStarted(shardId, 1 * 1024, false)) {
assertEquals(1 * 1024, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentReplicaBytes());
assertEquals((long) (1 * 1024 / 0.85), shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId).getCurrentReplicaLimits());
}
IndexingPressurePerShardStats shardStats = shardIndexingPressure.coldStats().getIndexingPressureShardStats(shardId);
assertEquals(0, shardStats.getCurrentReplicaBytes());
assertEquals(1 * 1024, shardStats.getTotalReplicaBytes());
assertEquals(15, shardStats.getCurrentReplicaLimits());
Thread.sleep(25);
// Total Bytes are 14*1024 and node limit is 15*1024
try (Releasable replica = shardIndexingPressure.markReplicaOperationStarted(shardId, 10 * 1024, false);
Releasable replica1 = shardIndexingPressure.markReplicaOperationStarted(shardId, 2 * 1024, false)) {
Releasable replica2 = shardIndexingPressure.markReplicaOperationStarted(shardId, 2 * 1024, false);
replica2.close();
}
shardStats = shardIndexingPressure.coldStats().getIndexingPressureShardStats(shardId);
assertEquals(0, shardStats.getReplicaRejections());
assertEquals(0, shardStats.getCurrentReplicaBytes());
assertEquals(1, shardStats.getReplicaLastSuccessfulRequestLimitsBreachedRejections());
IndexingPressureStats nodeStats = shardIndexingPressure.stats();
assertEquals(0, nodeStats.getReplicaRejections());
assertEquals(0, nodeStats.getCurrentReplicaBytes());
}
Aggregations