fix wrong timer behaviour

This commit is contained in:
Manfred Karrer 2016-01-14 11:40:06 +01:00
parent 7c3732c0e5
commit db128c6815
4 changed files with 14 additions and 10 deletions

View file

@ -135,8 +135,9 @@ public class ArbitratorManager {
}
// re-publish periodically
republishArbitratorExecutor = Utilities.getScheduledThreadPoolExecutor("", 1, 5, 5);
republishArbitratorExecutor.schedule(() -> republishArbitrator(), Arbitrator.TTL / 2, TimeUnit.MILLISECONDS);
republishArbitratorExecutor = Utilities.getScheduledThreadPoolExecutor("republishArbitrator", 1, 5, 5);
long delay = Arbitrator.TTL / 2;
republishArbitratorExecutor.scheduleAtFixedRate(() -> republishArbitrator(), delay, delay, TimeUnit.MILLISECONDS);
}
applyArbitrators();

View file

@ -53,9 +53,9 @@ public class MaintenanceManager implements MessageListener {
networkNode.addMessageListener(this);
executor = Utilities.getScheduledThreadPoolExecutor("MaintenanceManager", 1, 10, 5);
executor.schedule(() -> {
executor.scheduleAtFixedRate(() -> {
UserThread.execute(() -> pingPeers());
}, 5, TimeUnit.MINUTES);
}, 5, 5, TimeUnit.MINUTES);
}
public void shutDown() {

View file

@ -60,7 +60,7 @@ public class PeerExchangeManager implements MessageListener {
networkNode.addMessageListener(this);
executor = Utilities.getScheduledThreadPoolExecutor("PeerExchangeManager", 1, 10, 5);
executor.schedule(() -> UserThread.execute(() -> trySendGetPeersRequest()), 4, TimeUnit.MINUTES);
executor.scheduleAtFixedRate(() -> UserThread.execute(() -> trySendGetPeersRequest()), 4, 4, TimeUnit.MINUTES);
}
public void shutDown() {

View file

@ -118,7 +118,7 @@ public class PeerManager implements MessageListener, ConnectionListener {
@Override
public void onDisconnect(Reason reason, Connection connection) {
log.debug("onDisconnect connection=" + connection + " / reason=" + reason);
log.debug("onDisconnect reason=" + reason + " / connection=" + connection);
connection.getPeerAddressOptional().ifPresent(peerAddress -> {
// We only remove the peer from the authenticationHandshakes and the reportedPeers
@ -445,8 +445,8 @@ public class PeerManager implements MessageListener, ConnectionListener {
}
protected void startCheckSeedNodeConnectionTask() {
checkSeedNodeConnectionExecutor.schedule(() -> UserThread.execute(()
-> checkSeedNodeConnections()), 2, TimeUnit.MINUTES);
checkSeedNodeConnectionExecutor.scheduleAtFixedRate(() -> UserThread.execute(()
-> checkSeedNodeConnections()), 2, 2, TimeUnit.MINUTES);
}
// We want to stay connected to at least one seed node to avoid to get isolated with a group of peers
@ -530,8 +530,8 @@ public class PeerManager implements MessageListener, ConnectionListener {
authenticateToRemainingSeedNode();
} else if (!persistedPeers.isEmpty()) {
log.info("We don't have seed nodes or reported peers available. " +
"We will add 5 peers from our persistedReportedPeers to our reportedPeers list and " +
"try authenticateToRemainingReportedPeer again.");
"We will try to add 5 peers from our persistedPeers to our reportedPeers list and " +
"try authenticateToRemainingReportedPeer again. All persistedPeers=" + persistedPeers);
List<ReportedPeer> list = new ArrayList<>(persistedPeers);
authenticationHandshakes.keySet().stream().forEach(e -> list.remove(new ReportedPeer(e)));
@ -543,7 +543,10 @@ public class PeerManager implements MessageListener, ConnectionListener {
persistedPeers.remove(reportedPeer);
reportedPeers.add(reportedPeer);
}
log.info("We have added some of our persistedPeers to our reportedPeers. reportedPeers=" + reportedPeers);
authenticateToRemainingReportedPeer();
} else {
log.info("We don't have any persistedPeers available which are not authenticating or authenticated.");
}
} else {
log.info("We don't have seed nodes, reported peers nor persistedReportedPeers available. " +