Examples of IProcessComponent


Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

    putLocations.awaitUninterruptibly();
    putLocations.getFutureRequests().awaitUninterruptibly();

    assertTrue(putLocations.isSuccess());

    IProcessComponent registerProcess = ProcessFactory.instance().createRegisterProcess(credentials,
        client);
    ProcessComponentListener listener = new ProcessComponentListener();
    registerProcess.attachListener(listener);
    registerProcess.start();

    H2HWaiter waiter = new H2HWaiter(20);
    do {
      waiter.tickASecond();
    } while (!listener.hasFailed());
View Full Code Here

Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

  @Test
  public void testNotifyNobody() throws ClassNotFoundException, IOException, InvalidProcessStateException,
      IllegalArgumentException, NoPeerConnectionException, NoSessionException {
    NetworkManager notifier = network.get(0);
    CountingNotificationMessageFactory msgFactory = new CountingNotificationMessageFactory(notifier);
    IProcessComponent process = ProcessFactory.instance().createNotificationProcess(msgFactory,
        new HashSet<String>(0), notifier);
    TestProcessComponentListener listener = new TestProcessComponentListener();
    process.attachListener(listener);
    process.start();

    // wait until all messages are sent
    UseCaseTestUtil.waitTillSucceded(listener, 10);
  }
View Full Code Here

Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

    // send notification to own peers
    Set<String> users = new HashSet<String>(1);
    users.add(userACredentials.getUserId());
    CountingNotificationMessageFactory msgFactory = new CountingNotificationMessageFactory(notifier);
    IProcessComponent process = ProcessFactory.instance().createNotificationProcess(msgFactory,
        new HashSet<String>(0), notifier);
    process.start();

    H2HWaiter waiter = new H2HWaiter(20);
    do {
      waiter.tickASecond();
    } while (!msgFactory.allMsgsArrived());

    Assert.assertEquals(ProcessState.SUCCEEDED, process.getState());
  }
View Full Code Here

Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

  @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,
        rootDirectory.toPath());
    UseCaseTestUtil.executeProcess(loginProcess);
  }
View Full Code Here

Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

      NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException,
      NoPeerConnectionException {
    File testFile = new File(rootDirectory, "test-file");
    FileUtils.write(testFile, "Hello World");

    IProcessComponent process = loggedInNode.getFileManager().add(testFile);
    UseCaseTestUtil.executeProcess(process);

    // is now added; delete it
    process = loggedInNode.getFileManager().delete(testFile);
    UseCaseTestUtil.executeProcess(process);
View Full Code Here

Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

    File folder2 = new File(folder1, "folder2");
    folder2.mkdir();
    File test2File = new File(folder2, "test2.txt");
    FileUtils.write(test2File, "Hello World 2");

    IProcessComponent process = loggedInNode.getFileManager().add(folder1);
    UseCaseTestUtil.executeProcess(process);

    // 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.processes.framework.interfaces.IProcessComponent

    Assert.assertNotNull(network.get(random.nextInt(NETWORK_SIZE)).getPeer());
  }

  @After
  public void logoutAndUnregister() throws NoSessionException, NoPeerConnectionException {
    IProcessComponent process = loggedInNode.getUserManager().logout();
    UseCaseTestUtil.executeProcess(process);

    // TODO unregister
  }
View Full Code Here

Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

      }

      protected void execute() throws NoPeerConnectionException, InterruptedException,
          InvalidProcessStateException {

        IProcessComponent loginProcess = menus
            .getNodeMenu()
            .getNode()
            .getUserManager()
            .login(menus.getUserMenu().getUserCredentials(),
                menus.getFileMenu().getRootDirectory().toPath());

        boolean success = executeBlocking(loginProcess, displayText);
        // reset user configs as they might be wrong
        if (!success) {
          menus.getUserMenu().reset();
          menus.getFileMenu().reset();
        }
      }
    });

    add(new H2HConsoleMenuItem("Logout") {
      protected boolean checkPreconditions() throws Exception {
        return checkLogin();
      }

      protected void execute() throws Exception {

        IProcessComponent logoutProcess = menus.getNodeMenu().getNode().getUserManager().logout();
        executeBlocking(logoutProcess, displayText);
      }
    });

    add(new H2HConsoleMenuItem("File Menu") {
View Full Code Here

Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

    if (userManager.isRegistered(userCredentials.getUserId())) {
      return true;
    } else {
      H2HConsoleMenuItem
          .printPrecondition("You are not registered to the network. This will now happen automatically.");
      IProcessComponent registerProcess = userManager.register(userCredentials);
      return executeBlocking(registerProcess, "Register");
    }
  }
View Full Code Here

Examples of org.hive2hive.core.processes.framework.interfaces.IProcessComponent

      throw new IllegalArgumentException("Root cannot be added.");
    } else if (!FileUtil.isInH2HDirectory(file, session)) {
      throw new IllegalFileLocation();
    }

    IProcessComponent addProcess;
    if (file.isDirectory() && file.listFiles().length > 0) {
      // add the files recursively
      List<Path> preorderList = FileRecursionUtil.getPreorderList(file.toPath());
      addProcess = FileRecursionUtil.buildUploadProcess(preorderList, FileProcessAction.NEW_FILE,
          networkManager);
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.