Fixed issue when clients don't bootstrap to this node.

This commit is contained in:
ChronosX88 2019-05-16 19:03:12 +04:00
parent e0ff8801f4
commit 88cb498807

View File

@ -96,6 +96,7 @@ public class Main {
} }
private static void createNewPastryBootstrapNode() { private static void createNewPastryBootstrapNode() {
new Thread(() -> {
Environment env = new Environment(); Environment env = new Environment();
env.getParameters().setString("probe_for_external_address","true"); env.getParameters().setString("probe_for_external_address","true");
env.getParameters().setString("nat_search_policy","never"); env.getParameters().setString("nat_search_policy","never");
@ -119,17 +120,20 @@ public class Main {
} }
pastryNode = node; pastryNode = node;
try { /*try {
node.boot(new InetSocketAddress(InetAddress.getLocalHost().getHostName(), 7244)); //node.boot(new InetSocketAddress(InetAddress.getLocalHost().getHostName(), 7244));
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
e.printStackTrace(); e.printStackTrace();
} }*/
node.boot((Object) null);
// the node may require sending several messages to fully boot into the ring // the node may require sending several messages to fully boot into the ring
synchronized(node) { synchronized(node) {
while(!node.isReady() && !node.joinFailed()) { while(!node.isReady() && !node.joinFailed()) {
// delay so we don't busy-wait // delay so we don't busy-wait
try { try {
node.wait(500); node.wait(100);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -142,5 +146,6 @@ public class Main {
} }
System.out.println("[Pastry] Finished creating new bootstrap node "+node); System.out.println("[Pastry] Finished creating new bootstrap node "+node);
}).start();
} }
} }