|
@@ -17,17 +17,16 @@ import java.util.*;
|
|
|
*/
|
|
|
public class DataProcess {
|
|
|
|
|
|
+
|
|
|
private String serviceId;//作为实例化服务对象的Key
|
|
|
private long lastActive; //服务最后活跃时间
|
|
|
private String errorMessage = null; //当前数据输入处理对象不可用信息
|
|
|
private List<Map<String, Object>> calculationLibraryList;//输出计算库
|
|
|
- private static final Map<String, Integer> serviceErrorCount = new HashMap<>(); //服务错误次数:针对脚本异常
|
|
|
+ private final Map<String, Integer> serviceErrorCount = new HashMap<>(); //服务错误次数:针对脚本异常
|
|
|
|
|
|
private final Map<String, ScriptEnginePro> ScriptEngineProMaps = new HashMap<>();//用于缓存当前服务的算法引擎对象,数据库的无需缓存
|
|
|
|
|
|
- private final Map<String, List<String>> columnMaps = new HashMap<>(); //用于缓存对应数据库算法的SQL结构,表名、字段列表、主键
|
|
|
-
|
|
|
- private static final List<String> baseInfo = new ArrayList<>() {{
|
|
|
+ private final List<String> baseInfo = new ArrayList<>() {{
|
|
|
add("serviceId");
|
|
|
add("event");
|
|
|
add("page");
|
|
@@ -104,6 +103,7 @@ public class DataProcess {
|
|
|
return processFail("服务不可用" + errorMessage, null);
|
|
|
}
|
|
|
if (System.currentTimeMillis() - lastActive > 2000) { // 更新数据库中的服务最新活跃时间
|
|
|
+ lastActive = System.currentTimeMillis();//更新最后活跃时间 //------更新当前服务的最后活跃时间,用于服务监控
|
|
|
Runtime.getRuntime().gc();
|
|
|
//更新服务的活跃时间
|
|
|
MyDbHelper myDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.getSystemParams(AppConfig.REMOTE_DB_CONNECT));
|
|
@@ -113,7 +113,6 @@ public class DataProcess {
|
|
|
}
|
|
|
myDbHelper.updateByCondition("update serviceinfo set runState = 1 ,lastactive = now() where serviceID =?", null, serviceId); // 服务表增加最后活跃时间
|
|
|
}
|
|
|
- lastActive = System.currentTimeMillis();//更新最后活跃时间 //------更新当前服务的最后活跃时间,用于服务监控
|
|
|
//创建生命周期ID;//默认继承
|
|
|
if (!inputData.containsKey("dataObjectId")) {
|
|
|
// 生成新的生命周期ID
|
|
@@ -183,7 +182,7 @@ public class DataProcess {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static Map<String, Object> initParam(Map<String, Object> inputData, String event, List<Object> authList) { // authList 转换:left过后的
|
|
|
+ private Map<String, Object> initParam(Map<String, Object> inputData, String event, List<Object> authList) { // authList 转换:left过后的
|
|
|
Object dataContent = inputData.get("dataContent");//这个就是最终的dataContent,所有的变化都是针对它进行
|
|
|
if (Objects.isNull(dataContent)) {//如果为空则默认为inputData中除去常规变量的其它变量,最终可以是一个空Map
|
|
|
Map<String, Object> tempDataContent = new HashMap<>(inputData);//因为inputData并不会发生变化,所以使用浅拷贝即可:
|
|
@@ -208,7 +207,7 @@ public class DataProcess {
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- private static Map<String, Object> createStandardParameters(Map<String, Object> inDataContent, String event, List<Object> authList) {
|
|
|
+ private Map<String, Object> createStandardParameters(Map<String, Object> inDataContent, String event, List<Object> authList) {
|
|
|
Map<String, Object> returnData = new HashMap<>();//创建返回值returnData{}
|
|
|
if ("1,2".contains(event)) {//如果事件是新增或更新则(查询和删除无需处理value)
|
|
|
Object tempValueObject = inDataContent.get("Value");//获取Value----{c1:"123",c2:}
|
|
@@ -240,7 +239,7 @@ public class DataProcess {
|
|
|
return returnData;//返回组建好的参数
|
|
|
}
|
|
|
|
|
|
- private static List<Map<String, Object>> changeSignFilter(Map<String, Object> filterMap, String compare, String connect) {
|
|
|
+ private List<Map<String, Object>> changeSignFilter(Map<String, Object> filterMap, String compare, String connect) {
|
|
|
List<Map<String, Object>> objects = new ArrayList<>();
|
|
|
if (filterMap.containsKey("left")) {
|
|
|
objects.add(filterMap);
|
|
@@ -391,17 +390,17 @@ public class DataProcess {
|
|
|
* @param serviceId
|
|
|
* @param success
|
|
|
*/
|
|
|
- public static void setServiceErrorCount(String location, String serviceId, String success) {
|
|
|
+ public void setServiceErrorCount(String location, String serviceId, String success) {
|
|
|
String key = String.format("processData %s_%s", location, serviceId);
|
|
|
if (!success.equals("0")) {
|
|
|
- Integer errCount = DataProcess.serviceErrorCount.get(key);
|
|
|
+ Integer errCount = serviceErrorCount.get(key);
|
|
|
errCount = (null == errCount) ? 1 : errCount + 1;
|
|
|
- DataProcess.serviceErrorCount.put(key, errCount);
|
|
|
+ serviceErrorCount.put(key, errCount);
|
|
|
if (errCount > AppConfig.SERVICE_ERR_MAX) {
|
|
|
ServiceInputControl.stop(serviceId);
|
|
|
}
|
|
|
} else {
|
|
|
- DataProcess.serviceErrorCount.put(key, 0);
|
|
|
+ serviceErrorCount.put(key, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -425,22 +424,22 @@ public class DataProcess {
|
|
|
/**
|
|
|
* 支持的最大机器id,结果是31 (这个移位算法可以很快计算出几位二进制数所能表示的最大十进制数)
|
|
|
*/
|
|
|
- private final static String maxWorkerId = "4";
|
|
|
+ private final String maxWorkerId = "4";
|
|
|
/**
|
|
|
* 支持的最大数据标识id,结果是31
|
|
|
*/
|
|
|
- private final static String maxServiceId = "4";
|
|
|
+ private final String maxServiceId = "4";
|
|
|
/**
|
|
|
* 毫秒内序列(0~4095)
|
|
|
*/
|
|
|
- private static final Long maxSequence = 999L;
|
|
|
+ private final Long maxSequence = 999L;
|
|
|
|
|
|
- private static long sequence = 0L;
|
|
|
+ private long sequence = 0L;
|
|
|
|
|
|
/**
|
|
|
* 上次生成ID的时间截
|
|
|
*/
|
|
|
- private static long lastTimestamp = -1L;
|
|
|
+ private long lastTimestamp = -1L;
|
|
|
|
|
|
/**
|
|
|
* 生命周期ID生成
|
|
@@ -449,7 +448,7 @@ public class DataProcess {
|
|
|
* @param serviceId
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String createLifeCycleCol(Long workerId, Integer serviceId) {
|
|
|
+ public String createLifeCycleCol(Long workerId, Integer serviceId) {
|
|
|
long timestamp = System.currentTimeMillis();
|
|
|
//如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
|
|
|
//如果是同一时间生成的,则进行毫秒内序列
|
|
@@ -482,7 +481,7 @@ public class DataProcess {
|
|
|
return errorMessage;
|
|
|
}
|
|
|
|
|
|
- public static long getLastTimestamp() {
|
|
|
+ public long getLastTimestamp() {
|
|
|
return lastTimestamp;
|
|
|
}
|
|
|
|
|
@@ -490,15 +489,4 @@ public class DataProcess {
|
|
|
return lastActive;
|
|
|
}
|
|
|
|
|
|
- public List<String> getColumnMaps(String sql) {
|
|
|
- return columnMaps.get(sql);
|
|
|
- }
|
|
|
-
|
|
|
- public void setColumnMaps(String sql, List<String> columnList) {
|
|
|
- columnMaps.put(sql, columnList);
|
|
|
- }
|
|
|
-
|
|
|
- public void clearColumnList(String sql) {
|
|
|
- columnMaps.remove(sql);
|
|
|
- }
|
|
|
}
|