Package org.hive2hive.core.model

Examples of org.hive2hive.core.model.Locations


    this.networkManager = networkManager;
  }

  @Override
  protected void doExecute() throws InvalidProcessStateException {
    Locations locations = context.consumeLocations();

    if (unreachablePeers.isEmpty()) {
      logger.debug("No locations to remove. Skip the cleanup.");
      return;
    }

    KeyPair protectionKeys;
    try {
      protectionKeys = networkManager.getSession().getProfileManager().getDefaultProtectionKey();
    } catch (GetFailedException | NoSessionException e) {
      logger.error("Could not get the protection keys.", e);
      return;
    }

    for (PeerAddress toRemove : unreachablePeers) {
      locations.removePeerAddress(toRemove);
    }

    locations.setBasedOnKey(locations.getVersionKey());

    try {
      locations.generateVersionKey();
    } catch (IOException e) {
      logger.error("Version key could not be generated.");
      return;
    }

    try {
      put(locations.getUserId(), H2HConstants.USER_LOCATIONS, locations, protectionKeys);
    } catch (PutFailedException e) {
      logger.error("Could not put the updated locations.");
    }
  }
View Full Code Here


    for (String userId : context.consumeUsersToNotify()) {
      NetworkContent content = get(userId, H2HConstants.USER_LOCATIONS);
      if (content == null) {
        allLocations.put(userId, new ArrayList<PeerAddress>());
      } else {
        Locations currentLoc = (Locations) content;
        List<PeerAddress> addresses = new ArrayList<PeerAddress>(currentLoc.getPeerAddresses());
        allLocations.put(userId, addresses);
      }
    }

    // done with all locations
View Full Code Here

  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {

    Locations locations = context.consumeLocations();

    if (locations == null) {
      throw new ProcessExecutionException("Locations not found.");
    } else {

      // remove peer
      locations.removePeerAddress(networkManager.getConnection().getPeer().getPeerAddress());
      locations.setBasedOnKey(locations.getVersionKey());
      try {
        locations.generateVersionKey();
      } catch (IOException e) {
        throw new ProcessExecutionException("Version key could not be generated.", e);
      }

      // put updated locations
View Full Code Here

TOP

Related Classes of org.hive2hive.core.model.Locations

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.