Skip to content

Commit

Permalink
Convert ReplicationTracker insync global checkpoints getter to Map
Browse files Browse the repository at this point in the history
This method is only used for an assertion in test clusters. This commit
converts the hppc map to Java Map.

relates elastic#84735
  • Loading branch information
rjernst committed Mar 10, 2022
1 parent 744e5f7 commit b4c7fb0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -730,15 +730,14 @@ public int hashCode() {
*
* @return a map from allocation ID to the local knowledge of the persisted global checkpoint for that allocation ID
*/
public synchronized ObjectLongMap<String> getInSyncGlobalCheckpoints() {
public synchronized Map<String, Long> getInSyncGlobalCheckpoints() {
assert primaryMode;
assert handoffInProgress == false;
final ObjectLongMap<String> globalCheckpoints = new ObjectLongHashMap<>(checkpoints.size()); // upper bound on the size
checkpoints.entrySet()
return checkpoints.entrySet()
.stream()
.filter(e -> e.getValue().inSync)
.forEach(e -> globalCheckpoints.put(e.getKey(), e.getValue().globalCheckpoint));
return globalCheckpoints;
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().globalCheckpoint));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,7 @@ public long getLastSyncedGlobalCheckpoint() {
*
* @return a map from allocation ID to the local knowledge of the global checkpoint for that allocation ID
*/
public ObjectLongMap<String> getInSyncGlobalCheckpoints() {
public Map<String, Long> getInSyncGlobalCheckpoints() {
assert assertPrimaryMode();
verifyNotClosed();
return replicationTracker.getInSyncGlobalCheckpoints();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ public void assertSeqNos() throws Exception {
continue; // just ignore - shard movement
}
final SeqNoStats primarySeqNoStats;
final ObjectLongMap<String> syncGlobalCheckpoints;
final Map<String, Long> syncGlobalCheckpoints;
try {
primarySeqNoStats = primaryShard.seqNoStats();
syncGlobalCheckpoints = primaryShard.getInSyncGlobalCheckpoints();
Expand Down

0 comments on commit b4c7fb0

Please sign in to comment.