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 <im...@apache.org> 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