AE86 před 5 roky
rodič
revize
28d9169906

+ 1 - 1
dbsyncer-connector/src/main/java/org/dbsyncer/connector/database/AbstractDatabaseConnector.java

@@ -256,7 +256,7 @@ public abstract class AbstractDatabaseConnector implements Database {
                 }
             });
             if (0 == update) {
-                throw new ConnectorException(String.format("执行%s操作失败", event));
+                throw new ConnectorException(String.format("执行%s操作失败, 数据不存在", event));
             }
         } catch (Exception e) {
             // 记录错误数据

+ 1 - 1
dbsyncer-storage/src/main/java/org/dbsyncer/storage/lucene/LuceneFactoryTest.java

@@ -37,7 +37,7 @@ public class LuceneFactoryTest {
     }
 
     @After
-    public void tearDown() {
+    public void tearDown() throws IOException {
         shard.close();
     }
 

+ 14 - 9
dbsyncer-storage/src/main/java/org/dbsyncer/storage/lucene/Shard.java

@@ -1,5 +1,6 @@
 package org.dbsyncer.storage.lucene;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer;
 import org.apache.lucene.document.Document;
@@ -7,9 +8,10 @@ import org.apache.lucene.index.*;
 import org.apache.lucene.search.*;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
-import org.dbsyncer.storage.StorageException;
 
+import java.io.File;
 import java.io.IOException;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.*;
 
@@ -20,6 +22,8 @@ import java.util.*;
  */
 public class Shard {
 
+    private File indexPath;
+
     private Directory directory;
 
     private Analyzer analyzer;
@@ -36,7 +40,9 @@ public class Shard {
 
     public Shard(String path) throws IOException {
         // 索引存放的位置,设置在当前目录中
-        directory = FSDirectory.open(Paths.get(path));
+        Path dir = Paths.get(path);
+        indexPath = new File(dir.toUri());
+        directory = FSDirectory.open(dir);
         // 分词器
         analyzer = new SmartChineseAnalyzer();
         // 创建索引写入配置
@@ -80,15 +86,14 @@ public class Shard {
     public void deleteAll() throws IOException {
         indexWriter.deleteAll();
         indexWriter.commit();
+        close();
+        directory.close();
+        FileUtils.deleteDirectory(indexPath);
     }
 
-    public void close() {
-        try {
-            indexWriter.close();
-            indexReader.close();
-        } catch (IOException e) {
-            throw new StorageException(e);
-        }
+    public void close() throws IOException {
+        indexReader.close();
+        indexWriter.close();
     }
 
     public IndexSearcher getSearcher() throws IOException {

+ 0 - 1
dbsyncer-storage/src/main/java/org/dbsyncer/storage/support/DiskStorageServiceImpl.java

@@ -115,7 +115,6 @@ public class DiskStorageServiceImpl extends AbstractStorageService {
             Shard shard = map.get(collectionId);
             if (null != shard) {
                 shard.deleteAll();
-                shard.close();
                 map.remove(collectionId);
             }
         }

+ 1 - 1
dbsyncer-web/src/main/resources/static/js/monitor/index.js

@@ -9,7 +9,7 @@ function bindQueryDataEvent() {
             message: html,
             size: BootstrapDialog.SIZE_NORMAL,
             buttons: [{
-                label: "取消",
+                label: "关闭",
                 action: function (dialog) {
                     dialog.close();
                 }