1:修改证书类配置的表达式删除最后面的\n

2:修改redis连接池信息
3:修改获取配置id的方式,改为从程序中遍历,从redis中太耗时了
4:添加单独添加域,删除域使用多线程的方法
This commit is contained in:
renkaige
2018-11-14 19:29:35 +08:00
parent ad41ff768f
commit 996a780c3c
14 changed files with 934 additions and 55 deletions

View File

@@ -211,4 +211,6 @@ public final class Constants {
*是否使用Minio
*/
public static final Boolean IS_USE_MINIO = Configurations.getBooleanProperty("isUseMinio", true);
public static final int MAXTHREADNUM = Configurations.getIntProperty("maxThreadNum", 10);
public static final int EVERTHREADNUM = Configurations.getIntProperty("everThreadNum", 10000);
}

View File

@@ -17,10 +17,11 @@ import com.nis.web.service.SpringContextHolder;
public class JedisUtils {
private static Logger logger = LoggerFactory.getLogger(JedisUtils.class);
private static JedisPool jedisPool = SpringContextHolder.getBean(JedisPool.class);
/**
* 获取缓存
* @param key 键
*
* @param key
* 键
* @return 值
*/
public static String get(String key, int redisDb) {
@@ -34,7 +35,8 @@ public class JedisUtils {
logger.debug("get {} = {}", key, value);
}
} catch (Exception e) {
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取" + key + "对应的值失败", RestBusinessCode.KeyNotExistsInRedis.getValue());
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取" + key + "对应的值失败",
RestBusinessCode.KeyNotExistsInRedis.getValue());
} finally {
returnResource(jedis);
}
@@ -43,7 +45,9 @@ public class JedisUtils {
/**
* 获取缓存
* @param key 键
*
* @param key
* 键
* @return 值
*/
public static Object getObject(String key, int redisDb) {
@@ -56,7 +60,8 @@ public class JedisUtils {
logger.debug("getObject {} = {}", key, value);
}
} catch (Exception e) {
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取" + key + "对应的值失败", RestBusinessCode.KeyNotExistsInRedis.getValue());
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取" + key + "对应的值失败",
RestBusinessCode.KeyNotExistsInRedis.getValue());
} finally {
returnResource(jedis);
}
@@ -64,14 +69,15 @@ public class JedisUtils {
}
/**
* <b>可以作为获取唯一id的方法</b><br/>
* 将key对应的value加上指定的值只有value可以转为数字时该方法才可用
*
* @param String
* key
* @param long number 要减去的值
* @return long 相加后的值
* */
* <b>可以作为获取唯一id的方法</b><br/>
* 将key对应的value加上指定的值只有value可以转为数字时该方法才可用
*
* @param String
* key
* @param long
* number 要减去的值
* @return long 相加后的值
*/
public static long incrBy(String key, long number, int redisDb) {
Jedis jedis = getResource(redisDb);
long len = jedis.incrBy(key, number);
@@ -81,9 +87,13 @@ public class JedisUtils {
/**
* 设置缓存
* @param key 键
* @param value 值
* @param cacheSeconds 超时时间0为不超时
*
* @param key
*
* @param value
* 值
* @param cacheSeconds
* 超时时间0为不超时
* @return
*/
public static String set(String key, String value, int cacheSeconds, int redisDb) {
@@ -97,7 +107,8 @@ public class JedisUtils {
}
logger.debug("set {} = {}", key, value);
} catch (Exception e) {
throw new ServiceRuntimeException("" + redisDb + "号redisDB中设置zset失败,key=" + key + ",value=" + value, RestBusinessCode.ZsetFailed.getValue());
throw new ServiceRuntimeException("" + redisDb + "号redisDB中设置zset失败,key=" + key + ",value=" + value,
RestBusinessCode.ZsetFailed.getValue());
} finally {
returnResource(jedis);
}
@@ -106,7 +117,9 @@ public class JedisUtils {
/**
* 获取List缓存
* @param key 键
*
* @param key
* 键
* @return 值
*/
public static List<String> getList(String key, int redisDb) {
@@ -119,7 +132,8 @@ public class JedisUtils {
logger.debug("getList {} = {}", key, value);
}
} catch (Exception e) {
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取" + key + "对应的值失败", RestBusinessCode.KeyNotExistsInRedis.getValue());
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取" + key + "对应的值失败",
RestBusinessCode.KeyNotExistsInRedis.getValue());
} finally {
returnResource(jedis);
}
@@ -128,7 +142,9 @@ public class JedisUtils {
/**
* 获取List缓存
* @param key 键
*
* @param key
* 键
* @return 值
*/
public static List<Object> getObjectList(String key, int redisDb) {
@@ -145,7 +161,8 @@ public class JedisUtils {
logger.debug("getObjectList {} = {}", key, value);
}
} catch (Exception e) {
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取" + key + "对应的值失败", RestBusinessCode.KeyNotExistsInRedis.getValue());
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取" + key + "对应的值失败",
RestBusinessCode.KeyNotExistsInRedis.getValue());
} finally {
returnResource(jedis);
}
@@ -154,7 +171,9 @@ public class JedisUtils {
/**
* 缓存是否存在
* @param key 键
*
* @param key
* 键
* @return
*/
public static boolean exists(String key, int redisDb) {
@@ -165,7 +184,8 @@ public class JedisUtils {
result = jedis.exists(key);
logger.debug("exists {}", key);
} catch (Exception e) {
throw new ServiceRuntimeException("" + redisDb + "号redisDB中判断" + key + "是否存在失败", RestBusinessCode.ExistsKeyFailed.getValue());
throw new ServiceRuntimeException("" + redisDb + "号redisDB中判断" + key + "是否存在失败",
RestBusinessCode.ExistsKeyFailed.getValue());
} finally {
returnResource(jedis);
}
@@ -174,7 +194,9 @@ public class JedisUtils {
/**
* 缓存是否存在
* @param key 键
*
* @param key
* 键
* @return
*/
public static boolean existsObject(String key, int redisDb) {
@@ -185,7 +207,8 @@ public class JedisUtils {
result = jedis.exists(getBytesKey(key));
logger.debug("existsObject {}", key);
} catch (Exception e) {
throw new ServiceRuntimeException("" + redisDb + "号redisDB中判断" + key + "是否存在失败", RestBusinessCode.ExistsKeyFailed.getValue());
throw new ServiceRuntimeException("" + redisDb + "号redisDB中判断" + key + "是否存在失败",
RestBusinessCode.ExistsKeyFailed.getValue());
} finally {
returnResource(jedis);
}
@@ -194,20 +217,24 @@ public class JedisUtils {
/**
* 获取资源
*
* @return
* @throws JedisException
*/
public static Jedis getResource(int redisDb) throws JedisException {
Jedis jedis = null;
if (jedisPool == null) {
throw new ServiceRuntimeException("redis连接池为空,请联系管理员检查程序",RestBusinessCode.CannotConnectionRedis.getValue());
throw new ServiceRuntimeException("redis连接池为空,请联系管理员检查程序",
RestBusinessCode.CannotConnectionRedis.getValue());
}
try {
jedis = jedisPool.getResource();
jedis.select(redisDb);
} catch (JedisException e) {
returnBrokenResource(jedis);
throw new ServiceRuntimeException("获取redis连接失败,请联系管理员检查程序", RestBusinessCode.CannotConnectionRedis.getValue());
logger.error("获取redis连接失败,异常信息:{}" ,ExceptionUtil.getExceptionMsg(e));
throw new ServiceRuntimeException("获取redis连接失败,请联系管理员检查程序",
RestBusinessCode.CannotConnectionRedis.getValue());
}
return jedis;
@@ -215,6 +242,7 @@ public class JedisUtils {
/**
* 归还资源
*
* @param jedis
* @param isBroken
*/
@@ -226,6 +254,7 @@ public class JedisUtils {
/**
* 释放资源
*
* @param jedis
* @param isBroken
*/
@@ -237,6 +266,7 @@ public class JedisUtils {
/**
* 获取byte[]类型Key
*
* @param key
* @return
*/
@@ -250,6 +280,7 @@ public class JedisUtils {
/**
* Object转换byte[]类型
*
* @param key
* @return
*/
@@ -259,6 +290,7 @@ public class JedisUtils {
/**
* byte[]型转换Object
*
* @param key
* @return
*/

View File

@@ -0,0 +1,86 @@
package com.nis.web.service.restful;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.nis.domain.MaatXmlExpr;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Transaction;
public class CommRegionThreadMethod {
private static Logger logger = LoggerFactory.getLogger(CommRegionThreadMethod.class);
protected void updateMaatInfoByPipelined(List<MaatXmlExpr> list, String maatKey, Pipeline pipelined,
Double maatVersion, int redisDBIndex, boolean idDel) {
if (list != null && list.size() > 0) {
for (MaatXmlExpr maatXmlExpr : list) {
if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_UPDATE_STATUS")) {
if (maatKey != null) {
String zset = null;
if (idDel) {
zset = maatKey.replace("OBSOLETE_RULE:", "DEL,");
} else {
zset = maatKey.replace("EFFECTIVE_RULE:", "ADD,");
}
pipelined.zadd("MAAT_UPDATE_STATUS", maatVersion, zset);
logger.info("向{}号redis数据库更新了MAAT_UPDATE_STATUS,内容是{},SCORES是{}", redisDBIndex,
zset.toUpperCase(), maatVersion);
}
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
if (maatKey != null) {
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
pipelined.zadd("MAAT_RULE_TIMER", score, maatKey);
logger.info("向{}号redis数据库更新了MAAT_RULE_TIMER,内容是{},SCORES是{}", redisDBIndex, maatKey, score);
}
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_VERSION_TIMER")) {
Long nowTime = new Date().getTime();
nowTime = nowTime / 1000l;
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
pipelined.zadd("MAAT_VERSION_TIMER", score, maatVersion + "");
logger.info("向{}号redis数据库更新了MAAT_VERSION_TIMER,内容是{},SCORES是{}", redisDBIndex, maatVersion, score);
}
}
}
}
protected void updateMaatInfo(List<MaatXmlExpr> list, String maatKey, Transaction transaction, Double maatVersion,
int redisDBIndex, boolean idDel) {
if (list != null && list.size() > 0) {
for (MaatXmlExpr maatXmlExpr : list) {
if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_UPDATE_STATUS")) {
if (maatKey != null) {
String zset = null;
if (idDel) {
zset = maatKey.replace("OBSOLETE_RULE:", "DEL,");
} else {
zset = maatKey.replace("EFFECTIVE_RULE:", "ADD,");
}
transaction.zadd("MAAT_UPDATE_STATUS", maatVersion, zset);
logger.info("向{}号redis数据库更新了MAAT_UPDATE_STATUS,内容是{},SCORES是{}", redisDBIndex,
zset.toUpperCase(), maatVersion);
}
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
if (maatKey != null) {
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
transaction.zadd("MAAT_RULE_TIMER", score, maatKey);
logger.info("向{}号redis数据库更新了MAAT_RULE_TIMER,内容是{},SCORES是{}", redisDBIndex, maatKey, score);
}
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_VERSION_TIMER")) {
Long nowTime = new Date().getTime();
nowTime = nowTime / 1000l;
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
transaction.zadd("MAAT_VERSION_TIMER", score, maatVersion + "");
logger.info("向{}号redis数据库更新了MAAT_VERSION_TIMER,内容是{},SCORES是{}", redisDBIndex, maatVersion, score);
}
}
}
}
}

View File

@@ -8,6 +8,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -21,12 +25,15 @@ import com.nis.domain.restful.MaatConfig;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.ServiceRuntimeException;
import com.nis.util.Configurations;
import com.nis.util.Constants;
import com.nis.util.File2Redis;
import com.nis.util.JedisUtils;
import com.nis.util.ReadMaatXmlUtil;
import com.nis.util.ServiceAndRDBIndexReal;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Response;
import redis.clients.jedis.Transaction;
import redis.clients.jedis.exceptions.JedisConnectionException;
@@ -763,6 +770,12 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
return id;
}
public Long getIncrById(String key, int num) {
Long id = JedisUtils.incrBy(key, num, 0);
logger.info("从0号redis数据库获取{}成功,自增后的值是{}", key, id);
return id;
}
@Override
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap, boolean isInvalid) {
if (idMap != null && idMap.size() > 0) {
@@ -1445,7 +1458,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
}
private void addTmpReion(List<Map<String, String>> regionMapList, MaatXmlConfig maatXmlConfig,
Transaction transaction, int type, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex, Integer service1) {
Transaction transaction, int type, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex ) throws Exception {
if (regionMapList != null && regionMapList.size() > 0) {
for (Map<String, String> map : regionMapList) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
@@ -1569,6 +1583,51 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
}
}
}
}
private void addTmpReionByPipeLine(List<Map<String, String>> regionMapList, MaatXmlConfig maatXmlConfig,
Pipeline pipelined, int type, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex) throws Exception {
if (regionMapList != null && regionMapList.size() > 0) {
int execNum = Constants.MAXTHREADNUM;
// 每10000条数据开启一条线程
int threadSize = Constants.EVERTHREADNUM;
// 总数据条数
int dataSize = regionMapList.size();
// 线程数
int countSize = dataSize / threadSize ;
// 定义标记,过滤threadNum为整数
boolean special = dataSize % threadSize == 0;
if (!special && dataSize > threadSize) {
countSize++;
}
if (countSize < execNum) {
execNum = countSize;
}
// 创建一个线程池
ExecutorService exec = Executors.newFixedThreadPool(execNum);
// 定义一个任务集合
List<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
Callable<Integer> task = null;
List<Map<String, String>> cutList = null;
// 确定每条线程的数据
for (int i = 0; i < countSize; i++) {
cutList = regionMapList.subList(threadSize * i,
threadSize * (i + 1) > dataSize ? dataSize : threadSize * (i + 1));
final List<Map<String, String>> listStr = cutList;
task = new SaveRegionThreadByPipeline(listStr, maatXmlConfig, pipelined, type, tmpStorageReuseRegionDB,
idRelaRedisDBIndex);
// 这里提交的任务容器列表和返回的Future列表存在顺序对应的关系
tasks.add(task);
}
List<Future<Integer>> results;
results = exec.invokeAll(tasks);
// for (Future<Integer> future : results) {
// logger.info("SaveRegionThread添加分组复用域配置线程执行结果:" + future.get());
// }
// 关闭线程池
exec.shutdown();
}
}
/**
@@ -1587,11 +1646,11 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
for (MaatConfig maatConfig : configList) {
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(37);// maat类配置的表达式都一样,这里因为没有service所以就随便取了一个
addTmpReion(maatConfig.getIpRegionMapList(), maatXmlConfig, transaction, 12,
tmpStorageReuseRegionDB, idRelaRedisDBIndex, maatConfig.getService());
tmpStorageReuseRegionDB, idRelaRedisDBIndex );
addTmpReion(maatConfig.getNumRegionMapList(), maatXmlConfig, transaction, 13,
tmpStorageReuseRegionDB, idRelaRedisDBIndex, maatConfig.getService());
tmpStorageReuseRegionDB, idRelaRedisDBIndex );
addTmpReion(maatConfig.getStrRegionMapList(), maatXmlConfig, transaction, 14,
tmpStorageReuseRegionDB, idRelaRedisDBIndex, maatConfig.getService());
tmpStorageReuseRegionDB, idRelaRedisDBIndex );
}
} else {
throw new ServiceRuntimeException("添加分组复用域配置时,未发现对应的配置信息,请检查配置参数是否正确",
@@ -1614,6 +1673,56 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
}
}
public boolean saveGroupReuseConfigByPipeLine(List<MaatConfig> configList) {
Jedis resource = JedisUtils.getResource(0);
Pipeline pipelined = resource.pipelined();
try {
if (configList != null && configList.size() > 0) {
int tmpStorageReuseRegionDB = Configurations.getIntProperty("tmpStorageReuseRegionDB", 15);
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
pipelined.select(tmpStorageReuseRegionDB);
pipelined.multi();
for (MaatConfig maatConfig : configList) {
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(37);// maat类配置的表达式都一样,这里因为没有service所以就随便取了一个
addTmpReionByPipeLine(maatConfig.getIpRegionMapList(), maatXmlConfig, pipelined, 12,
tmpStorageReuseRegionDB, idRelaRedisDBIndex);
addTmpReionByPipeLine(maatConfig.getNumRegionMapList(), maatXmlConfig, pipelined, 13,
tmpStorageReuseRegionDB, idRelaRedisDBIndex);
addTmpReionByPipeLine(maatConfig.getStrRegionMapList(), maatXmlConfig, pipelined, 14,
tmpStorageReuseRegionDB, idRelaRedisDBIndex);
}
} else {
throw new ServiceRuntimeException("添加分组复用域配置时,未发现对应的配置信息,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
Response<List<Object>> exec = pipelined.exec();
pipelined.sync();// 关闭pipeline
// 结束pipeline并开始从相应中获得数据
// List<Object> responses = exec.get();
// if (responses == null || responses.isEmpty()) {
// throw new RuntimeException("Pipeline error: no response...");
// }
// for (Object resp : responses) {
// System.out.println("Response:" + resp.toString());// 注意此处resp的类型为Long
// }
return true;
} catch (JedisConnectionException e) {
String error = "连接redis异常,保存分组复用maat类域配置失败" + e.getMessage();
logger.error(error);
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
} catch (Exception e) {
String error = "保存分组复用maat类域配置发生了异常" + e.getMessage();
logger.error(error);
// pipelined.discard();
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
} finally {
// 释放连接到连接池
JedisUtils.returnResource(resource);
}
}
/**
* 添加分组和域的关联关系
*
@@ -1836,6 +1945,52 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
}
private void removeReuseReionByPipelined(long groupId, List<String> regionList, Pipeline pipelined,
MaatXmlConfig maatXmlConfig, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex) throws Exception {
if (regionList != null && regionList.size() > 0) {
int execNum = Constants.MAXTHREADNUM;
// 每10000条数据开启一条线程
int threadSize = Constants.EVERTHREADNUM;
// 总数据条数
int dataSize = regionList.size();
// 线程数
int countSize = dataSize / threadSize + 1;
// 定义标记,过滤threadNum为整数
boolean special = dataSize % threadSize == 0;
if (!special && dataSize > threadSize) {
countSize++;
}
if (countSize < execNum) {
execNum = countSize;
}
// 创建一个线程池
ExecutorService exec = Executors.newFixedThreadPool(execNum);
// 定义一个任务集合
List<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
Callable<Integer> task = null;
List<String> cutList = null;
// 确定每条线程的数据
for (int i = 0; i < countSize; i++) {
cutList = regionList.subList(threadSize * i,
threadSize * (i + 1) > dataSize ? dataSize : threadSize * (i + 1));
final List<String> listStr = cutList;
task = new DelRegionThreadByPipeline(groupId, listStr, pipelined, maatXmlConfig, tmpStorageReuseRegionDB,
idRelaRedisDBIndex);
// 这里提交的任务容器列表和返回的Future列表存在顺序对应的关系
tasks.add(task);
}
List<Future<Integer>> results;
results = exec.invokeAll(tasks);
for (Future<Integer> future : results) {
logger.info("DelRegionThread删除分组复用域配置线程执行结果:" + future.get());
}
// 关闭线程池
exec.shutdown();
}
}
@Override
public boolean delGroupReuseConfig(Map<Long, List<String>> groupAndRegionMap) {
Jedis resource = JedisUtils.getResource(0);
@@ -1876,6 +2031,52 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
}
}
public boolean delGroupReuseConfigByPipeline(Map<Long, List<String>> groupAndRegionMap) {
Jedis resource = JedisUtils.getResource(0);
Pipeline pipelined = resource.pipelined();
// Transaction transaction = resource.multi();
try {
if (groupAndRegionMap != null && groupAndRegionMap.size() > 0) {
int tmpStorageReuseRegionDB = Configurations.getIntProperty("tmpStorageReuseRegionDB", 15);
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
pipelined.select(tmpStorageReuseRegionDB);
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(37);// maat类配置的表达式都一样,这里因为没有service所以就随便取了一个
for (Long groupId : groupAndRegionMap.keySet()) {
List<String> regionList = groupAndRegionMap.get(groupId);
if (regionList != null && regionList.size() > 0) {
removeReuseReionByPipelined(groupId, regionList, pipelined, maatXmlConfig,
tmpStorageReuseRegionDB, idRelaRedisDBIndex);
} else {
throw new ServiceRuntimeException("删除分组复用域配置时,参数都为空,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
}
Response<List<Object>> exec = pipelined.exec();
pipelined.sync();// 关闭pipeline
return true;
} else {
throw new ServiceRuntimeException("单独删除分组复用配置的域配置时,参数为空,请检查",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
} catch (JedisConnectionException e) {
String error = "连接redis异常,删除分组复用maat类域配置失败" + e.getMessage();
logger.error(error);
// pipelined.discard();
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
} catch (Exception e) {
String error = "删除分组复用maat类域配置发生了异常" + e.getMessage();
logger.error(error);
// pipelined.discard();
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
} finally {
// 释放连接到连接池
JedisUtils.returnResource(resource);
}
}
/**
* 添加和删除时更新MAAT_*状态信息
*
@@ -1917,9 +2118,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
logger.info("向{}号redis数据库更新了MAAT_VERSION_TIMER,内容是{},SCORES是{}", redisDBIndex, maatVersion, score);
}
}
}
}
}

View File

@@ -5,6 +5,7 @@ package com.nis.web.service.restful;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -13,9 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nis.domain.restful.ConfigPzIdSource;
import com.zdjizhi.utils.StringUtil;
import com.nis.web.dao.ConfigPzIdDao;
import com.nis.web.service.BaseLogService;
import com.zdjizhi.utils.StringUtil;
/**
* @ClassName:ConfigPzIdService
@@ -33,26 +34,45 @@ public class ConfigPzIdService extends BaseLogService {
*/
@Autowired
protected ConfigPzIdDao dao;
@Autowired
ConfigRedisService configRedisService;
private static Map<String, String> sourceNameMap = new HashMap<String, String>();
static {
sourceNameMap.put("CONFIG_COMPILE", "SEQ_COMPILEID");
sourceNameMap.put("CONFIG_GROUP", "SEQ_GROUPID");
sourceNameMap.put("CONFIG_REGION", "SEQ_REGIONID");
}
public ConfigPzIdSource getConfigPzIdList(ConfigPzIdSource entity){
public ConfigPzIdSource getConfigPzIdListOld(ConfigPzIdSource entity) {
List<Long> pzIdList = new ArrayList<Long>();
entity.setSourceName(entity.getSourceName().toUpperCase());
String seqName= StringUtil.isEmpty(sourceNameMap.get(entity.getSourceName()))?"SEQ_COMPILEID":sourceNameMap.get(entity.getSourceName());
String seqName = StringUtil.isEmpty(sourceNameMap.get(entity.getSourceName())) ? "SEQ_COMPILEID"
: sourceNameMap.get(entity.getSourceName());
for (int i = 0; i < entity.getNum(); i++) {
// pzIdList.add(dao.getConfigPzIdList(entity)); //直接从数据库序列号获取
// pzIdList.add(dao.getConfigPzIdList(entity)); //直接从数据库序列号获取
pzIdList.add(configRedisService.getIncrId(seqName));
}
entity.setPzIdList(pzIdList);
return entity;
}
public ConfigPzIdSource getConfigPzIdList(ConfigPzIdSource entity) {
List<Long> pzIdList = new LinkedList<Long>();
entity.setSourceName(entity.getSourceName().toUpperCase());
String seqName = StringUtil.isEmpty(sourceNameMap.get(entity.getSourceName())) ? "SEQ_COMPILEID"
: sourceNameMap.get(entity.getSourceName());
long endNum = configRedisService.getIncrById(seqName, entity.getNum());
long startNum=endNum-entity.getNum();
for (long i = endNum; i > startNum; i--) {
// pzIdList.add(dao.getConfigPzIdList(entity)); //直接从数据库序列号获取
pzIdList.add(i);
}
entity.setPzIdList(pzIdList);
return entity;
}
}

View File

@@ -35,6 +35,12 @@ public interface ConfigRedisService {
* @return 成功返回true,失败返回false或抛出异常
*/
public boolean saveGroupReuseConfig( List<MaatConfig> configList);
/**
* 使用pipeline方式,分组复用域配置新增接口,value是配置集合
* @param configList
* @return 成功返回true,失败返回false或抛出异常
*/
public boolean saveGroupReuseConfigByPipeLine( List<MaatConfig> configList);
/**
* 获取指定key的自增长值
@@ -42,6 +48,13 @@ public interface ConfigRedisService {
* @return
*/
public Long getIncrId(String key);
/**
* 批量获取接口,利用java进行遍历,比从redis中自增要快很多
* @param key
* @param num
* @return
*/
public Long getIncrById(String key,int num);
/**
* 删除非maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
@@ -64,5 +77,11 @@ public interface ConfigRedisService {
* @return
*/
public boolean delGroupReuseConfig( Map<Long, List<String>> reuseMap);
/**
* 使用pipeline方式删除分组复用的域配置
* @param reuseMap key是groupId,value是"tableName,regionId"
* @return
*/
public boolean delGroupReuseConfigByPipeline( Map<Long, List<String>> reuseMap);
}

View File

@@ -11,10 +11,13 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sf.json.JSONObject;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -871,6 +874,7 @@ public class ConfigSourcesService extends BaseService {
// 调用接口入redis
logger.info("---------------调用Redis 分组复用配置新增接口---------------------");
configRedisService.saveGroupReuseConfig(list);
// configRedisService.saveGroupReuseConfigByPipeLine(list);
}
/**
@@ -936,6 +940,7 @@ public class ConfigSourcesService extends BaseService {
logger.info("调用接口删除Redis中分组复用的域配置接口");
// 所有的都删除成功返回true
if (!configRedisService.delGroupReuseConfig(reuseMap)) {
// if (!configRedisService.delGroupReuseConfigByPipeline(reuseMap)) {
throw new ServiceRuntimeException("删除分组利用域配置时出现异常,具体原因不详,请联系管理员",
RestBusinessCode.service_runtime_error.getValue());
}

View File

@@ -0,0 +1,126 @@
package com.nis.web.service.restful;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.nis.domain.MaatXmlConfig;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.ServiceRuntimeException;
import com.nis.util.JedisUtils;
import redis.clients.jedis.Pipeline;
public class DelRegionThreadByPipeline extends CommRegionThreadMethod implements Callable<Integer> {
private static Logger logger = LoggerFactory.getLogger(DelRegionThreadByPipeline.class);
long groupId;
List<String> regionList;
Pipeline pipelined;
MaatXmlConfig maatXmlConfig;
int tmpStorageReuseRegionDB;
int idRelaRedisDBIndex;
public DelRegionThreadByPipeline(long groupId, List<String> regionList, Pipeline pipelined, MaatXmlConfig maatXmlConfig,
int tmpStorageReuseRegionDB, int idRelaRedisDBIndex) {
super();
this.groupId = groupId;
this.regionList = regionList;
this.pipelined = pipelined;
this.maatXmlConfig = maatXmlConfig;
this.tmpStorageReuseRegionDB = tmpStorageReuseRegionDB;
this.idRelaRedisDBIndex = idRelaRedisDBIndex;
}
private void removeReuseReionByPipelined(long groupId, List<String> regionList, Pipeline pipelined,
MaatXmlConfig maatXmlConfig, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex) {
if (regionList != null && regionList.size() > 0) {
pipelined.select(tmpStorageReuseRegionDB);
for (String tableAndId : regionList) {
String regionKey = "EFFECTIVE_RULE:" + tableAndId;
if (JedisUtils.exists(regionKey, tmpStorageReuseRegionDB)) {
pipelined.del(regionKey);
String groupStr = "GROUPREGION:" + groupId;
String groupCompileVal = JedisUtils.get(groupStr, idRelaRedisDBIndex);
StringBuffer newGroupRegion = new StringBuffer();
if (groupCompileVal != null && !groupCompileVal.trim().equals("")) {
Set<Integer> redisDBSet = new HashSet<Integer>();
String[] split = groupCompileVal.split(";");
if (split != null && split.length > 0) {
for (String compileStr : split) {
if (compileStr.split("-")[0].equals(regionKey)) {
String[] dbArr = compileStr.split("-")[1].split(",");
for (String db : dbArr) {
if (db != null && !db.trim().equals("")) {
redisDBSet.add(Integer.parseInt(db.trim()));
}
}
if (split.length == 1) {
pipelined.select(idRelaRedisDBIndex);
pipelined.del(groupStr);
}
} else {
newGroupRegion.append(compileStr + ";");
}
}
if (newGroupRegion.length() > 0) {
pipelined.select(idRelaRedisDBIndex);
pipelined.set(groupStr, newGroupRegion.substring(0, newGroupRegion.length() - 1));
}
}
for (Integer redisDb : redisDBSet) {
if (JedisUtils.exists(regionKey, redisDb)) {
pipelined.select(redisDb);
String isValidKey = regionKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
pipelined.rename(regionKey, isValidKey);
String maatVersionStr = JedisUtils.get("MAAT_VERSION", redisDb);
if (maatVersionStr == null) {
maatVersionStr = "0";
}
if (maatVersionStr != null) {
Double maatVersion = Double.valueOf(maatVersionStr) + 1D;
updateMaatInfoByPipelined(maatXmlConfig.getExpressionList(), isValidKey, pipelined,
maatVersion, redisDb, true);
pipelined.incrBy("MAAT_VERSION", 1l);
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDb,
Integer.valueOf(maatVersionStr) + 1);
}
} else {
throw new ServiceRuntimeException(
"" + tmpStorageReuseRegionDB + "号redis库中删除分组复用域配置时,regionKey=" + regionKey
+ "不存在,请检查配置参数是否正确,或redis数据是否正确",
RestBusinessCode.KeyNotExistsInRedis.getValue());
}
}
}
} else {
throw new ServiceRuntimeException("临时存放region的" + tmpStorageReuseRegionDB + "号redis库中regionKey="
+ regionKey + "不存在,请检查配置参数是否正确", RestBusinessCode.KeyNotExistsInRedis.getValue());
}
}
} else {
throw new ServiceRuntimeException("删除分组复用域配置时,参数都为空,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
}
@Override
public Integer call() throws Exception {
removeReuseReionByPipelined(groupId, regionList, pipelined, maatXmlConfig, tmpStorageReuseRegionDB,
idRelaRedisDBIndex);
return 1;
}
}

View File

@@ -0,0 +1,187 @@
package com.nis.web.service.restful;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.nis.domain.MaatXmlConfig;
import com.nis.domain.MaatXmlExpr;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.ServiceRuntimeException;
import com.nis.util.JedisUtils;
import redis.clients.jedis.Transaction;
public class SaveRegionThread extends CommRegionThreadMethod implements Callable<Integer> {
private static Logger logger = LoggerFactory.getLogger(SaveRegionThread.class);
List<Map<String, String>> regionMapList;
MaatXmlConfig maatXmlConfig;
Transaction transaction;
int type;
int tmpStorageReuseRegionDB;
int idRelaRedisDBIndex;
public SaveRegionThread(List<Map<String, String>> regionMapList, MaatXmlConfig maatXmlConfig,
Transaction transaction, int type, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex) {
super();
this.regionMapList = regionMapList;
this.maatXmlConfig = maatXmlConfig;
this.transaction = transaction;
this.type = type;
this.tmpStorageReuseRegionDB = tmpStorageReuseRegionDB;
this.idRelaRedisDBIndex = idRelaRedisDBIndex;
}
private void addTmpReion(List<Map<String, String>> regionMapList, MaatXmlConfig maatXmlConfig,
Transaction transaction, int type, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex) {
if (regionMapList != null && regionMapList.size() > 0) {
for (Map<String, String> map : regionMapList) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
String maatKey = null;
for (MaatXmlExpr maatXmlExpr : expressionList) {
if (type == maatXmlExpr.getType().intValue()) {
StringBuffer keyBF = new StringBuffer();
String[] keySplit = maatXmlExpr.getKeyExpression().split(";");
for (String keyStr : keySplit) {
if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("[")) {
keyStr = keyStr.trim().replace("[", "").replace("]", "");
String keyVal = map.get(keyStr);
if (keyVal != null && !keyVal.equals("")) {
keyBF.append(keyVal);
} else {
throw new ServiceRuntimeException("未从map中获取到" + keyStr + "的值,请检查数据或配置文件是否正确",
RestBusinessCode.NotFoundValueByKey.getValue());
}
} else if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("{")) {
keyStr = keyStr.trim().replace("{", "").replace("}", "");
if (keyStr.toLowerCase().contains("table_name")) {
String argTableName = map.get("table_name");
if (argTableName == null) {
throw new ServiceRuntimeException(
"添加分组复用域配置时,必须要传入表名,请检查参数,配置类型:" + type + ",对应的真实表名",
RestBusinessCode.NotFoundTableName.getValue());
} else {
keyBF.append(argTableName);
}
}
} else {
keyBF.append(keyStr.trim());
}
}
String groupId = null;
StringBuffer valBF = new StringBuffer();
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
for (String valStr : valSplit) {
if (!StringUtils.isEmpty(valStr) && valStr.trim().startsWith("[")) {
valStr = valStr.trim().replace("[", "").replace("]", "");
// if (service != null && service.intValue() == 1028
// && valStr.toLowerCase().equals("op_time") && type == 12) {
if (valStr.toLowerCase().equals("op_time") && type == 12) {
String user_region = map.get("user_region");
valBF.append(user_region + "\t");
}
String val = map.get(valStr);
if (val != null) {
valBF.append(val);
if (valStr.equals("group_id")) {
groupId = val;
}
} else {
// 所有在maat.xml中配置的属性都不可以为空
throw new ServiceRuntimeException(
"未从map中获取到" + valStr + "的值,无法拼接redisValue,请检查数据或配置文件是否正确",
RestBusinessCode.NotFoundValueByKey.getValue());
}
} else if (valStr.equals("&nbsp")) {
valBF.append(" ");
} else if (valStr.equals("\\t")) {// xml中是字符串的\t这里判断的时候需要转义为\\t,但是添加的时候需要添加\t不是\\t
valBF.append("\t");
} else if (valStr.equals("\\n")) {
valBF.append("\n");
} else {
valBF.append(valStr.trim());
}
}
transaction.select(tmpStorageReuseRegionDB);
maatKey = keyBF.toString();
transaction.set(maatKey.toUpperCase(), valBF.toString());
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", tmpStorageReuseRegionDB,
maatKey.toUpperCase(), valBF.toString());
String groupIdStr = "GROUPCOMPILE:" + groupId;
String groupCompileVal = JedisUtils.get(groupIdStr, idRelaRedisDBIndex);
if (groupCompileVal != null && !groupCompileVal.trim().equals("")) {
Set<Integer> redisDBSet = new HashSet<Integer>();
String[] split = groupCompileVal.split(";");
if (split != null && split.length > 0) {
for (String compileStr : split) {
String[] dbArr = compileStr.split("-")[1].split(",");
for (String db : dbArr) {
if (db != null && !db.trim().equals("")) {
redisDBSet.add(Integer.parseInt(db.trim()));
}
}
}
}
String groupRegionStr = "GROUPREGION:" + groupId;
String regionVal = JedisUtils.get(groupIdStr, idRelaRedisDBIndex);
if (regionVal != null && !regionVal.trim().equals("")) {
transaction.append(groupRegionStr, ";" + maatKey.toUpperCase() + "-"
+ redisDBSet.toString().replace("[", "").replace("]", ""));
} else {
transaction.set(groupRegionStr, maatKey.toUpperCase() + "-"
+ redisDBSet.toString().replace("[", "").replace("]", ""));
}
for (Integer redisDb : redisDBSet) {
transaction.select(redisDb);
transaction.set(maatKey.toUpperCase(), valBF.toString());
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", redisDb, maatKey.toUpperCase(),
valBF.toString());
String maatVersionStr = JedisUtils.get("MAAT_VERSION", redisDb);
if (maatVersionStr == null) {
maatVersionStr = "0";
}
if (maatVersionStr != null) {
Double maatVersion = Double.valueOf(maatVersionStr) + 1D;
updateMaatInfo(expressionList, maatKey, transaction, maatVersion, redisDb, false);
transaction.incrBy("MAAT_VERSION", 1l);
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDb,
Integer.valueOf(maatVersionStr) + 1);
}
}
}
}
}
}
}
}
// @Override
// public void run() {
// addTmpReionByPipeLine(regionMapList, maatXmlConfig, pipelined, type,
// tmpStorageReuseRegionDB,
// idRelaRedisDBIndex);
//
// }
@Override
public Integer call() throws Exception {
addTmpReion( regionMapList, maatXmlConfig,
transaction, type, tmpStorageReuseRegionDB, idRelaRedisDBIndex);
return 1;
}
}

View File

@@ -0,0 +1,186 @@
package com.nis.web.service.restful;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.nis.domain.MaatXmlConfig;
import com.nis.domain.MaatXmlExpr;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.ServiceRuntimeException;
import com.nis.util.JedisUtils;
import redis.clients.jedis.Pipeline;
public class SaveRegionThreadByPipeline extends CommRegionThreadMethod implements Callable<Integer>{
private static Logger logger = LoggerFactory.getLogger(SaveRegionThreadByPipeline.class);
List<Map<String, String>> regionMapList;
MaatXmlConfig maatXmlConfig;
Pipeline pipelined;
int type;
int tmpStorageReuseRegionDB;
int idRelaRedisDBIndex;
public SaveRegionThreadByPipeline(List<Map<String, String>> regionMapList, MaatXmlConfig maatXmlConfig,
Pipeline pipelined, int type, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex) {
super();
this.regionMapList = regionMapList;
this.maatXmlConfig = maatXmlConfig;
this.pipelined = pipelined;
this.type = type;
this.tmpStorageReuseRegionDB = tmpStorageReuseRegionDB;
this.idRelaRedisDBIndex = idRelaRedisDBIndex;
}
private void addTmpReionByPipeLine(List<Map<String, String>> regionMapList, MaatXmlConfig maatXmlConfig,
Pipeline pipelined, int type, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex) {
if (regionMapList != null && regionMapList.size() > 0) {
for (Map<String, String> map : regionMapList) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
String maatKey = null;
for (MaatXmlExpr maatXmlExpr : expressionList) {
if (type == maatXmlExpr.getType().intValue()) {
StringBuffer keyBF = new StringBuffer();
String[] keySplit = maatXmlExpr.getKeyExpression().split(";");
for (String keyStr : keySplit) {
if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("[")) {
keyStr = keyStr.trim().replace("[", "").replace("]", "");
String keyVal = map.get(keyStr);
if (keyVal != null && !keyVal.equals("")) {
keyBF.append(keyVal);
} else {
throw new ServiceRuntimeException("未从map中获取到" + keyStr + "的值,请检查数据或配置文件是否正确",
RestBusinessCode.NotFoundValueByKey.getValue());
}
} else if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("{")) {
keyStr = keyStr.trim().replace("{", "").replace("}", "");
if (keyStr.toLowerCase().contains("table_name")) {
String argTableName = map.get("table_name");
if (argTableName == null) {
throw new ServiceRuntimeException(
"添加分组复用域配置时,必须要传入表名,请检查参数,配置类型:" + type + ",对应的真实表名",
RestBusinessCode.NotFoundTableName.getValue());
} else {
keyBF.append(argTableName);
}
}
} else {
keyBF.append(keyStr.trim());
}
}
String groupId = null;
StringBuffer valBF = new StringBuffer();
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
for (String valStr : valSplit) {
if (!StringUtils.isEmpty(valStr) && valStr.trim().startsWith("[")) {
valStr = valStr.trim().replace("[", "").replace("]", "");
// if (service != null && service.intValue() == 1028
// && valStr.toLowerCase().equals("op_time") && type == 12) {
if (valStr.toLowerCase().equals("op_time") && type == 12) {
String user_region = map.get("user_region");
valBF.append(user_region + "\t");
}
String val = map.get(valStr);
if (val != null) {
valBF.append(val);
if (valStr.equals("group_id")) {
groupId = val;
}
} else {
// 所有在maat.xml中配置的属性都不可以为空
throw new ServiceRuntimeException(
"未从map中获取到" + valStr + "的值,无法拼接redisValue,请检查数据或配置文件是否正确",
RestBusinessCode.NotFoundValueByKey.getValue());
}
} else if (valStr.equals("&nbsp")) {
valBF.append(" ");
} else if (valStr.equals("\\t")) {// xml中是字符串的\t这里判断的时候需要转义为\\t,但是添加的时候需要添加\t不是\\t
valBF.append("\t");
} else if (valStr.equals("\\n")) {
valBF.append("\n");
} else {
valBF.append(valStr.trim());
}
}
pipelined.select(tmpStorageReuseRegionDB);
maatKey = keyBF.toString();
pipelined.set(maatKey.toUpperCase(), valBF.toString());
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", tmpStorageReuseRegionDB,
maatKey.toUpperCase(), valBF.toString());
String groupIdStr = "GROUPCOMPILE:" + groupId;
String groupCompileVal = JedisUtils.get(groupIdStr, idRelaRedisDBIndex);
if (groupCompileVal != null && !groupCompileVal.trim().equals("")) {
Set<Integer> redisDBSet = new HashSet<Integer>();
String[] split = groupCompileVal.split(";");
if (split != null && split.length > 0) {
for (String compileStr : split) {
String[] dbArr = compileStr.split("-")[1].split(",");
for (String db : dbArr) {
if (db != null && !db.trim().equals("")) {
redisDBSet.add(Integer.parseInt(db.trim()));
}
}
}
}
String groupRegionStr = "GROUPREGION:" + groupId;
String regionVal = JedisUtils.get(groupIdStr, idRelaRedisDBIndex);
if (regionVal != null && !regionVal.trim().equals("")) {
pipelined.append(groupRegionStr, ";" + maatKey.toUpperCase() + "-"
+ redisDBSet.toString().replace("[", "").replace("]", ""));
} else {
pipelined.set(groupRegionStr, maatKey.toUpperCase() + "-"
+ redisDBSet.toString().replace("[", "").replace("]", ""));
}
for (Integer redisDb : redisDBSet) {
pipelined.select(redisDb);
pipelined.set(maatKey.toUpperCase(), valBF.toString());
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", redisDb, maatKey.toUpperCase(),
valBF.toString());
String maatVersionStr = JedisUtils.get("MAAT_VERSION", redisDb);
if (maatVersionStr == null) {
maatVersionStr = "0";
}
if (maatVersionStr != null) {
Double maatVersion = Double.valueOf(maatVersionStr) + 1D;
updateMaatInfoByPipelined(expressionList, maatKey, pipelined, maatVersion, redisDb,
false);
pipelined.incrBy("MAAT_VERSION", 1l);
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDb,
Integer.valueOf(maatVersionStr) + 1);
}
}
}
}
}
}
}
}
// @Override
// public void run() {
// addTmpReionByPipeLine(regionMapList, maatXmlConfig, pipelined, type, tmpStorageReuseRegionDB,
// idRelaRedisDBIndex);
//
// }
@Override
public Integer call() throws Exception {
addTmpReionByPipeLine(regionMapList, maatXmlConfig, pipelined, type, tmpStorageReuseRegionDB,
idRelaRedisDBIndex);
return 1;
}
}