-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Segment Replication] Adding segment replication statistics rolled up at index, node and cluster level #9709
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c726042
add node stats for segrep
Poojita-Raj 054342c
comment removal
Poojita-Raj df2b2a6
changelog
Poojita-Raj eca18d2
address review comments
Poojita-Raj 8efeccf
move segrep stats to segments
Poojita-Raj 7d428c4
fix failures
Poojita-Raj 04323bb
uniform response for docrep and segrep segment stats
Poojita-Raj 01d4dfe
remove pri check
Poojita-Raj 0e64471
version 3.0
Poojita-Raj 7ad9831
Merge branch 'main' into node_stats
Rishikesh1159 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
*/ | ||
mch2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry didn't catch this - lets move this to indices.replication package?