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

统计区块大小功能调整

parent 2400d4b3
...@@ -53,7 +53,7 @@ public class BlockDataFetcher<T> extends AbstractJob implements IBlockDataFetche ...@@ -53,7 +53,7 @@ public class BlockDataFetcher<T> extends AbstractJob implements IBlockDataFetche
num = Long.valueOf(blockNumStr); num = Long.valueOf(blockNumStr);
TronResponseData data = tronService.getBlockByNum(num); TronResponseData data = tronService.getBlockByNum(num);
if (data != null) { if (data != null) {
log.info("已抓取数据区块高度 num:{}", num); //log.info("已抓取数据区块高度 num:{}", num);
dataList.add(data); dataList.add(data);
} }
} }
......
...@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Slf4j @Slf4j
public class Executor { public class Executor {
private static final int SIZE = 5; private static final int SIZE = 6;
private final List<AbstractJob> jobList = new ArrayList<>(); private final List<AbstractJob> jobList = new ArrayList<>();
private final String name; private final String name;
private ThreadPoolExecutor pool; private ThreadPoolExecutor pool;
......
...@@ -26,10 +26,10 @@ public class PersistThreadPoolV2 { ...@@ -26,10 +26,10 @@ public class PersistThreadPoolV2 {
private PersistThreadPoolV2() { private PersistThreadPoolV2() {
for (int i = 0; i < POLL_SIZE; i++) { for (int i = 0; i < POLL_SIZE; i++) {
executors.add(new ThreadPoolExecutor(POLL_SIZE, POLL_SIZE * 2, 10L, TimeUnit.SECONDS, executors.add(new ThreadPoolExecutor(POLL_SIZE * 3, POLL_SIZE * 3, 10L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new PersistThreadFactory(i))); new LinkedBlockingQueue<>(), new PersistThreadFactory(i)));
} }
log.info("数据持久化-线程池 name:{} coreSize:{} maxSize:{}", "PersistThreadPool", POLL_SIZE * POLL_SIZE, POLL_SIZE * POLL_SIZE * 2); log.info("数据持久化-线程池 name:{} coreSize:{} maxSize:{}", "PersistThreadPool", POLL_SIZE * 3, POLL_SIZE * POLL_SIZE * 3);
} }
public static PersistThreadPoolV2 getInstance() { public static PersistThreadPoolV2 getInstance() {
......
...@@ -108,6 +108,10 @@ public class TransactionServiceImpl implements TransactionService { ...@@ -108,6 +108,10 @@ public class TransactionServiceImpl implements TransactionService {
Set<String> conAddrSet = new HashSet<>(); Set<String> conAddrSet = new HashSet<>();
if (transactionList.size() != 0) { if (transactionList.size() != 0) {
censusTransNumber = transactionList.size(); censusTransNumber = transactionList.size();
// 数据统计
this.censusFlushRedis(censusBlockSize, censusTransNumber);
transactionList.forEach(o -> { transactionList.forEach(o -> {
// hex 数据转换成base58 // hex 数据转换成base58
String ownerAddress; String ownerAddress;
...@@ -149,11 +153,9 @@ public class TransactionServiceImpl implements TransactionService { ...@@ -149,11 +153,9 @@ public class TransactionServiceImpl implements TransactionService {
if (!CollectionUtils.isEmpty(records)) { if (!CollectionUtils.isEmpty(records)) {
this.addressRepository.batchInsertOnDuplicateKey(records); this.addressRepository.batchInsertOnDuplicateKey(records);
} }
addressPushRedis(hexSet); addressPushRedis(hexSet);
conAddrPushRedis(conAddrSet); conAddrPushRedis(conAddrSet);
// 数据统计
this.censusFlushRedis(censusBlockSize, censusTransNumber);
} }
} }
...@@ -299,14 +301,8 @@ public class TransactionServiceImpl implements TransactionService { ...@@ -299,14 +301,8 @@ public class TransactionServiceImpl implements TransactionService {
* @param transNumber * @param transNumber
*/ */
private void censusFlushRedis(String blockSize, Integer transNumber) { private void censusFlushRedis(String blockSize, Integer transNumber) {
String zero = "0"; this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_BLOCK_SIZE, blockSize);
if (!StringUtils.isEmpty(blockSize) && !blockSize.equals(zero)) { this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_TRANS, transNumber.toString());
this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_BLOCK_SIZE, blockSize);
}
if (transNumber != 0) {
this.stringRedisTemplate.opsForList().leftPush(Constant.CENSUS_TRANS, transNumber.toString());
}
} }
@Override @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