PeerDiscovery:
+ performance improve, no using host name , but ip only + configuration preloaded with string "ip:port, ip:port, ip:port..."
This commit is contained in:
parent
4f6a3a6954
commit
1e9d1ac3a9
|
@ -20,8 +20,7 @@ public class SystemProperties {
|
||||||
private static Logger logger = LoggerFactory.getLogger(SystemProperties.class);
|
private static Logger logger = LoggerFactory.getLogger(SystemProperties.class);
|
||||||
|
|
||||||
private static int DEFAULT_TX_APPROVE_TIMEOUT = 10;
|
private static int DEFAULT_TX_APPROVE_TIMEOUT = 10;
|
||||||
private static String DEFAULT_DISCOVERY_PEER = "54.201.28.117";
|
private static String DEFAULT_DISCOVERY_PEER_LIST = "54.201.28.117:30303";
|
||||||
private static int DEFAULT_DISCOVERY_PORT = 30303;
|
|
||||||
private static String DEFAULT_ACTIVE_PEER_IP = "54.201.28.117";
|
private static String DEFAULT_ACTIVE_PEER_IP = "54.201.28.117";
|
||||||
private static int DEFAULT_ACTIVE_PORT = 30303;
|
private static int DEFAULT_ACTIVE_PORT = 30303;
|
||||||
private static String DEFAULT_SAMPLES_DIR = "samples";
|
private static String DEFAULT_SAMPLES_DIR = "samples";
|
||||||
|
@ -98,16 +97,11 @@ public class SystemProperties {
|
||||||
return Integer.parseInt(prop.getProperty("transaction.approve.timeout"));
|
return Integer.parseInt(prop.getProperty("transaction.approve.timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String peerDiscoveryIP() {
|
public String peerDiscoveryIPList() {
|
||||||
if(prop.isEmpty()) return DEFAULT_DISCOVERY_PEER;
|
if(prop.isEmpty()) return DEFAULT_DISCOVERY_PEER_LIST;
|
||||||
return prop.getProperty("peer.discovery.ip");
|
return prop.getProperty("peer.discovery.ip.list");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int peerDiscoveryPort() {
|
|
||||||
if(prop.isEmpty()) return DEFAULT_DISCOVERY_PORT;
|
|
||||||
return Integer.parseInt(prop.getProperty("peer.discovery.port"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean databaseReset() {
|
public boolean databaseReset() {
|
||||||
if(prop.isEmpty()) return DEFAULT_DB_RESET;
|
if(prop.isEmpty()) return DEFAULT_DB_RESET;
|
||||||
return Boolean.parseBoolean(prop.getProperty("database.reset"));
|
return Boolean.parseBoolean(prop.getProperty("database.reset"));
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class PeersTableModel extends AbstractTableModel {
|
||||||
public void run() {
|
public void run() {
|
||||||
updateModel();
|
updateModel();
|
||||||
}
|
}
|
||||||
}, 0, 1000);
|
}, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
|
|
|
@ -35,11 +35,11 @@ public class PeerDiscovery {
|
||||||
threadFactory = Executors.defaultThreadFactory();
|
threadFactory = Executors.defaultThreadFactory();
|
||||||
|
|
||||||
//creating the ThreadPoolExecutor
|
//creating the ThreadPoolExecutor
|
||||||
executorPool = new ThreadPoolExecutor(1, 1000, 10, TimeUnit.SECONDS,
|
executorPool = new ThreadPoolExecutor(CONFIG.peerDiscoveryWorkers(), 1000, 10, TimeUnit.SECONDS,
|
||||||
new ArrayBlockingQueue<Runnable>(CONFIG.peerDiscoveryWorkers()), threadFactory, rejectionHandler);
|
new ArrayBlockingQueue<Runnable>(CONFIG.peerDiscoveryWorkers()), threadFactory, rejectionHandler);
|
||||||
|
|
||||||
//start the monitoring thread
|
//start the monitoring thread
|
||||||
monitor = new PeerDiscoveryMonitorThread(executorPool, 3);
|
monitor = new PeerDiscoveryMonitorThread(executorPool, 0);
|
||||||
Thread monitorThread = new Thread(monitor);
|
Thread monitorThread = new Thread(monitor);
|
||||||
monitorThread.start();
|
monitorThread.start();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class PeerDiscoveryMonitorThread implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while(run) {
|
while(run) {
|
||||||
logger.info(
|
logger.trace(
|
||||||
String.format("[monitor] [%d/%d] Active: %d, Completed: %d, Task: %d, isShutdown: %s, isTerminated: %s, peersDiscovered: %d ",
|
String.format("[monitor] [%d/%d] Active: %d, Completed: %d, Task: %d, isShutdown: %s, isTerminated: %s, peersDiscovered: %d ",
|
||||||
this.executor.getPoolSize(),
|
this.executor.getPoolSize(),
|
||||||
this.executor.getCorePoolSize(),
|
this.executor.getCorePoolSize(),
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class PeerTaster {
|
||||||
|
|
||||||
public void connect(String host, int port) {
|
public void connect(String host, int port) {
|
||||||
|
|
||||||
|
logger.debug("connecting: {}:{}", host, port);
|
||||||
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -48,6 +49,7 @@ public class PeerTaster {
|
||||||
|
|
||||||
// Wait until the connection is closed.
|
// Wait until the connection is closed.
|
||||||
f.channel().closeFuture().sync();
|
f.channel().closeFuture().sync();
|
||||||
|
logger.debug("connection is closed");
|
||||||
|
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
logger.info("-- ClientPeer: catch (InterruptedException ie) --");
|
logger.info("-- ClientPeer: catch (InterruptedException ie) --");
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class WorkerThread implements Runnable {
|
||||||
|
|
||||||
ThreadPoolExecutor poolExecutor;
|
ThreadPoolExecutor poolExecutor;
|
||||||
private PeerData peerData;
|
private PeerData peerData;
|
||||||
|
private PeerTaster peerTaster = new PeerTaster();
|
||||||
|
|
||||||
public WorkerThread(PeerData peerData, ThreadPoolExecutor poolExecutor) {
|
public WorkerThread(PeerData peerData, ThreadPoolExecutor poolExecutor) {
|
||||||
this.poolExecutor = poolExecutor;
|
this.poolExecutor = poolExecutor;
|
||||||
|
@ -36,8 +37,7 @@ public class WorkerThread implements Runnable {
|
||||||
private void processCommand() {
|
private void processCommand() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PeerTaster peerTaster = new PeerTaster();
|
peerTaster.connect(peerData.getInetAddress().getHostAddress(), peerData.getPort());
|
||||||
peerTaster.connect(peerData.getInetAddress().getHostName(), peerData.getPort());
|
|
||||||
byte capabilities = peerTaster.getCapabilities();
|
byte capabilities = peerTaster.getCapabilities();
|
||||||
|
|
||||||
peerData.setOnline(true);
|
peerData.setOnline(true);
|
||||||
|
|
|
@ -2,21 +2,15 @@
|
||||||
# accept for incoming connections [true/false]
|
# accept for incoming connections [true/false]
|
||||||
server.acceptConnections = false
|
server.acceptConnections = false
|
||||||
|
|
||||||
# one default access point to start
|
# List of the peers to start
|
||||||
# discover the network e.g. ip: [54.201.28.117] port: [30303]
|
# the search of the online peers
|
||||||
# Peer Server Zero: peer discovery
|
# values: [ip:port, ip:port, ip:port ...]
|
||||||
#peer.discovery.ip = 54.72.69.180
|
peer.discovery.ip.list = 185.43.109.23:30303,\
|
||||||
#peer.discovery.port = 30303
|
213.100.248.181:30303, \
|
||||||
|
54.72.69.180:30303, \
|
||||||
# Peer Server One: peer discovery
|
54.201.28.117:30303, \
|
||||||
|
70.29.74.8:7
|
||||||
|
|
||||||
# Asimov
|
|
||||||
peer.discovery.ip = 185.43.109.23
|
|
||||||
peer.discovery.port = 30303
|
|
||||||
|
|
||||||
# RomanJ
|
|
||||||
#peer.discovery.ip = 54.211.14.10
|
|
||||||
#peer.discovery.port = 30303
|
|
||||||
|
|
||||||
# active peer ip and port
|
# active peer ip and port
|
||||||
# that is the peer through
|
# that is the peer through
|
||||||
|
@ -40,6 +34,9 @@ peer.active.port = 30303
|
||||||
#peer.active.ip = 54.72.69.180
|
#peer.active.ip = 54.72.69.180
|
||||||
#peer.active.port = 30303
|
#peer.active.port = 30303
|
||||||
|
|
||||||
|
#peer.active.ip = 185.43.109.23
|
||||||
|
#peer.active.port = 30303
|
||||||
|
|
||||||
#peer.active.ip = 151.64.223.120
|
#peer.active.ip = 151.64.223.120
|
||||||
#peer.active.port = 30304
|
#peer.active.port = 30304
|
||||||
|
|
||||||
|
@ -60,7 +57,7 @@ peer.discovery.workers = 15
|
||||||
|
|
||||||
# connection timeout for trying to
|
# connection timeout for trying to
|
||||||
# connect to a peer [seconds]
|
# connect to a peer [seconds]
|
||||||
peer.discovery.timeout = 1
|
peer.discovery.timeout = 3
|
||||||
|
|
||||||
# the time we wait to the network
|
# the time we wait to the network
|
||||||
# to approve the transaction, the
|
# to approve the transaction, the
|
||||||
|
@ -108,7 +105,7 @@ dump.clean.on.restart = true
|
||||||
# make changes to tracing options
|
# make changes to tracing options
|
||||||
# starting from certain block
|
# starting from certain block
|
||||||
# -1 don't make any tracing changes
|
# -1 don't make any tracing changes
|
||||||
trace.startblock = 1155
|
trace.startblock = -1
|
||||||
|
|
||||||
# invoke vm program on
|
# invoke vm program on
|
||||||
# message received,
|
# message received,
|
||||||
|
|
Loading…
Reference in New Issue