@Override public void processClusterEvent(ClusterEvent clusterEvent) { ClusterEventType clusterEventType = clusterEvent.getClusterEventType(); if (!clusterEventType.equals(ClusterEventType.JOIN)) { return; } List<Address> clusterNodeAddresses = ClusterExecutorUtil.getClusterNodeAddresses(); List<ClusterNode> clusterNodes = clusterEvent.getClusterNodes(); if ((clusterNodeAddresses.size() - clusterNodes.size()) > 1) { if (_log.isDebugEnabled()) { _log.debug("Number of original cluster members is greater than " + "one"); } return; } long[] companyIds = PortalInstances.getCompanyIds(); for (long companyId : companyIds) { loadIndexes(companyId); } loadIndexes(CompanyConstants.SYSTEM); }
private void _loadIndexFromCluster(IndexAccessor indexAccessor, long localLastGeneration) { List<Address> clusterNodeAddresses = ClusterExecutorUtil.getClusterNodeAddresses(); int clusterNodeAddressesCount = clusterNodeAddresses.size(); if (clusterNodeAddressesCount <= 1) { if (_log.isDebugEnabled()) { _log.debug( "Do not load indexes because there is either one portal " + "instance or no portal instances in the cluster"); } return; } ClusterRequest clusterRequest = ClusterRequest.createMulticastRequest( new MethodHandler(_getLastGenerationMethodKey, indexAccessor.getCompanyId()), true); ClusterExecutorUtil.execute( clusterRequest, new LoadIndexClusterResponseCallback( indexAccessor, clusterNodeAddressesCount, localLastGeneration)); }