Examples of AsyncComponent


Examples of org.hive2hive.core.processes.framework.decorators.AsyncComponent

  public void awaitAsyncTest() throws InvalidProcessStateException, InterruptedException {
   
    // succeeding process
    SequentialProcess process = new SequentialProcess();
    process.add(new BusySucceedingStep());
    AsyncComponent asyncProcess = new AsyncComponent(process);
    asyncProcess.start();
    asyncProcess.await();
    if (asyncProcess.getState() != ProcessState.SUCCEEDED)
      fail("Busy process should have finished. Await() did not block.");
    TestUtil.wait(TestUtil.DEFAULT_WAITING_TIME);
    assertTrue(asyncProcess.getState() == ProcessState.SUCCEEDED);
   
    // failing process
    SequentialProcess process2 = new SequentialProcess();
    process2.add(new BusyFailingStep());
    AsyncComponent asyncProcess2 = new AsyncComponent(process2);
    asyncProcess2.start();
    asyncProcess2.await();
    if (asyncProcess2.getState() != ProcessState.FAILED)
      fail("Busy process should have finished. Await() did not block.");
    TestUtil.wait(TestUtil.DEFAULT_WAITING_TIME);
    assertTrue(asyncProcess2.getState() == ProcessState.FAILED);
  }
View Full Code Here

Examples of org.hive2hive.core.processes.framework.decorators.AsyncComponent

    for (int i = 0; i < operations.length; i++) {
      TestUserProfileStep proc = new TestUserProfileStep(manager, operations[i]);
      TestProcessComponentListener listener = new TestProcessComponentListener();
      proc.attachListener(listener);

      processes.add(new AsyncComponent(proc));
      listeners.add(listener);
    }

    // start, but not all at the same time
    for (IProcessComponent process : processes) {
View Full Code Here

Examples of org.hive2hive.core.processes.framework.decorators.AsyncComponent

      }
    }

    // the children are now grouped together. Next, we need to link the parent files.
    for (Path parent : sameParents.keySet()) {
      AsyncComponent asyncChain = new AsyncComponent(sameParents.get(parent));
      Path parentOfParent = parent.getParent();
      if (sameParents.containsKey(parentOfParent)) {
        // parent exists, we add this sub-process (sequential) to it. It can be async here
        SequentialProcess sequentialProcess = sameParents.get(parentOfParent);
        sequentialProcess.add(asyncChain);
View Full Code Here

Examples of org.hive2hive.core.processes.framework.decorators.AsyncComponent

      ProcessComponent deletionProcess = ProcessFactory.instance().createDeleteFileProcess(
          file.toFile(), networkManager);
      rootProcess.add(deletionProcess);
    }

    return new AsyncComponent(rootProcess);
  }
View Full Code Here

Examples of org.hive2hive.core.processes.framework.decorators.AsyncComponent

        SequentialProcess folderProcess = new SequentialProcess();
        folderProcess.add(downloadProcess);
        folderMap.put((FolderIndex) file, folderProcess);
      } else {
        // when a file, the process can run in parallel with all siblings (done in next step)
        fileMap.put((FileIndex) file, new AsyncComponent(downloadProcess));
      }
    }

    // find children with same parents and make them run in parallel
    // idea: iterate through all children and search for parent in other map. If not there, they can be
    // added to the root process anyway
    for (FileIndex file : fileMap.keySet()) {
      AsyncComponent fileProcess = fileMap.get(file);
      Index parent = file.getParent();
      if (parent == null) {
        // file is in root, thus we can add it to the root process
        rootProcess.add(fileProcess);
      } else if (folderMap.containsKey(parent)) {
        // the parent exists here
        SequentialProcess parentProcess = folderMap.get(parent);
        parentProcess.add(fileProcess);
      } else {
        // file is not in root and parent is not here, thus we simply add it to the root process
        rootProcess.add(fileProcess);
      }
    }

    // files and folder are linked. We now link the folders with other folders
    for (FolderIndex folder : folderMap.keySet()) {
      SequentialProcess folderProcess = folderMap.get(folder);
      // In addition, we can make this process run asynchronous because it does not affect the siblings
      AsyncComponent asyncFolderProcess = new AsyncComponent(folderProcess);
      Index parent = folder.getParent();
      if (parent == null) {
        // file is in root, thus we can add it to the root process.
        rootProcess.add(asyncFolderProcess);
      } else if (folderMap.containsKey(parent)) {
View Full Code Here

Examples of org.hive2hive.core.processes.framework.decorators.AsyncComponent

    ProvideUserLocationsContext context = new ProvideUserLocationsContext();

    SequentialProcess process = new SequentialProcess();
    for (String user : task.getUsers()) {
      GetUserLocationsStep step = new GetUserLocationsStep(user, context, dataManager);
      process.add(new AsyncComponent(step));
    }

    try {
      logger.debug("Started getting the list of locations to download {}", task.getDestinationName());
      process.start().await();
View Full Code Here

Examples of org.hive2hive.core.processes.framework.decorators.AsyncComponent

        ChunkPKUpdateContext chunkContext = new ChunkPKUpdateContext(
            context.consumeOldProtectionKeys(), context.consumeNewProtectionKeys(), metaChunk);

        // create the step and wrap it to run asynchronous, attach it to the parent process
        ChangeProtectionKeysStep changeStep = new ChangeProtectionKeysStep(chunkContext, dataManager);
        getParent().add(new AsyncComponent(changeStep));
        counter++;
      }
    }

    logger.debug("{} chunks of file '{}' need to update their protection keys.", counter,
View Full Code Here

Examples of org.hive2hive.core.processes.framework.decorators.AsyncComponent

  private void initForFile(FileIndex fileIndex) throws NoSessionException, NoPeerConnectionException {
    logger.debug("Initialize to change the protection keys of meta document of index '{}'.",
        fileIndex.getName());
    // create the process and make wrap it to make it asynchronous
    getParent().add(new AsyncComponent(buildProcess(fileIndex)));
  }
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.