Changeset 178
- Timestamp:
- 03/01/06 11:10:13 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
feedtree/trunk/src/net/feedtree/core/client/Client.java
r174 r178 10 10 11 11 import rice.pastry.PastryNode; 12 import rice.pastry.dist.DistPastryNodeFactory; 13 import rice.pastry.socket.SocketPastryNode; 12 import rice.pastry.socket.*; 14 13 import rice.pastry.standard.*; 15 14 import rice.pastry.commonapi.PastryIdFactory; … … 27 26 public static final boolean ANYCAST_STOP = false; 28 27 29 public static int PASTRY_PROTOCOL = DistPastryNodeFactory.PROTOCOL_SOCKET; 30 31 protected static InetSocketAddress g_localNodeAddress = null; 28 protected static InetSocketAddress g_publicNodeAddress = null; 32 29 protected static Environment g_pastryEnv = new Environment(); 33 30 34 31 public static InetSocketAddress getLocalNodeAddress() { 35 return g_ localNodeAddress;32 return g_publicNodeAddress; 36 33 } 37 34 … … 257 254 "Starting FeedTree client"); 258 255 259 DistPastryNodeFactory factory = null; 260 261 try { 262 factory = DistPastryNodeFactory.getFactory( 263 new RandomNodeIdFactory(g_pastryEnv), 264 PASTRY_PROTOCOL, 265 port, 266 g_pastryEnv); 267 } catch (IOException exc) { 268 Logger.global.severe("error: couldn't create node factory; bailing"); 269 status.notifyStatus(ClientStatus.STATUS_FATAL_ERROR, 270 "Error loading Pastry network code"); 271 272 return null; 273 } 256 SocketPastryNodeFactory factory = null; 274 257 275 258 int attempts = 5; … … 306 289 status.notifyStatus(ClientStatus.STATUS_STARTING, 307 290 "Detecting public IP address"); 308 291 309 292 InetAddress natAddr = NAT.findNatAddress( 310 293 localHost, port, bootSocketList, g_pastryEnv); 311 g_ localNodeAddress = null;294 g_publicNodeAddress = null; 312 295 if (natAddr != null) 313 g_localNodeAddress = new InetSocketAddress(natAddr, port); 296 g_publicNodeAddress = new InetSocketAddress(natAddr, port); 297 298 try { 299 300 // Construct the node factory given the *local* 301 // address to bind to (this allows us to select among 302 // multiple network interfaces on the client). Note 303 // that we're not yet using the (detected) external 304 // IP; that comes later. 305 factory = new SocketPastryNodeFactory( 306 new RandomNodeIdFactory(g_pastryEnv), 307 natAddr, port, g_pastryEnv); 308 309 } catch (IOException exc) { 310 Logger.global.severe("error: couldn't create node factory; bailing"); 311 status.notifyStatus(ClientStatus.STATUS_FATAL_ERROR, 312 "Error loading Pastry network code"); 313 314 return null; 315 } 314 316 315 317 Logger.global.fine("[Contacting bootstrap host " … … 318 320 status.notifyStatus(ClientStatus.STATUS_STARTING, 319 321 "Contacting bootstrap host"); 320 322 323 // Finally: construct the Pastry node, given the 324 // address to "claim" in the ring (our external IP) 321 325 node = factory.newNode( 322 326 factory.getNodeHandle(bootSocketList[0]), 323 g_localNodeAddress); 327 g_publicNodeAddress); 328 324 329 } catch (java.net.BindException exc) { 325 330 Logger.global.severe("error: couldn't bind to requested address (already in use?)");
