-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Segment Replication] Adding segment replication statistics rolled up…
… at index, node and cluster level (#9709) (#9741) * [Segment Replication] Adding segment replication statistics rolled up at index, node and cluster level (#9709) * add node stats for segrep Signed-off-by: Poojita Raj <poojiraj@amazon.com> * comment removal Signed-off-by: Poojita Raj <poojiraj@amazon.com> * changelog Signed-off-by: Poojita Raj <poojiraj@amazon.com> * address review comments Signed-off-by: Poojita Raj <poojiraj@amazon.com> * move segrep stats to segments Signed-off-by: Poojita Raj <poojiraj@amazon.com> * fix failures Signed-off-by: Poojita Raj <poojiraj@amazon.com> * uniform response for docrep and segrep segment stats Signed-off-by: Poojita Raj <poojiraj@amazon.com> * remove pri check Signed-off-by: Poojita Raj <poojiraj@amazon.com> * version 3.0 Signed-off-by: Poojita Raj <poojiraj@amazon.com> --------- Signed-off-by: Poojita Raj <poojiraj@amazon.com> Signed-off-by: Rishikesh Pasham <62345295+Rishikesh1159@users.noreply.github.com> Co-authored-by: Rishikesh Pasham <62345295+Rishikesh1159@users.noreply.github.com> * Change bwc version to 2.10 from 3.0 Signed-off-by: Suraj Singh <surajrider@gmail.com> --------- Signed-off-by: Poojita Raj <poojiraj@amazon.com> Signed-off-by: Rishikesh Pasham <62345295+Rishikesh1159@users.noreply.github.com> Signed-off-by: Suraj Singh <surajrider@gmail.com> Co-authored-by: Poojita Raj <poojiraj@amazon.com> Co-authored-by: Rishikesh Pasham <62345295+Rishikesh1159@users.noreply.github.com>
- Loading branch information
1 parent
b3b1091
commit d5ca3a9
Showing
12 changed files
with
262 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
server/src/main/java/org/opensearch/index/ReplicationStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
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; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* ReplicationStats is used to provide segment replication statistics at an index, | ||
* node and cluster level on a segment replication enabled cluster. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ReplicationStats implements ToXContentFragment, Writeable { | ||
|
||
public long maxBytesBehind; | ||
public long maxReplicationLag; | ||
public long totalBytesBehind; | ||
|
||
public ReplicationStats(long maxBytesBehind, long totalBytesBehind, long maxReplicationLag) { | ||
this.maxBytesBehind = maxBytesBehind; | ||
this.totalBytesBehind = totalBytesBehind; | ||
this.maxReplicationLag = maxReplicationLag; | ||
} | ||
|
||
public ReplicationStats(StreamInput in) throws IOException { | ||
this.maxBytesBehind = in.readVLong(); | ||
this.totalBytesBehind = in.readVLong(); | ||
this.maxReplicationLag = in.readVLong(); | ||
} | ||
|
||
public ReplicationStats() { | ||
|
||
} | ||
|
||
public void add(ReplicationStats other) { | ||
if (other != null) { | ||
maxBytesBehind = Math.max(other.maxBytesBehind, maxBytesBehind); | ||
totalBytesBehind += other.totalBytesBehind; | ||
maxReplicationLag = Math.max(other.maxReplicationLag, maxReplicationLag); | ||
} | ||
} | ||
|
||
public long getMaxBytesBehind() { | ||
return this.maxBytesBehind; | ||
} | ||
|
||
public long getTotalBytesBehind() { | ||
return this.totalBytesBehind; | ||
} | ||
|
||
public long getMaxReplicationLag() { | ||
return this.maxReplicationLag; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeVLong(maxBytesBehind); | ||
out.writeVLong(totalBytesBehind); | ||
out.writeVLong(maxReplicationLag); | ||
} | ||
|
||
@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.endObject(); | ||
return builder; | ||
} | ||
|
||
/** | ||
* Fields for segment replication statistics | ||
* | ||
* @opensearch.internal | ||
*/ | ||
static final class Fields { | ||
static final String SEGMENT_REPLICATION = "segment_replication"; | ||
static final String MAX_BYTES_BEHIND = "max_bytes_behind"; | ||
static final String TOTAL_BYTES_BEHIND = "total_bytes_behind"; | ||
static final String MAX_REPLICATION_LAG = "max_replication_lag"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.