mirror of
https://github.com/ChronosX88/Influence-Bootstrap-Node.git
synced 2024-11-21 23:02:19 +00:00
Fixed issue when clients don't bootstrap to this node.
This commit is contained in:
parent
e0ff8801f4
commit
88cb498807
@ -96,51 +96,56 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void createNewPastryBootstrapNode() {
|
private static void createNewPastryBootstrapNode() {
|
||||||
Environment env = new Environment();
|
new Thread(() -> {
|
||||||
env.getParameters().setString("probe_for_external_address","true");
|
Environment env = new Environment();
|
||||||
env.getParameters().setString("nat_search_policy","never");
|
env.getParameters().setString("probe_for_external_address","true");
|
||||||
// Generate the NodeIds Randomly
|
env.getParameters().setString("nat_search_policy","never");
|
||||||
NodeIdFactory nidFactory = new RandomNodeIdFactory(env);
|
// Generate the NodeIds Randomly
|
||||||
|
NodeIdFactory nidFactory = new RandomNodeIdFactory(env);
|
||||||
|
|
||||||
// construct the PastryNodeFactory, this is how we use rice.pastry.socket
|
// construct the PastryNodeFactory, this is how we use rice.pastry.socket
|
||||||
PastryNodeFactory factory = null;
|
PastryNodeFactory factory = null;
|
||||||
try {
|
try {
|
||||||
factory = new InternetPastryNodeFactory(nidFactory, 7244, env);
|
factory = new InternetPastryNodeFactory(nidFactory, 7244, env);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct a node, but this does not cause it to boot
|
// construct a node, but this does not cause it to boot
|
||||||
PastryNode node = null;
|
PastryNode node = null;
|
||||||
try {
|
try {
|
||||||
node = factory.newNode();
|
node = factory.newNode();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
// the node may require sending several messages to fully boot into the ring
|
|
||||||
synchronized(node) {
|
|
||||||
while(!node.isReady() && !node.joinFailed()) {
|
|
||||||
// delay so we don't busy-wait
|
|
||||||
try {
|
|
||||||
node.wait(500);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// abort if can't join
|
} catch (UnknownHostException e) {
|
||||||
if (node.joinFailed()) {
|
e.printStackTrace();
|
||||||
System.out.println("[Pastry] Could not join the FreePastry ring. Reason:"+node.joinFailedReason());
|
}*/
|
||||||
|
node.boot((Object) null);
|
||||||
|
|
||||||
|
// the node may require sending several messages to fully boot into the ring
|
||||||
|
synchronized(node) {
|
||||||
|
while(!node.isReady() && !node.joinFailed()) {
|
||||||
|
// delay so we don't busy-wait
|
||||||
|
try {
|
||||||
|
node.wait(100);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// abort if can't join
|
||||||
|
if (node.joinFailed()) {
|
||||||
|
System.out.println("[Pastry] Could not join the FreePastry ring. Reason:"+node.joinFailedReason());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("[Pastry] Finished creating new bootstrap node "+node);
|
System.out.println("[Pastry] Finished creating new bootstrap node "+node);
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user