Package com.subgraph.orchid

Examples of com.subgraph.orchid.Router


   * @param routerFilter
   * @return The chosen router or 'null' if no suitable router is available.
   */
  public Router chooseRandomNode(WeightRule rule, RouterFilter routerFilter) {
    final List<Router> candidates = getFilteredRouters(routerFilter, true);
    final Router choice = chooseByBandwidth(candidates, rule);
    if(choice == null) {
      // try again with more permissive flags
      return null;
    }
    return choice;
View Full Code Here


   
    return routers;
  }

  private Router chooseByBandwidth(List<Router> candidates, WeightRule rule) {
    final Router choice = chooseNodeByBandwidthWeights(candidates, rule);
    if(choice != null) {
      return choice;
    } else {
      return chooseNodeByBandwidth(candidates, rule);
    }
View Full Code Here

    return usableRouters;
  }
 
  private void addRouterIfUsableAndNotExcluded(GuardEntry entry, Set<Router> excluded, List<Router> routers) {
    if(entry.testCurrentlyUsable() && entry.getDownSince() == null) {
      final Router r = entry.getRouterForEntry();
      if(r != null && !excluded.contains(r)) {
        routers.add(r);
      }
    }
  }
View Full Code Here

  }

  private void addPendingInitialConnections(Set<Router> routerSet) {
    for(GuardEntry entry: pendingProbes) {
      if(!entry.isAdded()) {
        Router r = entry.getRouterForEntry();
        if(r != null) {
          routerSet.add(r);
        }
      }
    }
View Full Code Here

  }

  private void maybeChooseNew(int usableSize, int minSize, Set<Router> excluded) {
    int sz = usableSize + countPendingInitialProbes();
    while(sz < minSize) { 
      Router newGuard = chooseNewGuard(excluded);
      if(newGuard == null) {
        logger.warning("Need to add entry guards but no suitable guard routers are available");
        return;
      }
      logger.fine("Testing "+ newGuard + " as a new guard since we only have "+ usableSize + " usable guards");
View Full Code Here

    this.entryGuards = entryGuards;
    this.entry = entry;
  }
 
  public void run() {
    final Router router = entry.getRouterForEntry();
    if(router == null) {
      entryGuards.probeConnectionFailed(entry);
      return;
    }
    try {
View Full Code Here

    }
    return 0;
  }
 
  private String getHexIdForIndex(int idx) {
    final Router r = hsDirectories.get(idx);
    return r.getIdentityHash().toString();
  }
View Full Code Here

    }
  }
 
  private void swap(List<Router> dirs, int idx1, int idx2) {
    if(idx1 != idx2) {
      final Router r1 = dirs.get(idx1);
      final Router r2 = dirs.get(idx2);
      dirs.set(idx1, r2);
      dirs.set(idx2, r1);
    }
  }
View Full Code Here

TOP

Related Classes of com.subgraph.orchid.Router

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.