net.tomp2p.storage
Class TrackerStorage

java.lang.Object
  extended by net.tomp2p.storage.TrackerStorage
All Implemented Interfaces:
PeerStatusListener, Digest, ReplicationStorage

public class TrackerStorage
extends Object
implements PeerStatusListener, Digest, ReplicationStorage

The maintenance for the tracker is done by the client peer. Thus the peers on a tracker expire, but a client can send a Bloom filter with peers, that he knows are offline. TrackerStorage stores the data in memory only. TODO: check availability of secondary peers and periodically check if peers from the mesh are still online, right now we rely on the PeerMap mechanism

Author:
draft

Nested Class Summary
static class TrackerStorage.ReferrerType
           
 
Nested classes/interfaces inherited from interface net.tomp2p.peers.PeerStatusListener
PeerStatusListener.Reason
 
Field Summary
static int TRACKER_CACHE_SIZE
           
static int TRACKER_SIZE
           
 
Constructor Summary
TrackerStorage(IdentityManagement identityManagement, int trackerTimoutSeconds, PeerBean peerBean, Maintenance maintenance)
           
 
Method Summary
 Map<Number160,TrackerData> activePeers(Number160 locationKey, Number160 domainKey)
           
 void addActive(Number160 locationKey, Number160 domainKey, PeerAddress remotePeer, byte[] attachement, int offset, int length)
           
 DigestInfo digest(Number160 locationKey, Number160 domainKey, Collection<Number160> contentKeys)
          Calculates a digest over a specific location and domain.
 DigestInfo digest(Number160 locationKey, Number160 domainKey, SimpleBloomFilter<Number160> bloomFilter1, SimpleBloomFilter<Number160> bloomFilter2)
          Calculates a digest over a specific location and domain.
 Collection<Number160> findContentForResponsiblePeerID(Number160 peerID)
           
 Number160 findPeerIDForResponsibleContent(Number160 locationKey)
           
 int getPrimanyFactor()
           
 int getSecondaryFactor()
           
 int getTrackerTimoutSeconds()
           
 boolean isFillPrimaryStorageFast()
           
 boolean isSecondaryTracker(Number160 locationKey, Number160 domainKey)
          A peer is a secondary tracker if the peers stores itself on the tracker as well.
 Map<Number160,TrackerData> meshPeers(Number160 locationKey, Number160 domainKey)
           
 boolean moveFromSecondaryToMesh(PeerAddress peerAddress, PeerAddress referrer, Number160 locationKey, Number160 domainKey, PublicKey publicKey)
           
 void peerFail(PeerAddress peerAddress, boolean force)
          Called if the peer does not send answer in time.
 void peerOffline(PeerAddress peerAddress, PeerStatusListener.Reason reason)
          Called if the peer does not send multiple answer in time.
 void peerOnline(PeerAddress peerAddress)
          Called if the peer is online and we verified it.
 boolean put(Number160 locationKey, Number160 domainKey, PeerAddress peerAddress, PublicKey publicKey, byte[] attachement)
           
 boolean put(Number160 locationKey, Number160 domainKey, PeerAddress peerAddress, PublicKey publicKey, byte[] attachement, int offset, int length)
           
 boolean putReferred(Number160 locationKey, Number160 domainKey, PeerAddress peerAddress, PeerAddress referrer, byte[] attachement, int offset, int length, TrackerStorage.ReferrerType type)
           
 boolean removeActive(Number160 locationKey, Number160 domainKey, Number160 remotePeerId)
           
 void removeReferred(Number160 locationKey, Number160 domainKey, Number160 key, PeerAddress referrer)
           
 void removeResponsibility(Number160 locationKey)
           
 Collection<Number160> responsibleDomains(Number160 locationKey)
           
 Map<Number160,TrackerData> secondaryPeers(Number160 locationKey, Number160 domainKey)
           
 void setFillPrimaryStorageFast(boolean fillPrimaryStorageFast)
           
 void setPrimanyFactor(int primanyFactor)
           
 void setSecondaryFactor(int secondaryFactor)
           
 int sizePrimary(Number160 locationKey, Number160 domainKey)
           
 int sizeSecondary(Number160 locationKey, Number160 domainKey)
           
 boolean updateResponsibilities(Number160 locationKey, Number160 peerId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACKER_SIZE

public static final int TRACKER_SIZE
See Also:
Constant Field Values

TRACKER_CACHE_SIZE

public static final int TRACKER_CACHE_SIZE
See Also:
Constant Field Values
Constructor Detail

TrackerStorage

public TrackerStorage(IdentityManagement identityManagement,
                      int trackerTimoutSeconds,
                      PeerBean peerBean,
                      Maintenance maintenance)
Method Detail

activePeers

public Map<Number160,TrackerData> activePeers(Number160 locationKey,
                                              Number160 domainKey)

meshPeers

public Map<Number160,TrackerData> meshPeers(Number160 locationKey,
                                            Number160 domainKey)

secondaryPeers

public Map<Number160,TrackerData> secondaryPeers(Number160 locationKey,
                                                 Number160 domainKey)

addActive

public void addActive(Number160 locationKey,
                      Number160 domainKey,
                      PeerAddress remotePeer,
                      byte[] attachement,
                      int offset,
                      int length)

removeActive

public boolean removeActive(Number160 locationKey,
                            Number160 domainKey,
                            Number160 remotePeerId)

put

public boolean put(Number160 locationKey,
                   Number160 domainKey,
                   PeerAddress peerAddress,
                   PublicKey publicKey,
                   byte[] attachement)

put

public boolean put(Number160 locationKey,
                   Number160 domainKey,
                   PeerAddress peerAddress,
                   PublicKey publicKey,
                   byte[] attachement,
                   int offset,
                   int length)

putReferred

public boolean putReferred(Number160 locationKey,
                           Number160 domainKey,
                           PeerAddress peerAddress,
                           PeerAddress referrer,
                           byte[] attachement,
                           int offset,
                           int length,
                           TrackerStorage.ReferrerType type)

moveFromSecondaryToMesh

public boolean moveFromSecondaryToMesh(PeerAddress peerAddress,
                                       PeerAddress referrer,
                                       Number160 locationKey,
                                       Number160 domainKey,
                                       PublicKey publicKey)

sizePrimary

public int sizePrimary(Number160 locationKey,
                       Number160 domainKey)

sizeSecondary

public int sizeSecondary(Number160 locationKey,
                         Number160 domainKey)

setSecondaryFactor

public void setSecondaryFactor(int secondaryFactor)

getSecondaryFactor

public int getSecondaryFactor()

setPrimanyFactor

public void setPrimanyFactor(int primanyFactor)

getPrimanyFactor

public int getPrimanyFactor()

peerOffline

public void peerOffline(PeerAddress peerAddress,
                        PeerStatusListener.Reason reason)
Description copied from interface: PeerStatusListener
Called if the peer does not send multiple answer in time. This peer is considered offline

Specified by:
peerOffline in interface PeerStatusListener
Parameters:
peerAddress - The address of the peer that went offline

peerFail

public void peerFail(PeerAddress peerAddress,
                     boolean force)
Description copied from interface: PeerStatusListener
Called if the peer does not send answer in time. The peer may be busy, so there is a chance of seeing this peer again.

Specified by:
peerFail in interface PeerStatusListener
Parameters:
peerAddress - The address of the peer that failed
force - Set to true if we are sure that the peer died.

peerOnline

public void peerOnline(PeerAddress peerAddress)
Description copied from interface: PeerStatusListener
Called if the peer is online and we verified it. This method may get called many times, for each successful request.

Specified by:
peerOnline in interface PeerStatusListener
Parameters:
peerAddress - The address of the peer that is online.

digest

public DigestInfo digest(Number160 locationKey,
                         Number160 domainKey,
                         SimpleBloomFilter<Number160> bloomFilter1,
                         SimpleBloomFilter<Number160> bloomFilter2)
Description copied from interface: Digest
Calculates a digest over a specific location and domain. It will return those content keys that match the Bloom filter. Those keys that are not stored are ignored

Specified by:
digest in interface Digest
Parameters:
locationKey - The location key
domainKey - The domain key
bloomFilter1 - The bloomFilter of those key elements we want the digest. Please not that there might be false positive, e.g., a Number160 that is included in the digest but not stored on disk/memory.
bloomFilter2 - The bloomFilter of those data elements we want the digest. Please not that there might be false positive, e.g., a Number160 that is included in the digest but not stored on disk/memory.
Returns:
A list of all hashes for the content keys. To return a predictable amount (important for routing), the hashes can be xored.

digest

public DigestInfo digest(Number160 locationKey,
                         Number160 domainKey,
                         Collection<Number160> contentKeys)
Description copied from interface: Digest
Calculates a digest over a specific location and domain. It will return those content keys that are stored. Those keys that are not stored are ignored

Specified by:
digest in interface Digest
Parameters:
locationKey - The location key
domainKey - The domain key
contentKeys - The content keys to look for. Those keys that are not found are ignored. Can be set to null -> gets the information for all content keys
Returns:
A list of all hashes for the content keys. To return a predictable amount (important for routing), the hashes can be xored.

removeReferred

public void removeReferred(Number160 locationKey,
                           Number160 domainKey,
                           Number160 key,
                           PeerAddress referrer)

setFillPrimaryStorageFast

public void setFillPrimaryStorageFast(boolean fillPrimaryStorageFast)

isFillPrimaryStorageFast

public boolean isFillPrimaryStorageFast()

getTrackerTimoutSeconds

public int getTrackerTimoutSeconds()

isSecondaryTracker

public boolean isSecondaryTracker(Number160 locationKey,
                                  Number160 domainKey)
A peer is a secondary tracker if the peers stores itself on the tracker as well. The primary trackers do not behave like this.

Parameters:
locationKey -
domainKey -
Returns:

responsibleDomains

public Collection<Number160> responsibleDomains(Number160 locationKey)

findPeerIDForResponsibleContent

public Number160 findPeerIDForResponsibleContent(Number160 locationKey)
Specified by:
findPeerIDForResponsibleContent in interface ReplicationStorage

findContentForResponsiblePeerID

public Collection<Number160> findContentForResponsiblePeerID(Number160 peerID)
Specified by:
findContentForResponsiblePeerID in interface ReplicationStorage

updateResponsibilities

public boolean updateResponsibilities(Number160 locationKey,
                                      Number160 peerId)
Specified by:
updateResponsibilities in interface ReplicationStorage

removeResponsibility

public void removeResponsibility(Number160 locationKey)
Specified by:
removeResponsibility in interface ReplicationStorage


Copyright © 2013. All Rights Reserved.