net.tomp2p.futures
Class FutureRouting

java.lang.Object
  extended by net.tomp2p.futures.BaseFutureImpl<FutureRouting>
      extended by net.tomp2p.futures.FutureRouting
All Implemented Interfaces:
BaseFuture, Cancellable

public class FutureRouting
extends BaseFutureImpl<FutureRouting>

The routing future keeps track of the routing process. This means that the routing future is returned immediately and the routing process starts in the background. There are two ways to wait for the routing process: (1) to use await*, which blocks the current thread and waits for the routing process to complete, or (2) to use addListener*, which will be called when the routing process completes. The listener may or may not run in the same thread. The routing will always succeed if we do DHT operations or bootstrap to ourself. It will fail if we bootstrap to another peer, but could not contact any peer than ourself.

Author:
Thomas Bocek
See Also:
#setNeighbors(SortedSet, SortedSet, SortedSet, boolean, boolean)

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.tomp2p.futures.BaseFuture
BaseFuture.FutureType
 
Field Summary
 
Fields inherited from class net.tomp2p.futures.BaseFutureImpl
completed, lock, reason, type
 
Constructor Summary
FutureRouting()
           
 
Method Summary
 NavigableSet<PeerAddress> getDirectHits()
          The direct hits set contains those peers that reported to have the key (Number160) we were looking for.
 SortedMap<PeerAddress,DigestInfo> getDirectHitsDigest()
          The direct hits map contains those peers that reported to have the key (Number160) we were looking for including its digest (size of the result set and its xored hashes).
 String getFailedReason()
          The default failed reason is Unknown.
 NavigableSet<PeerAddress> getPotentialHits()
          The potential hits set contains those peers that are in the direct hit and that did report to *not* have the key (Number160) we were looking for.
 SortedSet<PeerAddress> getRoutingPath()
          Returns the peers that have been asked to provide neighbor information.
 void setNeighbors(SortedMap<PeerAddress,DigestInfo> directHits, NavigableSet<PeerAddress> potentialHits, SortedSet<PeerAddress> routingPath, boolean isBootstrap, boolean isRoutingToOther)
          Sets the result of the routing process and finishes the future.
 
Methods inherited from class net.tomp2p.futures.BaseFutureImpl
addCancellation, addListener, addListener, await, await, awaitListeners, awaitUninterruptibly, awaitUninterruptibly, cancel, getType, isCompleted, isFailed, isSuccess, notifyListerenrs, removeListener, self, setCompletedAndNotify, setFailed, setFailed, setFailed, setFailed, setFailed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FutureRouting

public FutureRouting()
Method Detail

setNeighbors

public void setNeighbors(SortedMap<PeerAddress,DigestInfo> directHits,
                         NavigableSet<PeerAddress> potentialHits,
                         SortedSet<PeerAddress> routingPath,
                         boolean isBootstrap,
                         boolean isRoutingToOther)
Sets the result of the routing process and finishes the future. This will notify all listeners. The future will always succeed if we do DHT operations or bootstrap to ourself. It will fail if we bootstrap to another peer, but could not contact any peer than ourself.

Parameters:
directHits - The direct hits, the peers in the direct set that reports to have the key (Number160) we were looking for.
potentialHits - The potential hits, the peers in the direct set and those peers that reports to *not* have the key (Number160) we were looking for.
routingPath - A set of peers that took part in the routing process.
isBootstrap - Whether the future was triggered by the bootstrap process or the a P2P process
isRoutingToOther - Whether routing peers have been specified others than myself.
See Also:
getDirectHits(), getDirectHitsDigest(), getPotentialHits(), getRoutingPath()

getPotentialHits

public NavigableSet<PeerAddress> getPotentialHits()
The potential hits set contains those peers that are in the direct hit and that did report to *not* have the key (Number160) we were looking for. We already check for the content during routing, since we send the information what we are looking for anyway, so a reply if the content exists or not is not very expensive. However, a peer may lie about this.

Returns:
The potential hits, the peers in the direct set and those peers that reports to *not* have the key (Number160) we were looking for.
See Also:
getDirectHits(), getDirectHitsDigest()

getDirectHits

public NavigableSet<PeerAddress> getDirectHits()
The direct hits set contains those peers that reported to have the key (Number160) we were looking for. We already check for the content during routing, since we send the information what we are looking for anyway, so a reply if the content exists or not is not very expensive. However, a peer may lie about this.

Returns:
The direct hits, the peers in the direct set that reports to have the key (Number160) we were looking for.
See Also:
getPotentialHits(), getDirectHitsDigest()

getDirectHitsDigest

public SortedMap<PeerAddress,DigestInfo> getDirectHitsDigest()
The direct hits map contains those peers that reported to have the key (Number160) we were looking for including its digest (size of the result set and its xored hashes). We already check for the content during routing, since we send the information what we are looking for anyway, so a reply if the content exists or not is not very expensive. However, a peer may lie about this.

Returns:
The direct hits including its digest (size of the result set and its xored hashes), when a peer reports to have the key (Number160) we were looking for.
See Also:
getPotentialHits(), getDirectHits()

getRoutingPath

public SortedSet<PeerAddress> getRoutingPath()
Returns the peers that have been asked to provide neighbor information. The order is sorted by peers that were close to the target.

Returns:
A set of peers that took part in the routing process.

getFailedReason

public String getFailedReason()
Description copied from interface: BaseFuture
The default failed reason is Unknown.

Specified by:
getFailedReason in interface BaseFuture
Overrides:
getFailedReason in class BaseFutureImpl<FutureRouting>
Returns:
Returns the reason why a future failed.


Copyright © 2013. All Rights Reserved.