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


##########
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:
   AFAIK, I can't do it without changing dependencies.
   
   `LeaderWithTerm` is located in raft-api module
   `NodeWithTerm` (a new one) is located in sql-engine module (it depends on 
table module, but not raft-api)
   `InternalTableImpl` is located in table module (it depends on raft-api, but 
not on sql-engine)
   
   I can add raft-api as sql-engine dependency



-- 
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