/** * Create network configuration for initial peer with given node id. * * @param nodeID defines the location of the peer in the DHT * @return the network configuration */ public static NetworkConfiguration createInitial(String nodeID) { return new NetworkConfiguration().setNodeId(nodeID).setPort(AUTO_PORT); }
/** * Creates a local peer that is only able to bootstrap to a peer running on the same host. * * @param nodeID the id of the peer to create * @param initialPeer the peer to bootstrap to * @return the network configuration for local peers */ public static NetworkConfiguration createLocalPeer(String nodeID, Peer initialPeer) { return new NetworkConfiguration().setNodeId(nodeID).setPort(AUTO_PORT).setBootstrapLocal(initialPeer); }
/** * Create a local initial peer. Regard that bootstrapping may only work for peers running on the same * host. * * @param nodeID the id of the initial peer * @return the network configuration for local peers (initial) */ public static NetworkConfiguration createInitialLocalPeer(String nodeID) { return new NetworkConfiguration().setNodeId(nodeID).setPort(AUTO_PORT).setLocal(); }
/** * Create network configuration for 'normal' peer. The bootstrapping happens at the default port * {@link H2HConstants#H2H_PORT}. * * @param nodeID defines the location of the peer in the DHT. Should not be null * @param bootstrapAddress the address to bootstrap to. This can be address of the initial peer or any * other peer connected to the DHT. * @return the network configuration */ public static NetworkConfiguration create(String nodeID, InetAddress bootstrapAddress) { return new NetworkConfiguration().setNodeId(nodeID).setPort(AUTO_PORT).setBootstrap(bootstrapAddress, H2HConstants.H2H_PORT); }
/** * Create network configuration for 'normal' peer. The bootstrapping happens to the specified address and * port * * @param nodeID defines the location of the peer in the DHT. Should not be null * @param bootstrapAddress the address to bootstrap to. This can be address of the initial peer or any * other peer connected to the DHT. * @param bootstrapPort the port to bootstrap * @return the network configuration */ public static NetworkConfiguration create(String nodeID, InetAddress bootstrapAddress, int bootstrapPort) { return new NetworkConfiguration().setNodeId(nodeID).setPort(AUTO_PORT).setBootstrap(bootstrapAddress, bootstrapPort); }
NetworkConfiguration node3Conf = NetworkConfiguration.create(InetAddress.getLocalHost()).setPort(4777) .setNodeId("node3"); node3.connect(node3Conf);
networkConfig.setPort(Integer.parseInt(bindPort));