Commit 28547bf2 authored by jianhua.zhang's avatar jianhua.zhang

tps峰值接口重新调整

parent f9257399
...@@ -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
......
...@@ -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);
} //}
/* /*
统计数据抓取、处理 统计数据抓取、处理
......
...@@ -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;
......
...@@ -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);
......
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