Skip to content

Commit

Permalink
Added support for search replica to return segrep stats (opensearch-p…
Browse files Browse the repository at this point in the history
…roject#16678)

* Added implementation for the stats calculation for search and regular replica in shards

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Updated changelog

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Added unit tests for TransportSegmentReplicationStatsAction

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* fixed java style after running precommit locally

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* refined the test cases

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* fixed style issues

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Made changes in the bytes to download calculation based on comments

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* added addReplicaStats method to SegmentReplicationPerGroupStats

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* fixed style issues

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Fixed issue with immutable set

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Fixed PR comments and moved the integration tests to separate module

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Fixed failing integ tests

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Fixed failing integ test

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* fixed some comments for PR

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* fixed failing tests

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

---------

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

remove license

Signed-off-by: Mingshi Liu <[email protected]>
  • Loading branch information
vinaykpud authored and mingshl committed Dec 15, 2024
1 parent eeb5a74 commit 2bea56e
Show file tree
Hide file tree
Showing 6 changed files with 744 additions and 225 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add stats for remote publication failure and move download failure stats to remote methods([#16682](https://github.com/opensearch-project/OpenSearch/pull/16682/))
- Introduce Template query ([#16818](https://github.com/opensearch-project/OpenSearch/pull/16818))
- Added a precaution to handle extreme date values during sorting to prevent `arithmetic_exception: long overflow` ([#16812](https://github.com/opensearch-project/OpenSearch/pull/16812)).
- Add search replica stats to segment replication stats API ([#16678](https://github.com/opensearch-project/OpenSearch/pull/16678))

### Dependencies
- Bump `com.google.cloud:google-cloud-core-http` from 2.23.0 to 2.47.0 ([#16504](https://github.com/opensearch-project/OpenSearch/pull/16504))
Expand Down
202 changes: 0 additions & 202 deletions plugins/repository-hdfs/licenses/commons-lang3-LICENSE.txt

This file was deleted.

5 changes: 0 additions & 5 deletions plugins/repository-hdfs/licenses/commons-lang3-NOTICE.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@

package org.opensearch.indices.replication;

import org.opensearch.action.admin.indices.replication.SegmentReplicationStatsResponse;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.index.SegmentReplicationPerGroupStats;
import org.opensearch.index.SegmentReplicationShardStats;
import org.opensearch.indices.replication.common.ReplicationType;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.junit.After;
import org.junit.Before;

import java.nio.file.Path;
import java.util.List;
import java.util.Set;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class SearchReplicaReplicationIT extends SegmentReplicationBaseIT {
Expand Down Expand Up @@ -82,4 +88,47 @@ public void testReplication() throws Exception {
waitForSearchableDocs(docCount, primary, replica);
}

public void testSegmentReplicationStatsResponseWithSearchReplica() throws Exception {
internalCluster().startClusterManagerOnlyNode();
final List<String> nodes = internalCluster().startDataOnlyNodes(2);
createIndex(
INDEX_NAME,
Settings.builder()
.put("number_of_shards", 1)
.put("number_of_replicas", 0)
.put("number_of_search_only_replicas", 1)
.put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT)
.build()
);
ensureGreen(INDEX_NAME);

final int docCount = 5;
for (int i = 0; i < docCount; i++) {
client().prepareIndex(INDEX_NAME).setId(Integer.toString(i)).setSource("field", "value" + i).execute().get();
}
refresh(INDEX_NAME);
waitForSearchableDocs(docCount, nodes);

SegmentReplicationStatsResponse segmentReplicationStatsResponse = dataNodeClient().admin()
.indices()
.prepareSegmentReplicationStats(INDEX_NAME)
.setDetailed(true)
.execute()
.actionGet();

// Verify the number of indices
assertEquals(1, segmentReplicationStatsResponse.getReplicationStats().size());
// Verify total shards
assertEquals(2, segmentReplicationStatsResponse.getTotalShards());
// Verify the number of primary shards
assertEquals(1, segmentReplicationStatsResponse.getReplicationStats().get(INDEX_NAME).size());

SegmentReplicationPerGroupStats perGroupStats = segmentReplicationStatsResponse.getReplicationStats().get(INDEX_NAME).get(0);
Set<SegmentReplicationShardStats> replicaStats = perGroupStats.getReplicaStats();
// Verify the number of replica stats
assertEquals(1, replicaStats.size());
for (SegmentReplicationShardStats replicaStat : replicaStats) {
assertNotNull(replicaStat.getCurrentReplicationState());
}
}
}
Loading

0 comments on commit 2bea56e

Please sign in to comment.