List of usage examples for com.liferay.portal.kernel.cluster ClusterExecutorUtil execute
public static FutureClusterResponses execute(ClusterRequest clusterRequest)
From source file:com.liferay.portlet.admin.action.EditServerAction.java
License:Open Source License
protected void reindex(ActionRequest actionRequest) throws Exception { String portletId = ParamUtil.getString(actionRequest, "portletId"); long[] companyIds = PortalInstances.getCompanyIds(); if (LuceneHelperUtil.isLoadIndexFromClusterEnabled()) { MessageValuesThreadLocal.setValue(ClusterLinkUtil.CLUSTER_FORWARD_MESSAGE, true); }/*from w ww. j a v a 2s . c o m*/ if (Validator.isNull(portletId)) { for (long companyId : companyIds) { try { LuceneIndexer indexer = new LuceneIndexer(companyId); indexer.reindex(); } catch (Exception e) { _log.error(e, e); } } } else { Portlet portlet = PortletLocalServiceUtil.getPortletById(companyIds[0], portletId); if (portlet == null) { return; } List<Indexer> indexers = portlet.getIndexerInstances(); if (indexers == null) { return; } for (Indexer indexer : indexers) { for (long companyId : companyIds) { ShardUtil.pushCompanyService(companyId); try { SearchEngineUtil.deletePortletDocuments(companyId, portletId); indexer.reindex(new String[] { String.valueOf(companyId) }); } catch (Exception e) { _log.error(e, e); } ShardUtil.popCompanyService(); } } } if (LuceneHelperUtil.isLoadIndexFromClusterEnabled()) { Address localClusterNodeAddress = ClusterExecutorUtil.getLocalClusterNodeAddress(); ClusterRequest clusterRequest = ClusterRequest.createMulticastRequest( new MethodHandler(_loadIndexesFromClusterMethodKey, companyIds, localClusterNodeAddress), true); ClusterExecutorUtil.execute(clusterRequest); return; } }