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