提交 6bcdb33e 编写于 作者: xuhui961310148's avatar xuhui961310148

update:saveResultsMQMsg2方法保存数据值cql打印错误日志

上级 2bd5f95a
package cn.ibizlab.core.extensions.cql;
import cn.ibizlab.core.extensions.domain.ResultsMQMsg;
import com.alibaba.fastjson.JSONObject;
import com.datastax.driver.core.*;
import com.datastax.driver.core.schemabuilder.SchemaBuilder;
import com.datastax.driver.mapping.Mapper;
......@@ -161,6 +162,10 @@ public class ExecResultRepository {
public void saveResultsMQMsg2(ResultsMQMsg resultsMQMsg){
log.info("--saveResultsMQMsg2--");
try {
if (resultsMQMsg == null){
log.error("-saveResultsMQMsg2--入参resultsMQMsg为空!");
return;
}
List<ExecResult> results = resultsMQMsg.getDatas();
if(deleteInvalidResultData) {
final ResultSet result = session.execute(select().all().from(TABLE2).where(in("ruleid", resultsMQMsg.getRules())).and(eq("keyvaluefield", resultsMQMsg.getKeyValueField())));
......@@ -185,16 +190,18 @@ public class ExecResultRepository {
deleteBatch.setConsistencyLevel(ConsistencyLevel.ANY);// 设置一致性
BatchStatement deleteBatch2 = new BatchStatement();
deleteBatch2.setConsistencyLevel(ConsistencyLevel.ANY);// 设置一致性
for (ExecResult2 result2 : list) {
BoundStatement bs = ps.bind(result2.getRuleid(), 1, result2.getDimfield(), result2.getTimefield(), result2.getDomainsfield(), result2.getKeyvaluefield());
BoundStatement bs2 = ps2.bind(result2.getRuleid(), result2.getKeyvaluefield(), result2.getDimfield(), result2.getDomainsfield(), result2.getTimefield());
deleteBatch.add(bs);
deleteBatch2.add(bs2);
if (deleteBatch.size() > batchSize) {
session.execute(deleteBatch);
deleteBatch.clear();
session.execute(deleteBatch2);
deleteBatch2.clear();
if (list != null){
for (ExecResult2 result2 : list) {
BoundStatement bs = ps.bind(result2.getRuleid(), 1, result2.getDimfield(), result2.getTimefield(), result2.getDomainsfield(), result2.getKeyvaluefield());
BoundStatement bs2 = ps2.bind(result2.getRuleid(), result2.getKeyvaluefield(), result2.getDimfield(), result2.getDomainsfield(), result2.getTimefield());
deleteBatch.add(bs);
deleteBatch2.add(bs2);
if (deleteBatch.size() > batchSize) {
session.execute(deleteBatch);
deleteBatch.clear();
session.execute(deleteBatch2);
deleteBatch2.clear();
}
}
}
if (deleteBatch.size() > 0) {
......@@ -204,12 +211,20 @@ public class ExecResultRepository {
deleteBatch2.clear();
}
}
//保存数据
for (ExecResult execResult : results) {
save(execResult);
if (results != null && results.size() > 0) {
//保存数据
for (ExecResult execResult : results) {
save(execResult);
}
}
} catch (Exception e){
log.error("cassandra保存错误原因:" + e.getMessage());
e.printStackTrace();
try{
log.error("cassandra保存错误原因:" + e.getMessage() + ",输入内容 :" + JSONObject.toJSONString(resultsMQMsg));
}catch (Exception e1){
e1.printStackTrace();
log.error("cassandra保存错误原因打印失败,原因:" + e1.getMessage());
}
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册