Examples of IH2HNode


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

 
  public void shutdown() {
    // TODO check whether network indeed has to be shut down here, e.g., when bootstrapped -> just leave
   
    // shutdown network
    IH2HNode node = menus.getNodeMenu().getNode();
    if (node != null && node.isConnected()) {
      print("Disconnecting from the network...");
      node.disconnect();     
    }
   
    // stop file observer
    IFileObserver fileObserver = menus.getFileObserverMenu().getFileObserver();
    if (fileObserver != null && fileObserver.isRunning()) {
View Full Code Here

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

    List<IH2HNode> nodes = new ArrayList<IH2HNode>(numberOfNodes);

    // TODO the initial peer has an autostart, whereas the others dont

    // create initial peer
    IH2HNode initial = H2HNode.createNode(NetworkConfiguration.create("initial"), FileConfiguration.createDefault());
    initial.connect();
    initial.getFileManager().configureAutostart(false);
    initial.getUserManager().configureAutostart(false);

    nodes.add(initial);

    try {
      InetAddress bootstrapAddress = InetAddress.getLocalHost();
      for (int i = 1; i < numberOfNodes; i++) {
        IH2HNode node = H2HNode.createNode(NetworkConfiguration.create("node " + i, bootstrapAddress),
            FileConfiguration.createDefault());
        node.connect();
        node.getFileManager().configureAutostart(false);
        node.getUserManager().configureAutostart(false);
        nodes.add(node);
      }
    } catch (UnknownHostException e) {
      // should not happen
    }
View Full Code Here

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

  @Before
  public void testRegisterLogin() throws IOException, NoPeerConnectionException {
    credentials = NetworkTestUtil.generateRandomCredentials();

    IH2HNode registerNode = network.get(random.nextInt(NETWORK_SIZE));
    IProcessComponent registerProcess = registerNode.getUserManager().register(credentials);
    UseCaseTestUtil.executeProcess(registerProcess);

    rootDirectory = FileTestUtil.getTempDirectory();
    loggedInNode = network.get(random.nextInt(NETWORK_SIZE / 2));
    IProcessComponent loginProcess = loggedInNode.getUserManager().login(credentials,
View Full Code Here

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

    // TODO wait for all async process to upload

    // then start 2nd client and login
    File rootUser2 = FileTestUtil.getTempDirectory();
    IH2HNode newNode = network.get((random.nextInt(NETWORK_SIZE / 2) + NETWORK_SIZE / 2));

    IProcessComponent loginProcess = newNode.getUserManager().login(credentials, rootUser2.toPath());
    UseCaseTestUtil.executeProcess(loginProcess);

    // TODO wait for login process to download all files

    // verfiy that all files are here
View Full Code Here

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

  @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
    Assert.assertNotNull(network.get(random.nextInt(NETWORK_SIZE)).getPeer());
  }
View Full Code Here

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

  }
 
  @Test
  public void eventListenerTest() {
   
    IH2HNode node = H2HNode.createNode(NetworkConfiguration.create(), FileConfiguration.createDefault());
   
    TestNetworkEventListener listener = new TestNetworkEventListener();
    node.addEventListener(listener);
   
    node.connect();
   
    assertTrue(listener.connectionSucceeded || listener.connectionFailed);
    assertTrue(!listener.disconnectionSucceeded && !listener.disconnectionFailed);
    listener.reset();
   
    node.disconnect();
    assertTrue(listener.disconnectionSucceeded || listener.disconnectionFailed);
    assertTrue(!listener.connectionSucceeded && !listener.connectionFailed);
    listener.reset();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.