Skip to content

Commit c1b986f

Browse files
Making PressureService as Singleton class. (#7274) (#7277)
(cherry picked from commit 115bb30) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c00e0f7 commit c1b986f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

server/src/internalClusterTest/java/org/opensearch/index/SegmentReplicationPressureIT.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package org.opensearch.index;
77

8+
import org.opensearch.action.admin.indices.replication.SegmentReplicationStatsResponse;
89
import org.opensearch.action.bulk.BulkItemResponse;
910
import org.opensearch.action.bulk.BulkRequest;
1011
import org.opensearch.action.bulk.BulkResponse;
@@ -101,6 +102,23 @@ public void testWritesRejected() throws Exception {
101102
totalDocs.incrementAndGet();
102103
});
103104
});
105+
// Try to index one more doc.
106+
expectThrows(OpenSearchRejectedExecutionException.class, () -> {
107+
indexDoc();
108+
totalDocs.incrementAndGet();
109+
refresh(INDEX_NAME);
110+
});
111+
112+
// Verify the rejected doc count.
113+
SegmentReplicationStatsResponse segmentReplicationStatsResponse = dataNodeClient().admin()
114+
.indices()
115+
.prepareSegmentReplicationStats(INDEX_NAME)
116+
.setDetailed(true)
117+
.execute()
118+
.actionGet();
119+
SegmentReplicationPerGroupStats perGroupStats = segmentReplicationStatsResponse.getReplicationStats().get(INDEX_NAME).get(0);
120+
121+
assertEquals(perGroupStats.getRejectedRequestCount(), 2L);
104122
}
105123
refresh(INDEX_NAME);
106124
// wait for the replicas to catch up after block is released.

server/src/main/java/org/opensearch/indices/IndicesModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.opensearch.common.io.stream.NamedWriteableRegistry;
4343
import org.opensearch.common.io.stream.NamedWriteableRegistry.Entry;
4444
import org.opensearch.core.xcontent.NamedXContentRegistry;
45+
import org.opensearch.index.SegmentReplicationPressureService;
4546
import org.opensearch.index.mapper.BinaryFieldMapper;
4647
import org.opensearch.index.mapper.BooleanFieldMapper;
4748
import org.opensearch.index.mapper.CompletionFieldMapper;
@@ -284,6 +285,7 @@ protected void configure() {
284285
bind(RetentionLeaseBackgroundSyncAction.class).asEagerSingleton();
285286
bind(RetentionLeaseSyncer.class).asEagerSingleton();
286287
bind(SegmentReplicationCheckpointPublisher.class).asEagerSingleton();
288+
bind(SegmentReplicationPressureService.class).asEagerSingleton();
287289
}
288290

289291
/**

0 commit comments

Comments
 (0)