Publish arbitrator after bootstrap completed

This commit is contained in:
Manfred Karrer 2016-05-09 16:34:43 +02:00
parent cb1de4a9c9
commit d99b5ade5e

View File

@ -135,23 +135,27 @@ public class ArbitratorManager {
if (user.getRegisteredArbitrator() != null) {
P2PService p2PService = arbitratorService.getP2PService();
if (p2PService.isBootstrapped())
republishArbitrator();
isBootstrapped();
else
p2PService.addP2PServiceListener(new BootstrapListener() {
@Override
public void onBootstrapComplete() {
republishArbitrator();
isBootstrapped();
}
});
}
republishArbitratorTimer = UserThread.runPeriodically(this::republishArbitrator, REPUBLISH_MILLIS, TimeUnit.MILLISECONDS);
UserThread.runAfter(this::republishArbitrator, REPEATED_REPUBLISH_AT_STARTUP_SEC);
applyArbitrators();
}
private void isBootstrapped() {
if (republishArbitratorTimer == null) {
republishArbitratorTimer = UserThread.runPeriodically(this::republishArbitrator, REPUBLISH_MILLIS, TimeUnit.MILLISECONDS);
UserThread.runAfter(this::republishArbitrator, REPEATED_REPUBLISH_AT_STARTUP_SEC);
republishArbitrator();
}
}
public void applyArbitrators() {
Map<NodeAddress, Arbitrator> map = arbitratorService.getArbitrators();
log.trace("Arbitrators . size=" + map.values().size());