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:
romanman 2014-08-05 10:48:27 +03:00
parent 4f6a3a6954
commit 1e9d1ac3a9
7 changed files with 25 additions and 32 deletions

View File

@ -20,8 +20,7 @@ public class SystemProperties {
private static Logger logger = LoggerFactory.getLogger(SystemProperties.class);
private static int DEFAULT_TX_APPROVE_TIMEOUT = 10;
private static String DEFAULT_DISCOVERY_PEER = "54.201.28.117";
private static int DEFAULT_DISCOVERY_PORT = 30303;
private static String DEFAULT_DISCOVERY_PEER_LIST = "54.201.28.117:30303";
private static String DEFAULT_ACTIVE_PEER_IP = "54.201.28.117";
private static int DEFAULT_ACTIVE_PORT = 30303;
private static String DEFAULT_SAMPLES_DIR = "samples";
@ -98,14 +97,9 @@ public class SystemProperties {
return Integer.parseInt(prop.getProperty("transaction.approve.timeout"));
}
public String peerDiscoveryIP() {
if(prop.isEmpty()) return DEFAULT_DISCOVERY_PEER;
return prop.getProperty("peer.discovery.ip");
}
public int peerDiscoveryPort() {
if(prop.isEmpty()) return DEFAULT_DISCOVERY_PORT;
return Integer.parseInt(prop.getProperty("peer.discovery.port"));
public String peerDiscoveryIPList() {
if(prop.isEmpty()) return DEFAULT_DISCOVERY_PEER_LIST;
return prop.getProperty("peer.discovery.ip.list");
}
public boolean databaseReset() {

View File

@ -29,7 +29,7 @@ public class PeersTableModel extends AbstractTableModel {
public void run() {
updateModel();
}
}, 0, 1000);
}, 0, 100);
}
public String getColumnName(int column) {

View File

@ -35,11 +35,11 @@ public class PeerDiscovery {
threadFactory = Executors.defaultThreadFactory();
//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);
//start the monitoring thread
monitor = new PeerDiscoveryMonitorThread(executorPool, 3);
monitor = new PeerDiscoveryMonitorThread(executorPool, 0);
Thread monitorThread = new Thread(monitor);
monitorThread.start();

View File

@ -25,7 +25,7 @@ public class PeerDiscoveryMonitorThread implements Runnable {
@Override
public void run() {
while(run) {
logger.info(
logger.trace(
String.format("[monitor] [%d/%d] Active: %d, Completed: %d, Task: %d, isShutdown: %s, isTerminated: %s, peersDiscovered: %d ",
this.executor.getPoolSize(),
this.executor.getCorePoolSize(),

View File

@ -26,6 +26,7 @@ public class PeerTaster {
public void connect(String host, int port) {
logger.debug("connecting: {}:{}", host, port);
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
@ -48,6 +49,7 @@ public class PeerTaster {
// Wait until the connection is closed.
f.channel().closeFuture().sync();
logger.debug("connection is closed");
} catch (InterruptedException ie) {
logger.info("-- ClientPeer: catch (InterruptedException ie) --");

View File

@ -17,6 +17,7 @@ public class WorkerThread implements Runnable {
ThreadPoolExecutor poolExecutor;
private PeerData peerData;
private PeerTaster peerTaster = new PeerTaster();
public WorkerThread(PeerData peerData, ThreadPoolExecutor poolExecutor) {
this.poolExecutor = poolExecutor;
@ -36,8 +37,7 @@ public class WorkerThread implements Runnable {
private void processCommand() {
try {
PeerTaster peerTaster = new PeerTaster();
peerTaster.connect(peerData.getInetAddress().getHostName(), peerData.getPort());
peerTaster.connect(peerData.getInetAddress().getHostAddress(), peerData.getPort());
byte capabilities = peerTaster.getCapabilities();
peerData.setOnline(true);

View File

@ -2,21 +2,15 @@
# accept for incoming connections [true/false]
server.acceptConnections = false
# one default access point to start
# discover the network e.g. ip: [54.201.28.117] port: [30303]
# Peer Server Zero: peer discovery
#peer.discovery.ip = 54.72.69.180
#peer.discovery.port = 30303
# List of the peers to start
# the search of the online peers
# values: [ip:port, ip:port, ip:port ...]
peer.discovery.ip.list = 185.43.109.23:30303,\
213.100.248.181:30303, \
54.72.69.180:30303, \
54.201.28.117:30303, \
70.29.74.8:7
# Peer Server One: peer discovery
# 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
# that is the peer through
@ -40,6 +34,9 @@ peer.active.port = 30303
#peer.active.ip = 54.72.69.180
#peer.active.port = 30303
#peer.active.ip = 185.43.109.23
#peer.active.port = 30303
#peer.active.ip = 151.64.223.120
#peer.active.port = 30304
@ -60,7 +57,7 @@ peer.discovery.workers = 15
# connection timeout for trying to
# connect to a peer [seconds]
peer.discovery.timeout = 1
peer.discovery.timeout = 3
# the time we wait to the network
# to approve the transaction, the
@ -108,7 +105,7 @@ dump.clean.on.restart = true
# make changes to tracing options
# starting from certain block
# -1 don't make any tracing changes
trace.startblock = 1155
trace.startblock = -1
# invoke vm program on
# message received,