java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml | 34 ++++++ java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java | 20 --- java/code/src/com/redhat/rhn/manager/system/SystemManager.java | 52 ++++++++++ 3 files changed, 89 insertions(+), 17 deletions(-)
New commits: commit 60d188b797fd3bac125bc735ec88bf3fd33c2bd7 Author: Stephen Herr sherr@redhat.com Date: Thu Mar 15 13:21:08 2012 -0400
790120 - Removing rule to help system overview listing happen faster, improving performance of api queries
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml index abc68e8..cdb0cc5 100644 --- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml +++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml @@ -425,6 +425,38 @@ ORDER BY UPPER(COALESCE(X.name, '(none)')), X.id </query> </mode>
+<mode name="xmlrpc_visible_to_user_inactive"> + <query params="user_id, checkin_threshold"> +select * from ( + SELECT DISTINCT S.id AS ID, + S.name AS NAME, + INFO.checkin AS LAST_CHECKIN + FROM rhnServer S, rhnUserServerPerms USP, rhnServerInfo INFO + WHERE USP.user_id = :user_id + AND S.id = USP.server_id + AND S.id = INFO.server_id + AND INFO.checkin < current_timestamp - numtodsinterval(:checkin_threshold * 86400, 'second') +) X +ORDER BY UPPER(COALESCE(X.name, '(none)')), X.id + </query> +</mode> + +<mode name="xmlrpc_visible_to_user_active"> + <query params="user_id, checkin_threshold"> +select * from ( + SELECT DISTINCT S.id AS ID, + S.name AS NAME, + INFO.checkin AS LAST_CHECKIN + FROM rhnServer S, rhnUserServerPerms USP, rhnServerInfo INFO + WHERE USP.user_id = :user_id + AND S.id = USP.server_id + AND S.id = INFO.server_id + AND INFO.checkin > current_timestamp - numtodsinterval(:checkin_threshold * 86400, 'second') +) X +ORDER BY UPPER(COALESCE(X.name, '(none)')), X.id + </query> +</mode> + <mode name="visible_to_user_from_sysid_list" class="com.redhat.rhn.frontend.dto.SystemSearchResult"> <query name="available_to_user_from_sysid_list" /> <elaborator name="system_overview" /> @@ -1112,7 +1144,7 @@ ORDER BY S.ID </query>
<query name="system_overview" params=""> - SELECT /*+ RULE */ SERVER_ID AS ID, OUTDATED_PACKAGES, SERVER_NAME, security_errata, bug_errata, enhancement_errata, + SELECT SERVER_ID AS ID, OUTDATED_PACKAGES, SERVER_NAME, security_errata, bug_errata, enhancement_errata, SERVER_ADMINS, GROUP_COUNT, MODIFIED, CHANNEL_LABELS, CHANNEL_ID, HISTORY_COUNT, LAST_CHECKIN_DAYS_AGO, PENDING_UPDATES, OS, RELEASE, SERVER_ARCH_NAME, LAST_CHECKIN, LOCKED, config_files_with_differences, diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java index 3b76b07..e64ee9f 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java @@ -584,19 +584,9 @@ public class SystemHandler extends BaseHandler { * $SystemOverviewSerializer * #array_end() */ - public Object[] listActiveSystems(String sessionKey) throws FaultException { + public List listActiveSystems(String sessionKey) throws FaultException { User loggedInUser = getLoggedInUser(sessionKey); - DataResult<SystemOverview> dr = SystemManager.systemList(loggedInUser, null); - dr.elaborate(); - List<SystemOverview> returnList = new ArrayList(); - - for (SystemOverview so : dr) { - if (isSystemInactive(so)) { - continue; - } - returnList.add(so); - } - return returnList.toArray(); + return SystemManager.systemListShortActive(loggedInUser, null); }
private Map createChannelMap(EssentialChannelDto channel, Boolean currentBase) { @@ -2340,7 +2330,6 @@ public class SystemHandler extends BaseHandler { return XmlRpcSystemHelper.getInstance().lookupServer(user, sid); }
- /** * Private helper method to determine if a server is inactive. * @param so SystemOverview object representing system to inspect. @@ -4038,8 +4027,7 @@ public class SystemHandler extends BaseHandler { */ public List listInactiveSystems(String sessionKey) { User loggedInUser = getLoggedInUser(sessionKey); - return SystemManager.inactiveList(loggedInUser, null); - + return SystemManager.systemListShortInactive(loggedInUser, null); }
@@ -4060,7 +4048,7 @@ public class SystemHandler extends BaseHandler { */ public List listInactiveSystems(String sessionKey, Integer days) { User loggedInUser = getLoggedInUser(sessionKey); - return SystemManager.inactiveList(loggedInUser, null, days); + return SystemManager.systemListShortInactive(loggedInUser, days, null); }
/** diff --git a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java index be29dd0..db91a9a 100644 --- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java +++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java @@ -372,6 +372,58 @@ public class SystemManager extends BaseManager { }
/** + * Returns list of all systems visible to user that are inactive. + * This is meant to be fast and only gets the id, name, and last checkin + * @param user Currently logged in user. + * @param pc PageControl + * @return list of SystemOverviews. + */ + public static DataResult systemListShortInactive(User user, PageControl pc) { + return systemListShortInactive(user, new Integer(Config.get().getInt(ConfigDefaults + .SYSTEM_CHECKIN_THRESHOLD)), pc); + } + + /** + * Returns list of all systems visible to user that are inactive. + * This is meant to be fast and only gets the id, name, and last checkin + * @param user Currently logged in user. + * @param inactiveThreshold number of days before we consider systems inactive + * @param pc PageControl + * @return list of SystemOverviews. + */ + public static DataResult systemListShortInactive( + User user, int inactiveThreshold, PageControl pc) { + SelectMode m = ModeFactory.getMode( + "System_queries", "xmlrpc_visible_to_user_inactive", + SystemOverview.class); + Map params = new HashMap(); + params.put("user_id", user.getId()); + params.put("checkin_threshold", inactiveThreshold); + Map elabParams = new HashMap(); + + return makeDataResult(params, elabParams, pc, m); + } + + /** + * Returns list of all systems visible to user that are active. + * This is meant to be fast and only gets the id, name, and last checkin + * @param user Currently logged in user. + * @param pc PageControl + * @return list of SystemOverviews. + */ + public static DataResult systemListShortActive(User user, PageControl pc) { + SelectMode m = ModeFactory.getMode( + "System_queries", "xmlrpc_visible_to_user_active", SystemOverview.class); + Map params = new HashMap(); + params.put("user_id", user.getId()); + params.put("checkin_threshold", new Integer(Config.get().getInt(ConfigDefaults + .SYSTEM_CHECKIN_THRESHOLD))); + Map elabParams = new HashMap(); + + return makeDataResult(params, elabParams, pc, m); + } + + /** * Returns list of all systems that are visible to user * but not in the given server group. * @param user Currently logged in user.
spacewalk-commits@lists.fedorahosted.org