|
@@ -8,7 +8,9 @@ import com.jjt.common.enums.SyncType;
|
|
|
import com.jjt.common.utils.CompressZip;
|
|
|
import com.jjt.common.utils.DateUtils;
|
|
|
import com.jjt.common.utils.LinuxCommand;
|
|
|
+import com.jjt.out.domain.OutProcessInfo;
|
|
|
import com.jjt.out.service.IOutEsService;
|
|
|
+import com.jjt.out.service.IOutProcessInfoService;
|
|
|
import com.jjt.system.service.ISysConfigService;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.http.HttpEntity;
|
|
@@ -37,6 +39,7 @@ import java.io.IOException;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -50,6 +53,8 @@ public class OutEsServiceImpl extends OutBaseService implements IOutEsService {
|
|
|
private static final Logger log = LoggerFactory.getLogger(OutEsServiceImpl.class);
|
|
|
@Resource
|
|
|
private ISysConfigService sysConfigService;
|
|
|
+ @Resource
|
|
|
+ private IOutProcessInfoService processInfoService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -107,6 +112,12 @@ public class OutEsServiceImpl extends OutBaseService implements IOutEsService {
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
+ OutProcessInfo opi = new OutProcessInfo();
|
|
|
+ opi.setProcessType(SyncType.es.toString());
|
|
|
+ Date st = new Date();
|
|
|
+ opi.setCreateTime(st);
|
|
|
+ opi.setProcessKey(String.valueOf(st.getTime()));
|
|
|
+
|
|
|
|
|
|
IndexDO ido = getIndexInfo(index);
|
|
|
String uri = scheme + "://" + hostname + ":" + port + "/" + index;
|
|
@@ -171,6 +182,10 @@ public class OutEsServiceImpl extends OutBaseService implements IOutEsService {
|
|
|
} catch (IOException e) {
|
|
|
}
|
|
|
//生成描述json文件--end
|
|
|
+
|
|
|
+ Date et = new Date();
|
|
|
+ opi.setCostTime(et.getTime() - st.getTime());
|
|
|
+ processInfoService.insertOutProcessInfo(opi);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -178,6 +193,11 @@ public class OutEsServiceImpl extends OutBaseService implements IOutEsService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void clean() {
|
|
|
+ //如果是增量,需要获取时间戳
|
|
|
+ OutProcessInfo pi = new OutProcessInfo();
|
|
|
+ pi.setProcessType(SyncType.es.toString());
|
|
|
+ List<OutProcessInfo> list = processInfoService.selectOutProcessInfoList(pi);
|
|
|
+ String time = list.get(0).getProcessKey();
|
|
|
String params = sysConfigService.selectConfigByKey("out.es.connect");
|
|
|
JSONObject jsonObject = JSONObject.parseObject(params);
|
|
|
String index = jsonObject.getString("index");
|
|
@@ -188,7 +208,10 @@ public class OutEsServiceImpl extends OutBaseService implements IOutEsService {
|
|
|
builder = JsonXContent.contentBuilder()
|
|
|
.startObject()
|
|
|
.startObject("query")
|
|
|
- .startObject("match_all")
|
|
|
+ .startObject("range")
|
|
|
+ .startObject("time")
|
|
|
+ .field("lte", Long.parseLong(time))
|
|
|
+ .endObject()
|
|
|
.endObject()
|
|
|
.endObject()
|
|
|
.endObject();
|