Commit e27a57dd authored by jianhua.zhang's avatar jianhua.zhang

统计区块大小、交易数功能调整

parent ef3a0a68
......@@ -36,23 +36,47 @@ public class CensusDataFetcher<T> extends AbstractJob implements ICensusDataFetc
List<Census> dataList = new ArrayList<>();
try {
// Redis 获取区块大小
String blockSize = this.stringRedisTemplate.opsForList().rightPop(Constant.CENSUS_BLOCK_SIZE);
Long blockSize = 0L;
Long transNumber = 0L;
// Redis 获取交易数量
String transNumber = this.stringRedisTemplate.opsForList().rightPop(Constant.CENSUS_TRANS);
String blockSizeStr = null;
String transNumberStr = null;
for (int i = 0; i < 3; i++) {
// Redis 获取区块大小
/*blockSizeStr = this.stringRedisTemplate.opsForList().rightPop(Constant.CENSUS_BLOCK_SIZE);
if (blockSizeStr != null) {
blockSize = blockSize + Long.valueOf(blockSizeStr);
}*/
// Redis 获取交易数量
String res = this.stringRedisTemplate.opsForList().rightPop(Constant.CENSUS_TRANS);
if (res != null) {
transNumberStr = res.split(",")[0];
blockSizeStr = res.split(",")[1];
transNumber = transNumber + Long.valueOf(transNumberStr);
blockSize = blockSize + Long.valueOf(blockSizeStr);
}
}
Census census = new Census();
boolean flag = false;
if (!StringUtils.isEmpty(blockSize)) {
if (blockSize != 0) {
flag = true;
census.setTotalBlockSize(blockSize);
}
if (transNumber != 0) {
flag = true;
census.setTotalTrans(transNumber);
}
/*if (!StringUtils.isEmpty(blockSize)) {
flag = true;
census.setTotalBlockSize(Long.valueOf(blockSize));
}
if (!StringUtils.isEmpty(transNumber)) {
flag = true;
census.setTotalTrans(Long.valueOf(transNumber));
}
}*/
if (flag) {
dataList.add(census);
}
......
......@@ -26,10 +26,10 @@ public class PersistThreadPoolV2 {
private PersistThreadPoolV2() {
for (int i = 0; i < POLL_SIZE; i++) {
executors.add(new ThreadPoolExecutor(POLL_SIZE * 3, POLL_SIZE * 3, 10L, TimeUnit.SECONDS,
executors.add(new ThreadPoolExecutor(POLL_SIZE * 3, POLL_SIZE * 5, 30L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new PersistThreadFactory(i)));
}
log.info("数据持久化-线程池 name:{} coreSize:{} maxSize:{}", "PersistThreadPool", POLL_SIZE * 3, POLL_SIZE * POLL_SIZE * 3);
log.info("数据持久化-线程池 name:{} coreSize:{} maxSize:{}", "PersistThreadPool", POLL_SIZE * 3, POLL_SIZE * 5);
}
public static PersistThreadPoolV2 getInstance() {
......
......@@ -301,8 +301,11 @@ public class TransactionServiceImpl implements TransactionService {
* @param transNumber
*/
private void censusFlushRedis(String blockSize, Integer transNumber) {
this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_BLOCK_SIZE, blockSize);
this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_TRANS, transNumber.toString());
//this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_BLOCK_SIZE, blockSize);
long res = this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_TRANS, transNumber.toString() + "," + blockSize);
if (res == 0) {
this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_TRANS, transNumber.toString() + "," + blockSize);
}
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment