net.tomp2p.storage
Class TrackerStorage
java.lang.Object
net.tomp2p.storage.TrackerStorage
- All Implemented Interfaces:
- PeerStatusListener, Digest
public class TrackerStorage
- extends Object
- implements PeerStatusListener, Digest
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
|
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(Number320 key)
|
DigestInfo |
digest(Number320 key,
Collection<Number160> contentKeys)
|
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)
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)
|
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)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TRACKER_SIZE
public static final int TRACKER_SIZE
- See Also:
- Constant Field Values
TrackerStorage
public TrackerStorage(IdentityManagement identityManagement,
int trackerTimoutSeconds,
Replication replication,
Maintenance maintenance)
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)
- 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
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(Number320 key)
- Specified by:
digest in interface Digest
digest
public DigestInfo digest(Number320 key,
Collection<Number160> contentKeys)
- Specified by:
digest in interface Digest
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)
Copyright © 2011. All Rights Reserved.