Author: scottmf Date: 2010-01-20 21:26:40 -0800 (Wed, 20 Jan 2010) New Revision: 14205 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14205 Modified: trunk/src/org/hyperic/hibernate/dialect/Oracle9Dialect.java trunk/src/org/hyperic/hq/application/HQApp.java trunk/src/org/hyperic/hq/bizapp/server/session/AuthzBossEJBImpl.java trunk/src/org/hyperic/hq/ui/action/resource/ResourceController.java trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/visibility/MetricsControlAction.java Log: [HHQ-3676] [HQ-1915] added a callback to start a new session when a user preferences are updated instead of upgrading a session to read-write when a user bounces from page to page. This increases page load times about 2-3x for very large groups / applications. Changed oracle to use a metric union for the indicator page charts instead of EAM_MEASUREMENT_DATA view. Benchmarks show that this performs better in with lots of measurements. Modified: trunk/src/org/hyperic/hibernate/dialect/Oracle9Dialect.java =================================================================== --- trunk/src/org/hyperic/hibernate/dialect/Oracle9Dialect.java 2010-01-20 09:24:32 UTC (rev 14204) +++ trunk/src/org/hyperic/hibernate/dialect/Oracle9Dialect.java 2010-01-21 05:26:40 UTC (rev 14205) @@ -150,7 +150,7 @@ } public boolean useMetricUnion() { - return true; + return false; } public String getLimitBuf(String sql, int offset, int limit) { Modified: trunk/src/org/hyperic/hq/application/HQApp.java =================================================================== --- trunk/src/org/hyperic/hq/application/HQApp.java 2010-01-20 09:24:32 UTC (rev 14204) +++ trunk/src/org/hyperic/hq/application/HQApp.java 2010-01-21 05:26:40 UTC (rev 14205) @@ -54,6 +54,9 @@ import org.hyperic.hibernate.HibernateInterceptorChain; import org.hyperic.hibernate.HypericInterceptor; import org.hyperic.hibernate.Util; +import org.hyperic.hq.authz.server.session.AuthzSubject; +import org.hyperic.hq.authz.server.session.AuthzSubjectManagerEJBImpl; +import org.hyperic.hq.authz.shared.AuthzSubjectManagerLocal; import org.hyperic.hq.common.SystemException; import org.hyperic.hq.common.shared.HQConstants; import org.hyperic.hq.hibernate.SessionManager; @@ -62,6 +65,7 @@ import org.hyperic.tools.ant.dbupgrade.DBUpgrader; import org.hyperic.txsnatch.TxSnatch; import org.hyperic.util.callback.CallbackDispatcher; +import org.hyperic.util.config.ConfigResponse; import org.hyperic.util.jdbc.DBUtil; import org.hyperic.util.thread.ThreadWatchdog; import org.hyperic.util.timer.StopWatch; @@ -80,6 +84,7 @@ private ThreadLocal _txListeners = new ThreadLocal(); private List _startupClasses = new ArrayList(); private CallbackDispatcher _callbacks; + private ThreadLocal _userPrefsCallbacks = new ThreadLocal(); private ShutdownCallback _shutdown; private File _restartStorage; private File _resourceDir; @@ -440,6 +445,45 @@ } } + public void setUserPrefsCallback(Integer sessionId, Integer subjId, ConfigResponse prefs) { + List list = (List) _userPrefsCallbacks.get(); + if (list == null) { + list = new ArrayList(); + _userPrefsCallbacks.set(list); + } + Object[] objs = new Object[3]; + objs[0] = sessionId; + objs[1] = subjId; + objs[2] = prefs; + list.add(objs); + } + + private void runSetUserPrefsCallback() { + List list = (List) _userPrefsCallbacks.get(); + if (list == null) { + return; + } + _userPrefsCallbacks.set(null); + final boolean debug = _log.isDebugEnabled(); + for (Iterator it=list.iterator(); it.hasNext(); ) { + Object[] objs = (Object[]) it.next(); + Integer sessionId = (Integer) objs[0]; + Integer subjId = (Integer) objs[1]; + ConfigResponse prefs = (ConfigResponse) objs[2]; + try { + if (debug) { + _log.debug("setting preferences for sessionid=" + sessionId + + ", subjId=" + subjId); + } + AuthzSubject who = + org.hyperic.hq.auth.shared.SessionManager.getInstance().getSubject(sessionId); + AuthzSubjectManagerEJBImpl.getOne().setUserPrefs(who, subjId, prefs); + } catch (Exception e) { + _log.error(e,e); + } + } + } + private static class Snatcher implements TxSnatch.Snatcher { private final Object SNATCH_LOCK = new Object(); private HQApp _app; @@ -485,7 +529,7 @@ Method meth = v.getMethod(); String methName = meth.getName(); Class c = meth.getDeclaringClass(); - String className = meth.getClass().getName(); + String className = c.getName(); boolean readWrite = false; boolean flush = true; boolean sessCreated = SessionManager.setupSession(methName); @@ -555,12 +599,14 @@ className + "]"); } SessionManager.cleanupSession(flush); + HQApp.getInstance().runSetUserPrefsCallback(); } } } - + private boolean methIsReadOnly(String methName) { return // 'create' is part of EJB session bean creation + methName.equals("setUserPrefsAfterCommit") || methName.equals("create") || methName.equals("disconnectAgent") || // recent alerts & indicators Modified: trunk/src/org/hyperic/hq/bizapp/server/session/AuthzBossEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/server/session/AuthzBossEJBImpl.java 2010-01-20 09:24:32 UTC (rev 14204) +++ trunk/src/org/hyperic/hq/bizapp/server/session/AuthzBossEJBImpl.java 2010-01-21 05:26:40 UTC (rev 14205) @@ -42,6 +42,7 @@ import org.hyperic.hq.appdef.shared.AppdefEntityID; import org.hyperic.hq.appdef.shared.AppdefEntityNotFoundException; import org.hyperic.hq.appdef.shared.UpdateException; +import org.hyperic.hq.application.HQApp; import org.hyperic.hq.auth.shared.SessionException; import org.hyperic.hq.auth.shared.SessionManager; import org.hyperic.hq.auth.shared.SessionNotFoundException; @@ -471,6 +472,18 @@ * Set the UserPreferences * @ejb:interface-method */ + public void setUserPrefsAfterCommit(Integer sessionId, Integer subjectId, + ConfigResponse prefs) + throws ApplicationException, SessionTimeoutException, + SessionNotFoundException + { + HQApp.getInstance().setUserPrefsCallback(sessionId, subjectId, prefs); + } + + /** + * Set the UserPreferences + * @ejb:interface-method + */ public void setUserPrefs(Integer sessionId, Integer subjectId, ConfigResponse prefs) throws ApplicationException, SessionTimeoutException, @@ -478,7 +491,6 @@ { AuthzSubject who = manager.getSubject(sessionId); getAuthzSubjectManager().setUserPrefs(who, subjectId, prefs); - getUserPrefs(sessionId, subjectId); } /** Modified: trunk/src/org/hyperic/hq/ui/action/resource/ResourceController.java =================================================================== --- trunk/src/org/hyperic/hq/ui/action/resource/ResourceController.java 2010-01-20 09:24:32 UTC (rev 14204) +++ trunk/src/org/hyperic/hq/ui/action/resource/ResourceController.java 2010-01-21 05:26:40 UTC (rev 14205) @@ -183,7 +183,7 @@ Constants.USERPREF_KEY_RECENT_RESOURCES, userPrefs, entityId, 10)) { AuthzBoss boss = ContextUtils.getAuthzBoss(ctx); - boss.setUserPrefs(user.getSessionId(), + boss.setUserPrefsAfterCommit(user.getSessionId(), user.getSubject().getId(), userPrefs); } } catch (AppdefEntityNotFoundException aenf) { Modified: trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/visibility/MetricsControlAction.java =================================================================== --- trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/visibility/MetricsControlAction.java 2010-01-20 09:24:32 UTC (rev 14204) +++ trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/visibility/MetricsControlAction.java 2010-01-21 05:26:40 UTC (rev 14205) @@ -183,7 +183,7 @@ } } } - boss.setUserPrefs(sessionId, user.getId(), user.getPreferences()); + boss.setUserPrefsAfterCommit(sessionId, user.getId(), user.getPreferences()); } |