001
014
015 package com.liferay.portal.search.lucene.cluster;
016
017 import com.liferay.portal.kernel.cluster.Address;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021 import com.liferay.portal.search.lucene.LuceneHelperUtil;
022
023 import java.io.IOException;
024 import java.io.InputStream;
025
026
030 public class LuceneClusterUtil {
031
032 public static void loadIndexesFromCluster(long companyId)
033 throws SystemException {
034
035 LuceneHelperUtil.loadIndexesFromCluster(companyId);
036 }
037
038 public static void loadIndexesFromCluster(
039 long[] companyIds, Address bootupAddress)
040 throws SystemException {
041
042 if (bootupAddress == null) {
043 return;
044 }
045
046 if (_log.isInfoEnabled()) {
047 _log.info(
048 "Start loading Lucene index files from cluster node " +
049 bootupAddress);
050 }
051
052 InputStream inputStream = null;
053
054 for (long companyId : companyIds) {
055 try {
056 inputStream =
057 LuceneHelperUtil.getLoadIndexesInputStreamFromCluster(
058 companyId, bootupAddress);
059
060 LuceneHelperUtil.loadIndex(companyId, inputStream);
061 }
062 catch (SystemException se) {
063 throw se;
064 }
065 catch (IOException ioe) {
066 throw new SystemException(ioe);
067 }
068 finally {
069 if (inputStream != null) {
070 try {
071 inputStream.close();
072 }
073 catch (IOException ioe) {
074 throw new SystemException(ioe);
075 }
076 }
077 }
078 }
079 }
080
081 private static Log _log = LogFactoryUtil.getLog(LuceneClusterUtil.class);
082
083 }