From b7a88c09cf1c4275f3d3e8a2a8dece6583212dc0 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Thu, 16 May 2019 17:37:09 +0400 Subject: [PATCH] Fixed issue with starting Pastry bootstrap node --- .../io/github/chronosx88/dhtBootstrap/Main.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/chronosx88/dhtBootstrap/Main.java b/src/main/java/io/github/chronosx88/dhtBootstrap/Main.java index c871526..6b3a064 100644 --- a/src/main/java/io/github/chronosx88/dhtBootstrap/Main.java +++ b/src/main/java/io/github/chronosx88/dhtBootstrap/Main.java @@ -12,9 +12,7 @@ import net.tomp2p.relay.RelayType; import net.tomp2p.relay.tcp.TCPRelayServerConfig; import net.tomp2p.replication.IndirectReplication; import rice.environment.Environment; -import rice.pastry.NodeIdFactory; -import rice.pastry.PastryNode; -import rice.pastry.PastryNodeFactory; +import rice.pastry.*; import rice.pastry.socket.internet.InternetPastryNodeFactory; import rice.pastry.standard.RandomNodeIdFactory; @@ -22,7 +20,9 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; +import java.net.InetAddress; import java.net.InetSocketAddress; +import java.net.UnknownHostException; import java.util.Properties; import java.util.UUID; @@ -114,14 +114,16 @@ public class Main { PastryNode node = null; try { node = factory.newNode(); - pastryNode = node; } catch (IOException e) { e.printStackTrace(); } + pastryNode = node; - // in later tutorials, we will register applications before calling boot - node.boot(new InetSocketAddress(7244)); - + try { + 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()) {