1:新增webFocusDb业务
2:修改编译配置对doblacklist,exprType的校验值 3:新增从clickhouse查询流量统计的controller,service,dao等 4:新增对maat类配置支持停启用
This commit is contained in:
@@ -901,8 +901,8 @@ public class CompileVal {
|
||||
"编译配置id为" + compileId + "的配置中service的值为" + configCompile.getService() + "时action只能为" + action,
|
||||
RestBusinessCode.ServiceUnmatchAction.getValue());
|
||||
}
|
||||
if (configCompile.getDoBlacklist() != 1) {
|
||||
throw new RestServiceException("编译配置id为" + compileId + "的配置中doBlacklist的值只能是1",
|
||||
if (configCompile.getDoBlacklist() != 1&&configCompile.getDoBlacklist() != 0) {
|
||||
throw new RestServiceException("编译配置id为" + compileId + "的配置中doBlacklist的值只能是1或0",
|
||||
RestBusinessCode.DoBlacklistIsWrongRange.getValue());
|
||||
}
|
||||
|
||||
@@ -923,12 +923,12 @@ public class CompileVal {
|
||||
|
||||
public static void serviceStrRegionVal(StrRegion strRegion, Long compileId, boolean isDirtrict) throws Exception {
|
||||
|
||||
Integer exprType = strRegion.getExprType();
|
||||
Integer exprType= strRegion.getExprType();
|
||||
Integer matchMethod = strRegion.getMatchMethod();
|
||||
Integer isHexbin = strRegion.getIsHexbin();
|
||||
if (exprType != 0 && exprType != 1) {
|
||||
if (exprType != 0 && exprType != 1 && exprType != 3) {
|
||||
throw new RestServiceException("编译配置id为" + compileId + "的配置中strRegionList中regionId为"
|
||||
+ strRegion.getRegionId() + "的域配置exprType的值只能是0(无表达式)或者1(与表达式)",
|
||||
+ strRegion.getRegionId() + "的域配置exprType的值只能是0(无表达式)或者1(与表达式)或者3(偏移表达式)",
|
||||
RestBusinessCode.ExprTypeIsWrongRange.getValue());
|
||||
}
|
||||
if (matchMethod != 0 && matchMethod != 1 && matchMethod != 2 && matchMethod != 3) {
|
||||
|
||||
@@ -233,4 +233,11 @@ public final class Constants {
|
||||
|
||||
|
||||
|
||||
//阀门库db
|
||||
public static final int TAPREDISDB = Configurations.getIntProperty("tapRedisDb", 5);
|
||||
//webfocus库db
|
||||
public static final int WEBFOCUSREDISDB = Configurations.getIntProperty("webFocusDb", 7);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,19 +6,18 @@ import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
|
||||
public class JedisUtils {
|
||||
private static Logger logger = LoggerFactory.getLogger(JedisUtils.class);
|
||||
private static final JedisPool jedisPool = SpringContextHolder.getBean(JedisPool.class);
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
*
|
||||
@@ -213,13 +212,15 @@ public class JedisUtils {
|
||||
* @throws JedisException
|
||||
*/
|
||||
public static Jedis getResource(int redisDb) throws JedisException {
|
||||
Jedis jedis = null;
|
||||
if (jedisPool == null) {
|
||||
JedisSentinelPool jedisSentinelPool = SpringContextHolder.getBean(JedisSentinelPool.class);
|
||||
|
||||
if (jedisSentinelPool == null) {
|
||||
throw new ServiceRuntimeException("redis连接池为空,请联系管理员检查程序",
|
||||
RestBusinessCode.CannotConnectionRedis.getValue());
|
||||
}
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
jedis = jedisSentinelPool.getResource();
|
||||
jedis.select(redisDb);
|
||||
} catch (JedisException e) {
|
||||
returnBrokenResource(jedis);
|
||||
|
||||
@@ -56,11 +56,14 @@ public class ServiceAndRDBIndexReal {
|
||||
* Map<service,Map<regionType,fields>>
|
||||
*/
|
||||
private static Map<Integer, Map<String, String[]>> maatToValveMap = new HashMap<Integer, Map<String, String[]>>();
|
||||
|
||||
|
||||
/**
|
||||
* 阀门保存的redis数据库Index,在nis.properties中定义
|
||||
* 保存maat分发到webFocus需要添加到域的属性:maat2WebFocus
|
||||
* Map<service,Map<regionType,fields>>
|
||||
*/
|
||||
private static Integer valveDBIndex = Configurations.getIntProperty("tapRedisDb", 5);
|
||||
private static Map<Integer, Map<String, String[]>> maatToWebFocusMap = new HashMap<Integer, Map<String, String[]>>();
|
||||
|
||||
static {
|
||||
|
||||
String unMaatService = Configurations.getStringProperty("unMaatService", "");
|
||||
@@ -130,7 +133,7 @@ public class ServiceAndRDBIndexReal {
|
||||
}
|
||||
}
|
||||
|
||||
String maat2Valve = Configurations.getStringProperty("maat2Valve", "");
|
||||
String maat2Valve= Configurations.getStringProperty("maat2Valve", "");
|
||||
if (maat2Valve != null && !maat2Valve.trim().equals("")) {
|
||||
String[] maat2ValveAry = maat2Valve.split(";");
|
||||
for (String maat2ValveStr : maat2ValveAry) {
|
||||
@@ -154,6 +157,29 @@ public class ServiceAndRDBIndexReal {
|
||||
}
|
||||
}
|
||||
}
|
||||
String maat2WebFocus = Configurations.getStringProperty("maat2WebFocus", "");
|
||||
if (maat2WebFocus != null && !maat2WebFocus.trim().equals("")) {
|
||||
String[] maat2ValveAry = maat2WebFocus.split(";");
|
||||
for (String maat2ValveStr : maat2ValveAry) {
|
||||
String[] serviceAndRegion = maat2ValveStr.split(":");
|
||||
if (serviceAndRegion != null && serviceAndRegion.length == 2) {
|
||||
String[] regionAndFields = serviceAndRegion[1].split("@");
|
||||
Map<String, String[]> fieldMap = new HashMap<String, String[]>();
|
||||
String[] fields = regionAndFields[1].split("&");
|
||||
// 同一service有不同的域类型,多个之间用“|”分隔
|
||||
if (regionAndFields[0].contains("|")) {
|
||||
String[] regionTypeAry = regionAndFields[0].split("\\|");
|
||||
for (String regionType : regionTypeAry) {
|
||||
fieldMap.put(regionType, fields);
|
||||
}
|
||||
} else {
|
||||
fieldMap.put(regionAndFields[0], fields);
|
||||
}
|
||||
maatToWebFocusMap.put(Integer.parseInt(serviceAndRegion[0]), fieldMap);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String serviceRepeatedReal = Configurations.getStringProperty("serviceRepeatedReal", "");
|
||||
if (!StringUtil.isEmpty(serviceRepeatedReal)) {
|
||||
@@ -351,6 +377,7 @@ public class ServiceAndRDBIndexReal {
|
||||
return isValve;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据业务类型获取unmaat配置表名
|
||||
* @param service
|
||||
@@ -391,20 +418,20 @@ public class ServiceAndRDBIndexReal {
|
||||
ServiceAndRDBIndexReal.maatToValveMap = maatToValveMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param valveDBIndex the valveDBIndex to set
|
||||
*/
|
||||
public static void setValveDBIndex(Integer valveDBIndex) {
|
||||
ServiceAndRDBIndexReal.valveDBIndex = valveDBIndex;
|
||||
|
||||
|
||||
|
||||
|
||||
public static Map<Integer, Map<String, String[]>> getMaatToWebFocusMap() {
|
||||
return maatToWebFocusMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the valveDBIndex
|
||||
*/
|
||||
public static Integer getValveDBIndex() {
|
||||
return valveDBIndex;
|
||||
public static void setMaatToWebFocusMap(Map<Integer, Map<String, String[]>> maatToWebFocusMap) {
|
||||
ServiceAndRDBIndexReal.maatToWebFocusMap = maatToWebFocusMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Map<Integer, String> getUnMaatSercieNameMap() {
|
||||
return unMaatSercieNameMap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user