Package org.hive2hive.core.processes.framework.abstracts

Examples of org.hive2hive.core.processes.framework.abstracts.ProcessComponent


    // deletion must happen in reverse tree order. Since this is very complicated when it contains
    // asynchronous components, we simply delete them all in the same thread (reverse preorder of course)
    Collections.reverse(files);
    for (Path file : files) {
      ProcessComponent deletionProcess = ProcessFactory.instance().createDeleteFileProcess(
          file.toFile(), networkManager);
      rootProcess.add(deletionProcess);
    }

    return new AsyncComponent(rootProcess);
View Full Code Here


    Map<FolderIndex, SequentialProcess> folderMap = new HashMap<FolderIndex, SequentialProcess>();
    Map<FileIndex, AsyncComponent> fileMap = new HashMap<FileIndex, AsyncComponent>();

    for (Index file : files) {
      PublicKey fileKey = file.getFilePublicKey();
      ProcessComponent downloadProcess = ProcessFactory.instance().createDownloadFileProcess(fileKey,
          networkManager);
      if (file.isFolder()) {
        // when a directory, the process may have multiple children, thus we need a sequential process
        SequentialProcess folderProcess = new SequentialProcess();
        folderProcess.add(downloadProcess);
View Full Code Here

    return this;
  }

  @Override
  public IProcessComponent register(UserCredentials credentials) throws NoPeerConnectionException {
    ProcessComponent registerProcess = ProcessFactory.instance().createRegisterProcess(credentials, networkManager);

    CompletionHandleComponent eventComponent = new CompletionHandleComponent(registerProcess,
        createRegisterHandle(credentials));

    AsyncComponent asyncProcess = new AsyncComponent(eventComponent);
View Full Code Here

  protected void notifyOtherClients(BaseNotificationMessageFactory messageFactory)
      throws IllegalArgumentException, NoPeerConnectionException, InvalidProcessStateException,
      NoSessionException {
    Set<String> onlyMe = new HashSet<String>(1);
    onlyMe.add(networkManager.getUserId());
    ProcessComponent notificationProcess = ProcessFactory.instance().createNotificationProcess(
        messageFactory, onlyMe, networkManager);
    notificationProcess.start();
  }
View Full Code Here

     */

    // download remotely added/updated files
    List<Index> toDownload = new ArrayList<Index>(synchronizer.getAddedRemotely());
    toDownload.addAll(synchronizer.getUpdatedRemotely());
    ProcessComponent downloadProcess = FileRecursionUtil.buildDownloadProcess(toDownload, networkManager);
    getParent().add(downloadProcess);

    // upload the locally added files
    List<Path> toUploadNewFiles = synchronizer.getAddedLocally();
    ProcessComponent addProcess = FileRecursionUtil.buildUploadProcess(toUploadNewFiles,
        FileProcessAction.NEW_FILE, networkManager);
    getParent().add(addProcess);

    // upload the locally updated files
    List<Path> toUploadModifiedFiles = synchronizer.getUpdatedLocally();
    ProcessComponent updateProcess = FileRecursionUtil.buildUploadProcess(toUploadModifiedFiles,
        FileProcessAction.MODIFY_FILE, networkManager);
    getParent().add(updateProcess);

    // remove files from the DHT that have been deleted locally
    List<Index> toDeleteInDHT = synchronizer.getDeletedLocally();
    ProcessComponent deletionProcess = FileRecursionUtil.buildDeletionProcessFromNodelist(toDeleteInDHT,
        networkManager);
    getParent().add(deletionProcess);

    // delete the remotely deleted files (is done directly here)
    List<Path> toDeleteOnDisk = synchronizer.getDeletedRemotely();
View Full Code Here

  }

  private void downloadSingle() {
    try {
      logger.debug("Got notified and start to download the file '{}'.", index.getName());
      ProcessComponent process = ProcessFactory.instance().createDownloadFileProcess(
          index.getFilePublicKey(), networkManager);
      process.start();
    } catch (Exception e) {
      logger.error("Got notified but cannot download the file.", e);
    }
  }
View Full Code Here

  }

  private void downloadTree(FolderIndex folder) {
    List<Index> files = Index.getIndexList(folder);
    try {
      ProcessComponent process = FileRecursionUtil.buildDownloadProcess(files, networkManager);
      process.start();
      logger.debug("Got notified and start downloading a file tree.");
    } catch (Exception e) {
      logger.error("Could not download the full tree.", e);
    }
  }
View Full Code Here

    startNotification();
  }

  private void startDownload() {
    try {
      ProcessComponent process = ProcessFactory.instance().createDownloadFileProcess(
          index.getFilePublicKey(), networkManager);
      logger.debug("Start downloading the file '{}'.", index.getFullPath());
      process.start();
    } catch (NoSessionException | InvalidProcessStateException e) {
      logger.error("Could not start the download of the newly shared file.");
    }
  }
View Full Code Here

  @Override
  public void run() {
    logger.debug("Received a user profile task notification from '{}'.", senderId);
    try {
      ProcessComponent process = ProcessFactory.instance().createUserProfileTaskStep(networkManager);
      process.start();
    } catch (InvalidProcessStateException e) {
      logger.error("Cannot handle user profile task queue. Currently no user is logged in.");
    }
  }
View Full Code Here

    logger.debug("Notified other client that new (shared) files are available for download.");

    /** 3. download the files that are now available */
    List<Index> fileList = Index.getIndexList(sharedIndex);
    // the folder itself is also contained, so remove it
    ProcessComponent downloadProcess = FileRecursionUtil.buildDownloadProcess(fileList, networkManager);
    logger.debug("Start to download {} files that have been shared with me.", fileList.size());
    downloadProcess.start();
  }
View Full Code Here

TOP

Related Classes of org.hive2hive.core.processes.framework.abstracts.ProcessComponent

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.