Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 74E17200CD9 for ; Thu, 3 Aug 2017 18:01:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7399616BE0B; Thu, 3 Aug 2017 16:01:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E04BE16BDE6 for ; Thu, 3 Aug 2017 18:01:20 +0200 (CEST) Received: (qmail 673 invoked by uid 500); 3 Aug 2017 16:01:19 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 99468 invoked by uid 99); 3 Aug 2017 16:01:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Aug 2017 16:01:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B92E8F553D; Thu, 3 Aug 2017 16:01:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: machristie@apache.org To: commits@airavata.apache.org Date: Thu, 03 Aug 2017 16:01:33 -0000 Message-Id: <2874c5bf856b4eac9d0bc289cfc68a25@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [17/50] [abbrv] airavata git commit: AIRAVATA-2405 loading all users in batches archived-at: Thu, 03 Aug 2017 16:01:22 -0000 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 Authored: Sun Jul 9 01:04:38 2017 -0500 Committer: Marcus Christie 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 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 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