Skip to content

Commit

Permalink
Fix javadoc.
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <handalm@amazon.com>
  • Loading branch information
mch2 committed Sep 4, 2023
1 parent 068ad9a commit 072ae99
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ static final class Fields {
static final String TOTAL_BYTES_AHEAD = "total_bytes_ahead";
}

/**
* Replication stats for a shard. This class is reused by primary and replicas
*/
public static class ShardReplicationStats implements Writeable {
public long maxBytes;
public long totalBytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.common.Nullable;
import org.opensearch.common.util.concurrent.ConcurrentCollections;
import org.opensearch.index.ReplicationStats;
import org.opensearch.index.store.Store;
import org.opensearch.index.store.StoreFileMetadata;
import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint;
Expand Down Expand Up @@ -89,7 +88,10 @@ Queue<TimedReplicationCheckpoint> getActiveTimers() {
private List<StoreFileMetadata> getMissingFiles(ReplicationCheckpoint latestReplicationCheckpoint) {
final ReplicationCheckpoint latestReceivedCheckpoint = getLatestReceivedCheckpoint();
if (latestReplicationCheckpoint != null && latestReceivedCheckpoint != null) {
return Store.segmentReplicationDiff(latestReplicationCheckpoint.getMetadataMap(), latestReceivedCheckpoint.getMetadataMap()).missing;
return Store.segmentReplicationDiff(
latestReplicationCheckpoint.getMetadataMap(),
latestReceivedCheckpoint.getMetadataMap()
).missing;
}
return Collections.emptyList();
}
Expand All @@ -114,9 +116,7 @@ ReplicationCheckpoint getCheckpoint() {

@Override
public String toString() {
return "TimedReplicationCheckpoint{" +
"checkpoint=" + checkpoint +
'}';
return "TimedReplicationCheckpoint{" + "checkpoint=" + checkpoint + '}';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ public SegmentReplicationState getSegmentReplicationState(ShardId shardId) {

@Nullable
public ReplicationStats.ShardReplicationStats getStatsForShard(ReplicationCheckpoint checkpoint) {
return Optional.ofNullable(replicaTrackers.get(checkpoint.getShardId())).map(tracker -> new ReplicationStats.ShardReplicationStats(tracker.getBytesBehind(checkpoint), tracker.getReplicationLag())).orElse(null);
return Optional.ofNullable(replicaTrackers.get(checkpoint.getShardId()))
.map(tracker -> new ReplicationStats.ShardReplicationStats(tracker.getBytesBehind(checkpoint), tracker.getReplicationLag()))
.orElse(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,18 @@ public void testSerialization() throws IOException {
final ReplicationStats.ShardReplicationStats deserializedReplicationStatsReplicaStats = deserializedReplicationStats
.getReplicaStats();
final ReplicationStats.ShardReplicationStats replicaStats = replicationStats.getReplicaStats();
assertEquals(deserializedReplicationStatsReplicaStats.getMaxBytes(), deserializedReplicationStatsReplicaStats.getMaxBytes());
assertEquals(deserializedReplicationStatsReplicaStats.getTotalBytes(), deserializedReplicationStatsReplicaStats.getTotalBytes());
assertEquals(deserializedReplicationStatsReplicaStats.getMaxReplicationLag(), deserializedReplicationStatsReplicaStats.getMaxReplicationLag());
assertEquals(
deserializedReplicationStatsReplicaStats.getMaxBytes(),
deserializedReplicationStatsReplicaStats.getMaxBytes()
);
assertEquals(
deserializedReplicationStatsReplicaStats.getTotalBytes(),
deserializedReplicationStatsReplicaStats.getTotalBytes()
);
assertEquals(
deserializedReplicationStatsReplicaStats.getMaxReplicationLag(),
deserializedReplicationStatsReplicaStats.getMaxReplicationLag()
);
}
}
}
Expand Down

0 comments on commit 072ae99

Please sign in to comment.