Package org.hive2hive.core.api.interfaces

Examples of org.hive2hive.core.api.interfaces.INetworkConfiguration


   * Creates a single node which is initial.
   *
   * @return a node
   */
  public static NetworkManager createSingleNode() {
    INetworkConfiguration netConfig = NetworkConfiguration.create("Node A");
    NetworkManager node = new NetworkManager(netConfig);
    node.connect();
    return node;
  }
View Full Code Here


    if (numberOfNodes < 1)
      throw new IllegalArgumentException("invalid size of network");
    List<NetworkManager> nodes = new ArrayList<NetworkManager>(numberOfNodes);

    // create the first node (initial)
    INetworkConfiguration netConfig = NetworkConfiguration.create("Node A");
    NetworkManager initial = new NetworkManager(netConfig);
    initial.connect();
    nodes.add(initial);

    // create the other nodes and bootstrap them to the initial peer
    char letter = 'A';
    for (int i = 1; i < numberOfNodes; i++) {
      try {
        INetworkConfiguration otherNetConfig = NetworkConfiguration.create(String.format("Node %s", ++letter),
            InetAddress.getLocalHost());
        NetworkManager node = new NetworkManager(otherNetConfig);
        node.connect();
        nodes.add(node);
      } catch (UnknownHostException e) {
View Full Code Here

  }
 
  @Test
  public void testConnectAsInitial(){
   
    INetworkConfiguration netConfig = NetworkConfiguration.create("initial node");
   
    NetworkManager initialNode = new NetworkManager(netConfig);
    assertTrue(initialNode.connect());
    initialNode.disconnect();
  }
View Full Code Here

  }
 
  @Test
  public void testConnectToOtherPeer() throws UnknownHostException{
   
    INetworkConfiguration netConfigA = NetworkConfiguration.create("nodeA");
    INetworkConfiguration netConfigB = NetworkConfiguration.create("nodeB", InetAddress.getLocalHost());
   
    NetworkManager nodeA = new NetworkManager(netConfigA);
    NetworkManager nodeB = new NetworkManager(netConfigB);
    assertTrue(nodeA.connect());
    assertTrue(nodeB.connect());
View Full Code Here

  }

  @Test
  public void getPeer() {
    // a unconnected node does not provide a peer
    INetworkConfiguration config = NetworkConfiguration.create();
    IFileConfiguration fileConfig = FileConfiguration.createDefault();
    IH2HNode node = H2HNode.createNode(config, fileConfig);
    Assert.assertNull(node.getPeer());

    // connected nodes return a peer
View Full Code Here

TOP

Related Classes of org.hive2hive.core.api.interfaces.INetworkConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.