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
28547bf2
Commit
28547bf2
authored
Dec 25, 2020
by
jianhua.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tps峰值接口重新调整
parent
f9257399
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
26 deletions
+9
-26
Bootstrapper.java
src/main/java/com/wuban/tron/explore/Bootstrapper.java
+1
-1
Engine.java
src/main/java/com/wuban/tron/explore/fetch/Engine.java
+6
-23
Executor.java
src/main/java/com/wuban/tron/explore/fetch/Executor.java
+1
-1
PersistThreadPoolV2.java
...ava/com/wuban/tron/explore/fetch/PersistThreadPoolV2.java
+1
-1
No files found.
src/main/java/com/wuban/tron/explore/Bootstrapper.java
View file @
28547bf2
...
@@ -44,7 +44,7 @@ public class Bootstrapper {
...
@@ -44,7 +44,7 @@ public class Bootstrapper {
private
ScheduledThreadPoolExecutor
executorService
;
private
ScheduledThreadPoolExecutor
executorService
;
private
void
init
()
{
private
void
init
()
{
this
.
executorService
=
new
ScheduledThreadPoolExecutor
(
2
,
new
ThreadFactory
()
{
this
.
executorService
=
new
ScheduledThreadPoolExecutor
(
1
,
new
ThreadFactory
()
{
private
final
AtomicInteger
threadNumber
=
new
AtomicInteger
(
1
);
private
final
AtomicInteger
threadNumber
=
new
AtomicInteger
(
1
);
@Override
@Override
...
...
src/main/java/com/wuban/tron/explore/fetch/Engine.java
View file @
28547bf2
...
@@ -69,29 +69,12 @@ public class Engine {
...
@@ -69,29 +69,12 @@ public class Engine {
*/
*/
private
ContractEventHandler
contractEventHandler
;
private
ContractEventHandler
contractEventHandler
;
public
static
final
int
BLOCK_FETCHER_NUM
=
2
;
public
static
final
int
BLOCK_FETCHER_NUM
=
1
;
public
static
final
int
BALANCE_FETCHER_NUM
=
2
;
public
static
final
int
BALANCE_FETCHER_NUM
=
1
;
public
Engine
(
String
name
)
{
public
Engine
(
String
name
)
{
this
.
executor
=
new
Executor
(
name
);
this
.
executor
=
new
Executor
(
name
);
this
.
monitor
=
new
Thread
(()
->
{
while
(!
Thread
.
currentThread
().
isInterrupted
())
{
try
{
Thread
.
sleep
(
1000
);
if
(
this
.
handler
!=
null
&&
this
.
handler
.
isShutdown
())
{
log
.
error
(
"{} engine shutdown now restart "
,
name
);
reload
();
}
}
catch
(
final
InterruptedException
e
)
{
log
.
error
(
"{} engine monitor interrupted "
,
name
);
break
;
}
catch
(
final
Exception
e
)
{
log
.
error
(
"{} engine monitor error "
,
name
,
e
);
}
}
},
name
.
concat
(
"_monitor"
));
this
.
monitor
.
start
();
}
}
public
synchronized
void
start
()
{
public
synchronized
void
start
()
{
...
@@ -102,9 +85,9 @@ public class Engine {
...
@@ -102,9 +85,9 @@ public class Engine {
this
.
handler
=
new
BlockDataHandler
();
this
.
handler
=
new
BlockDataHandler
();
this
.
fetcher
=
new
BlockDataFetcher
(
this
.
handler
);
this
.
fetcher
=
new
BlockDataFetcher
(
this
.
handler
);
this
.
executor
.
execute
(
this
.
handler
);
this
.
executor
.
execute
(
this
.
handler
);
for
(
int
i
=
0
;
i
<
BLOCK_FETCHER_NUM
;
i
++)
{
//
for (int i = 0; i < BLOCK_FETCHER_NUM; i++) {
this
.
executor
.
execute
(
this
.
fetcher
);
this
.
executor
.
execute
(
this
.
fetcher
);
}
//
}
/*
/*
账户余额抓取、处理
账户余额抓取、处理
...
@@ -112,9 +95,9 @@ public class Engine {
...
@@ -112,9 +95,9 @@ public class Engine {
this
.
addressHandler
=
new
AddressBalanceHandler
();
this
.
addressHandler
=
new
AddressBalanceHandler
();
this
.
addressFetcher
=
new
AddressBalanceFetcher
(
this
.
addressHandler
);
this
.
addressFetcher
=
new
AddressBalanceFetcher
(
this
.
addressHandler
);
this
.
executor
.
execute
(
this
.
addressHandler
);
this
.
executor
.
execute
(
this
.
addressHandler
);
for
(
int
i
=
0
;
i
<
BALANCE_FETCHER_NUM
;
i
++)
{
//
for (int i = 0; i < BALANCE_FETCHER_NUM; i++) {
this
.
executor
.
execute
(
this
.
addressFetcher
);
this
.
executor
.
execute
(
this
.
addressFetcher
);
}
//
}
/*
/*
统计数据抓取、处理
统计数据抓取、处理
...
...
src/main/java/com/wuban/tron/explore/fetch/Executor.java
View file @
28547bf2
...
@@ -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
=
10
;
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
;
...
...
src/main/java/com/wuban/tron/explore/fetch/PersistThreadPoolV2.java
View file @
28547bf2
...
@@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicInteger;
...
@@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Slf4j
@Slf4j
public
class
PersistThreadPoolV2
{
public
class
PersistThreadPoolV2
{
private
static
final
int
POLL_SIZE
=
2
;
private
static
final
int
POLL_SIZE
=
1
;
private
static
PersistThreadPoolV2
instance
;
private
static
PersistThreadPoolV2
instance
;
public
final
List
<
ThreadPoolExecutor
>
executors
=
new
ArrayList
<>(
POLL_SIZE
);
public
final
List
<
ThreadPoolExecutor
>
executors
=
new
ArrayList
<>(
POLL_SIZE
);
...
...
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