You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sk...@apache.org on 2022/08/11 16:55:18 UTC

[ignite-3] branch main updated: IGNITE-17394 Added api method for retrieving mapping of partitions leaders. Fixes #997

This is an automated email from the ASF dual-hosted git repository.

sk0x50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 747ba20c9 IGNITE-17394 Added api method for retrieving mapping of partitions leaders. Fixes #997
747ba20c9 is described below

commit 747ba20c961d9fde8810f1411bab0a158d0aae45
Author: Mirza Aliev <al...@gmail.com>
AuthorDate: Thu Aug 11 19:55:03 2022 +0300

    IGNITE-17394 Added api method for retrieving mapping of partitions leaders. Fixes #997
    
    Signed-off-by: Slava Koptilin <sl...@gmail.com>
---
 .../internal/table/distributed/TableManager.java    | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
index 0d929afca..ba0e2926c 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
@@ -442,7 +442,6 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
             return failedFuture(new NodeStoppingException());
         }
 
-
         try {
             updateAssignmentInternal(assignmentsCtx);
         } finally {
@@ -617,6 +616,26 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
         shutdownAndAwaitTermination(ioExecutor, 10, TimeUnit.SECONDS);
     }
 
+    /**
+     * Gets a list of the current table assignments.
+     *
+     * <p>Returns a list where on the i-th place resides a node id that considered as a leader for
+     * the i-th partition on the moment of invocation.
+     *
+     * @param tableId Unique id of a table.
+     * @return List of the current assignments.
+     */
+    public List<String> assignments(UUID tableId) throws NodeStoppingException {
+        if (!busyLock.enterBusy()) {
+            throw new NodeStoppingException();
+        }
+        try {
+            return table(tableId).internalTable().assignments();
+        } finally {
+            busyLock.leaveBusy();
+        }
+    }
+
     /**
      * Creates local structures for a table.
      *