HI Isuru, Thanks I did not notice the null check. Thanks for the info.
On Fri, Mar 13, 2015 at 12:35 PM, Isuru Haththotuwa <[email protected]> wrote: > Hi, > > When is this method called? AFAIR its not called every time an application > is deployed/un-deployed. > > The lock is taken if the applications are null only; that is when > applications are read for the first time. Thereafter, it will only be > returning the applications data structure which is in memory. > > On Fri, Mar 13, 2015 at 12:28 PM, Udara Liyanage <[email protected]> wrote: > >> While looking in to application undeployment issue, I noticed that >> *getApplications*() in ApplicationHolder is executed as a synchronized >> block. Normally doing IO operations inside a synchronized block is not >> recommended since other threads has to wait to take the lock. Assume that >> one thread hang a long time due to a slowness in just one connection of >> registry db call, then all other threads become BLOCKED. This may result in >> performance degrade. >> I guess since it is just a READ operation, it is not needed to >> synchronize. >> >> public static Applications getApplications () { >> >> if (applications == null) { >> synchronized (ApplicationHolder.class) { >> if (applications == null) { >> // retrieve from registry >> applications = AutoscalerUtil.getApplications(); >> if (log.isDebugEnabled()) { >> log.debug("Trying to retrieve Applications from >> registry"); >> } >> if (applications == null) { >> if (log.isDebugEnabled()) { >> log.debug("No applications found in >> Registry"); >> } >> // create a new Applications object >> applications = new Applications(); >> } >> } >> } >> } >> >> return applications; >> } >> -- >> >> Udara Liyanage >> Software Engineer >> WSO2, Inc.: http://wso2.com >> lean. enterprise. middleware >> >> web: http://udaraliyanage.wordpress.com >> phone: >> +94 71 443 6897 >> >> -- >> Thanks and Regards, >> >> Isuru H. >> +94 716 358 048* <http://wso2.com/>* >> >> >> * <http://wso2.com/>* >> >> >> * <http://wso2.com/>* >> >> >> -- Udara Liyanage Software Engineer WSO2, Inc.: http://wso2.com lean. enterprise. middleware web: http://udaraliyanage.wordpress.com phone: +94 71 443 6897
