Skip to content

Commit

Permalink
version 3.0
Browse files Browse the repository at this point in the history
Signed-off-by: Poojita Raj <poojiraj@amazon.com>
  • Loading branch information
Poojita-Raj committed Sep 4, 2023
1 parent 01d4dfe commit 0e64471
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ public SegmentsStats(StreamInput in) throws IOException {
fileSizes = in.readMap(StreamInput::readString, StreamInput::readLong);
if (in.getVersion().onOrAfter(Version.V_2_10_0)) {
remoteSegmentStats = in.readOptionalWriteable(RemoteSegmentStats::new);
replicationStats = in.readOptionalWriteable(ReplicationStats::new);
} else {
remoteSegmentStats = new RemoteSegmentStats();
}
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
replicationStats = in.readOptionalWriteable(ReplicationStats::new);
} else {
replicationStats = new ReplicationStats();

Check warning on line 131 in server/src/main/java/org/opensearch/index/engine/SegmentsStats.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/engine/SegmentsStats.java#L131

Added line #L131 was not covered by tests
}
}
Expand Down Expand Up @@ -326,6 +329,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeMap(this.fileSizes, StreamOutput::writeString, StreamOutput::writeLong);
if (out.getVersion().onOrAfter(Version.V_2_10_0)) {
out.writeOptionalWriteable(remoteSegmentStats);
}
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
out.writeOptionalWriteable(replicationStats);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2944,7 +2944,7 @@ public Set<SegmentReplicationShardStats> getReplicationStatsForTrackedReplicas()
}

public ReplicationStats getReplicationStats() {
if (indexSettings.isSegRepEnabled()) {
if (indexSettings.isSegRepEnabled() && routingEntry().primary()) {
final Set<SegmentReplicationShardStats> stats = getReplicationStatsForTrackedReplicas();
long maxBytesBehind = stats.stream().mapToLong(SegmentReplicationShardStats::getBytesBehindCount).max().orElse(0L);
long totalBytesBehind = stats.stream().mapToLong(SegmentReplicationShardStats::getBytesBehindCount).sum();
Expand All @@ -2954,7 +2954,7 @@ public ReplicationStats getReplicationStats() {
.orElse(0L);
return new ReplicationStats(maxBytesBehind, totalBytesBehind, maxReplicationLag);
}
return null;
return new ReplicationStats();

Check warning on line 2957 in server/src/main/java/org/opensearch/index/shard/IndexShard.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/shard/IndexShard.java#L2957

Added line #L2957 was not covered by tests
}

/**
Expand Down

0 comments on commit 0e64471

Please sign in to comment.