ygerzhedovich commented on code in PR #1501:
URL: https://github.com/apache/ignite-3/pull/1501#discussion_r1087871072


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1010,6 +1079,30 @@ public List<String> assignments() {
                 .collect(Collectors.toList());
     }
 
+    /** {@inheritDoc} */
+    // TODO: IGNITE-17256 Use a placement driver for getting a primary replica.
+    @Override
+    public List<IgniteBiTuple<String, Long>> leaderAssignmentsWithTerm() {
+        List<Entry<RaftGroupService>> entries = new 
ArrayList<>(partitionMap.int2ObjectEntrySet());
+        List<CompletableFuture<LeaderWithTerm>> futs = new ArrayList<>();
+
+        entries.sort(Comparator.comparingInt(Entry::getIntKey));
+
+        for (Entry<RaftGroupService> e : entries) {
+            futs.add(e.getValue().refreshAndGetLeaderWithTerm());
+        }
+
+        List<IgniteBiTuple<String, Long>> leadersWithTerm = new 
ArrayList<>(entries.size());
+
+        for (CompletableFuture<LeaderWithTerm> fut : futs) {
+            LeaderWithTerm leaderWithTerm = fut.join();
+
+            leadersWithTerm.add(new 
IgniteBiTuple<>(leaderWithTerm.leader().consistentId(), leaderWithTerm.term()));

Review Comment:
   you can use NodeWithTerm instantly instead of BiTuple



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to