airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [17/50] [abbrv] airavata git commit: AIRAVATA-2405 loading all users in batches
Date Thu, 03 Aug 2017 16:01:33 GMT
AIRAVATA-2405 loading all users in batches


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/5d4d1057
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/5d4d1057
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/5d4d1057

Branch: refs/heads/master
Commit: 5d4d1057c70406ac03cb09aef706cd7020315eed
Parents: 86713ee
Author: Marcus Christie <machristie@apache.org>
Authored: Sun Jul 9 01:04:38 2017 -0500
Committer: Marcus Christie <machristie@apache.org>
Committed: Sun Jul 9 01:04:38 2017 -0500

----------------------------------------------------------------------
 .../core/impl/TenantManagementKeycloakImpl.java | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/5d4d1057/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
index 97039ed..e3ac6a3 100644
--- a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
+++ b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
@@ -535,12 +535,20 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface
{
         try{
             client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(),
tenantId, realmAdminCreds);
             // FIXME: this only searches through the most recent 100 users for the given
role (assuming there are no more than 10,000 users in the gateway)
-            logger.debug("getUsersWithRole: fetching all users...");
-            List<UserRepresentation> allUsers = client.realm(tenantId).users().search(null,
-                    null,
-                    null,
-                    null,
-                    0, 100);
+            int totalUserCount = client.realm(tenantId).users().count();
+            logger.debug("getUsersWithRole: totalUserCount=" + totalUserCount);
+            // Load all users in batches
+            List<UserRepresentation> allUsers = new ArrayList<>();
+            int userBatchSize = 100;
+            for (int start = 0; start < totalUserCount; start=start+userBatchSize) {
+
+                logger.debug("getUsersWithRole: fetching " + userBatchSize + " users...");
+                allUsers.addAll(client.realm(tenantId).users().search(null,
+                        null,
+                        null,
+                        null,
+                        start, userBatchSize));
+            }
             logger.debug("getUsersWithRole: all users count=" + allUsers.size());
             allUsers.sort((a, b) -> a.getCreatedTimestamp() - b.getCreatedTimestamp()
> 0 ? -1 : 1);
             // The 100 most recently created users


Mime
View raw message