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 LuceneHelperUtil.loadIndexesFromCluster(companyId);
034 }
035
036 public static void loadIndexesFromCluster(
037 long[] companyIds, Address bootupAddress) {
038
039 if (bootupAddress == null) {
040 return;
041 }
042
043 if (_log.isInfoEnabled()) {
044 _log.info(
045 "Start loading Lucene index files from cluster node " +
046 bootupAddress);
047 }
048
049 InputStream inputStream = null;
050
051 for (long companyId : companyIds) {
052 try {
053 inputStream =
054 LuceneHelperUtil.getLoadIndexesInputStreamFromCluster(
055 companyId, bootupAddress);
056
057 LuceneHelperUtil.loadIndex(companyId, inputStream);
058 }
059 catch (SystemException se) {
060 throw se;
061 }
062 catch (IOException ioe) {
063 throw new SystemException(ioe);
064 }
065 finally {
066 if (inputStream != null) {
067 try {
068 inputStream.close();
069 }
070 catch (IOException ioe) {
071 throw new SystemException(ioe);
072 }
073 }
074 }
075 }
076 }
077
078 private static final Log _log = LogFactoryUtil.getLog(
079 LuceneClusterUtil.class);
080
081 }