Skip to content

Commit

Permalink
Return unformatted Segment Replication metrics that take upload time …
Browse files Browse the repository at this point in the history
…into account for replication lag (#10723) (#10804)

* Return unformatted segrep metrics in stats



* Take upload time into account for replication time lag



* unformat segrep stats



* remove unused field names



---------


(cherry picked from commit 4f8bcff)

Signed-off-by: Poojita Raj <[email protected]>
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>
  • Loading branch information
1 parent 7c038b3 commit b399c67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

package org.opensearch.index;

import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.common.unit.ByteSizeValue;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;

Expand Down Expand Up @@ -76,9 +74,9 @@ public void writeTo(StreamOutput out) throws IOException {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(Fields.SEGMENT_REPLICATION);
builder.field(Fields.MAX_BYTES_BEHIND, new ByteSizeValue(maxBytesBehind).toString());
builder.field(Fields.TOTAL_BYTES_BEHIND, new ByteSizeValue(totalBytesBehind).toString());
builder.field(Fields.MAX_REPLICATION_LAG, new TimeValue(maxReplicationLag));
builder.field(Fields.MAX_BYTES_BEHIND, maxBytesBehind);
builder.field(Fields.TOTAL_BYTES_BEHIND, totalBytesBehind);
builder.field(Fields.MAX_REPLICATION_LAG, maxReplicationLag);
builder.endObject();
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3016,7 +3016,7 @@ public ReplicationStats getReplicationStats() {
long maxBytesBehind = stats.stream().mapToLong(SegmentReplicationShardStats::getBytesBehindCount).max().orElse(0L);
long totalBytesBehind = stats.stream().mapToLong(SegmentReplicationShardStats::getBytesBehindCount).sum();
long maxReplicationLag = stats.stream()
.mapToLong(SegmentReplicationShardStats::getCurrentReplicationTimeMillis)
.mapToLong(SegmentReplicationShardStats::getCurrentReplicationLagMillis)
.max()
.orElse(0L);
return new ReplicationStats(maxBytesBehind, totalBytesBehind, maxReplicationLag);
Expand Down

0 comments on commit b399c67

Please sign in to comment.