Added comment in 0b409e5cd2020322b82a9c472a9cee6d4c3e607f. On Sat, Feb 7, 2015 at 11:26 AM, Reka Thirunavukkarasu <[email protected]> wrote:
> Sorry. I should have added the comment in that section. Will go through > the code and add the relevant comments in the area where it has less > visibility. > > Thanks, > Reka > > On Sat, Feb 7, 2015 at 11:23 AM, Reka Thirunavukkarasu <[email protected]> > wrote: > >> Hi Imesh, >> >> As i explained in the other thread, all the clusters are created at once >> in the ApplicationClustersCreatedEvent. I beleive that by checking whether >> one of the cluster exists, we can assume that all the clusters are there >> which will improve performance as well. >> >> Thanks, >> Reka >> >> On Sat, Feb 7, 2015 at 3:14 AM, Imesh Gunaratne <[email protected]> wrote: >> >>> Hi Reka, >>> >>> Would you mind explaining the logic in this method? It is difficult to >>> understand the statements highlighted in yellow. If we are trying to check >>> whether all clusters have been initialized in an application, why do we >>> return true if one of the service clusters exists? >>> >>> public static boolean allClustersInitialized(Application application) { >>> boolean allClustersInitialized = false; >>> for (ClusterDataHolder holder : >>> application.getClusterDataRecursively()) { >>> TopologyManager.acquireReadLockForCluster(holder.getServiceType(), >>> holder.getClusterId()); >>> >>> try { >>> Topology topology = TopologyManager.getTopology(); >>> if (topology != null) { >>> Service service = >>> topology.getService(holder.getServiceType()); >>> if (service != null) { >>> if (service.clusterExists(holder.getClusterId())) { >>> allClustersInitialized = true; >>> return allClustersInitialized; >>> } else { >>> if (log.isDebugEnabled()) { >>> log.debug("[Cluster] " + holder.getClusterId() >>> + " is not found in " + >>> "the Topology"); >>> } >>> allClustersInitialized = false; >>> } >>> } else { >>> if (log.isDebugEnabled()) { >>> log.debug("Service is null in the >>> CompleteTopologyEvent"); >>> } >>> } >>> } else { >>> if (log.isDebugEnabled()) { >>> log.debug("Topology is null in the >>> CompleteTopologyEvent"); >>> } >>> } >>> } finally { >>> >>> TopologyManager.releaseReadLockForCluster(holder.getServiceType(), >>> holder.getClusterId()); >>> } >>> } >>> return allClustersInitialized; >>> } >>> >>> Thanks >>> >>> >>> >>> -- >>> Imesh Gunaratne >>> >>> Technical Lead, WSO2 >>> Committer & PMC Member, Apache Stratos >>> >> >> >> >> -- >> Reka Thirunavukkarasu >> Senior Software Engineer, >> WSO2, Inc.:http://wso2.com, >> Mobile: +94776442007 >> >> >> > > > -- > Reka Thirunavukkarasu > Senior Software Engineer, > WSO2, Inc.:http://wso2.com, > Mobile: +94776442007 > > > -- Reka Thirunavukkarasu Senior Software Engineer, WSO2, Inc.:http://wso2.com, Mobile: +94776442007
