|
|
@@ -41,6 +41,7 @@ import com.uas.search.console.b2b.model.ParsedQueueMessage;
|
|
|
import com.uas.search.console.b2b.service.IndexService;
|
|
|
import com.uas.search.console.b2b.support.IndexWriterManager;
|
|
|
import com.uas.search.console.b2b.util.ClassAndTableNameUtils;
|
|
|
+import com.uas.search.console.b2b.util.FileUtils;
|
|
|
import com.uas.search.console.b2b.util.ObjectToDocumentUtils;
|
|
|
import com.uas.search.console.b2b.util.SearchUtils;
|
|
|
|
|
|
@@ -112,7 +113,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
createIndexesFromFiles(ClassAndTableNameUtils.toClass(tableName));
|
|
|
}
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
+ } catch (Throwable e) {
|
|
|
// 防止SQLRecoverableException导致应用终止
|
|
|
throw new SearchException(e).setDetailedMessage(e);
|
|
|
} finally {
|
|
|
@@ -129,8 +130,9 @@ public class IndexServiceImpl implements IndexService {
|
|
|
* @param clazz
|
|
|
* @return 实际创建的索引的数目
|
|
|
* @throws IOException
|
|
|
+ * @throws InterruptedException
|
|
|
*/
|
|
|
- private <T> Long createIndexes(Class<T> clazz) {
|
|
|
+ private <T> Long createIndexes(Class<T> clazz) throws IOException, InterruptedException {
|
|
|
Long startTime = new Date().getTime();
|
|
|
Table_name tableName = ClassAndTableNameUtils.toTableName(clazz);
|
|
|
logger.info("正在创建" + tableName.value() + "索引...");
|
|
|
@@ -181,8 +183,6 @@ public class IndexServiceImpl implements IndexService {
|
|
|
pageResult = dao.findAll(pageInfo);
|
|
|
}
|
|
|
indexWriter.commit();
|
|
|
- } catch (InterruptedException | IOException e) {
|
|
|
- logger.error("", e);
|
|
|
} finally {
|
|
|
indexWriterManager.release(tableName);
|
|
|
}
|
|
|
@@ -198,9 +198,10 @@ public class IndexServiceImpl implements IndexService {
|
|
|
*
|
|
|
* @param clazz
|
|
|
* @return 实际创建的索引的数目
|
|
|
+ * @throws InterruptedException
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- private <T> Long createIndexesFromFiles(Class<T> clazz) {
|
|
|
+ private <T> Long createIndexesFromFiles(Class<T> clazz) throws InterruptedException, IOException {
|
|
|
Table_name tableName = ClassAndTableNameUtils.toTableName(clazz);
|
|
|
logger.info("正在创建" + tableName.value() + "索引...");
|
|
|
// 数据的总数目
|
|
|
@@ -239,8 +240,6 @@ public class IndexServiceImpl implements IndexService {
|
|
|
indexWriter.commit();
|
|
|
bufferedReader.close();
|
|
|
}
|
|
|
- } catch (IOException | InterruptedException e) {
|
|
|
- logger.error("", e);
|
|
|
} finally {
|
|
|
indexWriterManager.release(tableName);
|
|
|
}
|
|
|
@@ -306,6 +305,10 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
Long startTime = new Date().getTime();
|
|
|
Table_name tableName = ClassAndTableNameUtils.toTableName(clazz);
|
|
|
+ if (fileIndex == 1) {
|
|
|
+ // 删除旧的文件
|
|
|
+ FileUtils.deleteSubFiles(new File(SearchUtils.getDataPath(tableName)));
|
|
|
+ }
|
|
|
logger.info("Download... " + tableName.value());
|
|
|
JpaRepository<T, Long> dao = ClassAndTableNameUtils.getDao(clazz);
|
|
|
|