diff --git a/CHANGELOG.md b/CHANGELOG.md index cac3b74fe716c..221692d9d9354 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Views, simplify data access and manipulation by providing a virtual layer over one or more indices ([#11957](https://github.com/opensearch-project/OpenSearch/pull/11957)) - Add Remote Store Migration Experimental flag and allow mixed mode clusters under same ([#11986](https://github.com/opensearch-project/OpenSearch/pull/11986)) - [Admission Control] Integrate IO Usage Tracker to the Resource Usage Collector Service and Emit IO Usage Stats ([#11880](https://github.com/opensearch-project/OpenSearch/pull/11880)) +- [Admission Control] Integrated IO Based AdmissionController to AdmissionControl Framework ([#12583](https://github.com/opensearch-project/OpenSearch/pull/12583)) ### Dependencies - Bump `log4j-core` from 2.18.0 to 2.19.0 diff --git a/server/src/internalClusterTest/java/org/opensearch/ratelimitting/admissioncontrol/AdmissionControlMultiNodeIT.java b/server/src/internalClusterTest/java/org/opensearch/ratelimitting/admissioncontrol/AdmissionControlMultiNodeIT.java index ff36e24b46e5e..317337ecf72c7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/ratelimitting/admissioncontrol/AdmissionControlMultiNodeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/ratelimitting/admissioncontrol/AdmissionControlMultiNodeIT.java @@ -45,7 +45,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.Map; -import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Stream; @@ -100,13 +99,14 @@ protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(settings).build(); } - public void testAdmissionControlRejectionOnEnforced() { + public void testAdmissionControlRejectionOnEnforced() throws Exception { Tuple primaryReplicaNodeNames = getPrimaryReplicaNodeNames(INDEX_NAME); String primaryName = primaryReplicaNodeNames.v1(); String replicaName = primaryReplicaNodeNames.v2(); String coordinatingOnlyNode = getCoordinatingOnlyNode(); AdmissionControlService admissionControlServicePrimary = internalCluster().getInstance(AdmissionControlService.class, primaryName); AdmissionControlService admissionControlServiceReplica = internalCluster().getInstance(AdmissionControlService.class, replicaName); + Thread.sleep(6000); final BulkRequest bulkRequest = new BulkRequest(); for (int i = 0; i < 3; ++i) { IndexRequest request = new IndexRequest(INDEX_NAME).id(UUIDs.base64UUID()) @@ -196,10 +196,10 @@ public void testAdmissionControlRejectionOnEnforced() { } } - public void testAdmissionControlEnforcedOnNonACEnabledActions() throws ExecutionException, InterruptedException { + public void testAdmissionControlEnforcedOnNonACEnabledActions() throws Exception { String coordinatingOnlyNode = getCoordinatingOnlyNode(); ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); - + Thread.sleep(6000); updateSettingsRequest.transientSettings( Settings.builder() .put( @@ -248,7 +248,7 @@ public void testAdmissionControlEnforcedOnNonACEnabledActions() throws Execution assertFalse(nodesStatsResponse.hasFailures()); } - public void testAdmissionControlRejectionOnMonitor() { + public void testAdmissionControlRejectionOnMonitor() throws Exception { Tuple primaryReplicaNodeNames = getPrimaryReplicaNodeNames(INDEX_NAME); String primaryName = primaryReplicaNodeNames.v1(); String replicaName = primaryReplicaNodeNames.v2(); @@ -256,6 +256,7 @@ public void testAdmissionControlRejectionOnMonitor() { AdmissionControlService admissionControlServicePrimary = internalCluster().getInstance(AdmissionControlService.class, primaryName); AdmissionControlService admissionControlServiceReplica = internalCluster().getInstance(AdmissionControlService.class, replicaName); + Thread.sleep(6000); ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); @@ -337,7 +338,7 @@ public void testAdmissionControlRejectionOnMonitor() { } } - public void testAdmissionControlRejectionOnDisabled() { + public void testAdmissionControlRejectionOnDisabled() throws Exception { Tuple primaryReplicaNodeNames = getPrimaryReplicaNodeNames(INDEX_NAME); String primaryName = primaryReplicaNodeNames.v1(); String replicaName = primaryReplicaNodeNames.v2(); @@ -345,6 +346,7 @@ public void testAdmissionControlRejectionOnDisabled() { AdmissionControlService admissionControlServicePrimary = internalCluster().getInstance(AdmissionControlService.class, primaryName); AdmissionControlService admissionControlServiceReplica = internalCluster().getInstance(AdmissionControlService.class, replicaName); + Thread.sleep(6000); ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); diff --git a/server/src/main/java/org/opensearch/ratelimitting/admissioncontrol/controllers/IoBasedAdmissionController.java b/server/src/main/java/org/opensearch/ratelimitting/admissioncontrol/controllers/IoBasedAdmissionController.java index 87b31e127c2f5..67f626696838a 100644 --- a/server/src/main/java/org/opensearch/ratelimitting/admissioncontrol/controllers/IoBasedAdmissionController.java +++ b/server/src/main/java/org/opensearch/ratelimitting/admissioncontrol/controllers/IoBasedAdmissionController.java @@ -23,6 +23,10 @@ import java.util.Locale; import java.util.Optional; +/** + * Class for IO Based Admission Controller in OpenSearch, which aims to provide IO utilisation admission control. + * It provides methods to apply admission control if configured limit has been reached + */ public class IoBasedAdmissionController extends AdmissionController { public static final String IO_BASED_ADMISSION_CONTROLLER = "global_io_usage"; private static final Logger LOGGER = LogManager.getLogger(IoBasedAdmissionController.class); diff --git a/server/src/test/java/org/opensearch/ratelimitting/admissioncontrol/AdmissionControlSingleNodeTests.java b/server/src/test/java/org/opensearch/ratelimitting/admissioncontrol/AdmissionControlSingleNodeTests.java index 48817c8f17346..bd209b3d2b183 100644 --- a/server/src/test/java/org/opensearch/ratelimitting/admissioncontrol/AdmissionControlSingleNodeTests.java +++ b/server/src/test/java/org/opensearch/ratelimitting/admissioncontrol/AdmissionControlSingleNodeTests.java @@ -77,6 +77,7 @@ protected Settings nodeSettings() { public void testAdmissionControlRejectionEnforcedMode() throws Exception { ensureGreen(); assertBusy(() -> assertEquals(1, getInstanceFromNode(ResourceUsageCollectorService.class).getAllNodeStatistics().size())); + Thread.sleep(6000); client().admin().indices().prepareCreate("index").execute().actionGet(); BulkRequestBuilder bulk = client().prepareBulk(); for (int i = 0; i < 3; i++) { @@ -200,6 +201,7 @@ public void testAdmissionControlRejectionEnforcedMode() throws Exception { public void testAdmissionControlRejectionMonitorOnlyMode() throws Exception { assertBusy(() -> assertEquals(1, getInstanceFromNode(ResourceUsageCollectorService.class).getAllNodeStatistics().size())); + Thread.sleep(6000); // Verify that cluster state is updated ActionFuture future2 = client().admin().cluster().state(new ClusterStateRequest()); assertThat(future2.isDone(), is(true)); @@ -299,6 +301,7 @@ public void testAdmissionControlRejectionMonitorOnlyMode() throws Exception { public void testAdmissionControlRejectionDisabledMode() throws Exception { assertBusy(() -> assertEquals(1, getInstanceFromNode(ResourceUsageCollectorService.class).getAllNodeStatistics().size())); + Thread.sleep(6000); // Verify that cluster state is updated ActionFuture future2 = client().admin().cluster().state(new ClusterStateRequest()); assertThat(future2.isDone(), is(true)); @@ -367,6 +370,7 @@ public void testAdmissionControlRejectionDisabledMode() throws Exception { public void testAdmissionControlWithinLimits() throws Exception { assertBusy(() -> assertEquals(1, getInstanceFromNode(ResourceUsageCollectorService.class).getAllNodeStatistics().size())); + Thread.sleep(6000); // Verify that cluster state is updated ActionFuture future2 = client().admin().cluster().state(new ClusterStateRequest()); assertThat(future2.isDone(), is(true));