Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tron-explore
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张建华@五瓣科技
tron-explore
Commits
e27a57dd
Commit
e27a57dd
authored
Dec 29, 2020
by
jianhua.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
统计区块大小、交易数功能调整
parent
ef3a0a68
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
11 deletions
+38
-11
CensusDataFetcher.java
.../java/com/wuban/tron/explore/fetch/CensusDataFetcher.java
+31
-7
PersistThreadPoolV2.java
...ava/com/wuban/tron/explore/fetch/PersistThreadPoolV2.java
+2
-2
TransactionServiceImpl.java
...ban/tron/explore/service/impl/TransactionServiceImpl.java
+5
-2
No files found.
src/main/java/com/wuban/tron/explore/fetch/CensusDataFetcher.java
View file @
e27a57dd
...
...
@@ -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
);
}
...
...
src/main/java/com/wuban/tron/explore/fetch/PersistThreadPoolV2.java
View file @
e27a57dd
...
...
@@ -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
,
1
0L
,
TimeUnit
.
SECONDS
,
executors
.
add
(
new
ThreadPoolExecutor
(
POLL_SIZE
*
3
,
POLL_SIZE
*
5
,
3
0L
,
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
()
{
...
...
src/main/java/com/wuban/tron/explore/service/impl/TransactionServiceImpl.java
View file @
e27a57dd
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment