public class ProfileOrganizer extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ProfileOrganizer.Slice
Replaces integer subTierMode argument, for clarity
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MINIMUM_FAST_PEERS |
static int |
DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS |
static String |
PROP_MINIMUM_FAST_PEERS
Defines the minimum number of 'fast' peers that the organizer should select.
|
static String |
PROP_MINIMUM_HIGH_CAPACITY_PEERS
Defines the minimum number of 'high capacity' peers that the organizer should
select when using the mean - if less than this many are available, select the
capacity by the median.
|
Constructor and Description |
---|
ProfileOrganizer(RouterContext context) |
Modifier and Type | Method and Description |
---|---|
PeerProfile |
addProfile(PeerProfile profile)
Add the new profile, returning the old value (or null if no profile existed)
|
(package private) void |
clearProfiles() |
int |
countActivePeers() |
int |
countFailingPeers() |
int |
countFastPeers() |
int |
countHighCapacityPeers() |
int |
countNotFailingPeers() |
int |
countWellIntegratedPeers()
Deprecated.
use ProfileManager.getPeersByCapability('f').size()
|
boolean |
exportProfile(Hash profile,
OutputStream out) |
double |
getCapacityThreshold() |
double |
getIntegrationThreshold() |
protected int |
getMaximumFastPeers()
fixme add config @since 0.7.10
|
protected int |
getMaximumHighCapPeers()
fixme add config @since 0.7.11
|
protected int |
getMinimumFastPeers()
Defines the minimum number of 'fast' peers that the organizer should select.
|
protected int |
getMinimumHighCapacityPeers()
Defines the minimum number of 'fast' peers that the organizer should select.
|
PeerProfile |
getProfile(Hash peer)
Retrieve the profile for the given peer, if one exists (else null).
|
PeerProfile |
getProfileNonblocking(Hash peer)
Retrieve the profile for the given peer, if one exists (else null).
|
double |
getSpeedThreshold() |
Hash |
getUs() |
boolean |
isFailing(Hash peer)
Deprecated for now, always false
|
boolean |
isFast(Hash peer) |
boolean |
isHighCapacity(Hash peer) |
boolean |
isSelectable(Hash peer) |
boolean |
isWellIntegrated(Hash peer) |
static void |
main(String[] args)
Read in all of the profiles specified and print out
their calculated values.
|
boolean |
peerSendsBadReplies(Hash peer)
Does the given peer send us bad replies - either invalid store messages
(expired, corrupt, etc) or unreachable replies (pointing towards routers
that don't exist).
|
void |
reorganize()
Place peers into the correct tier, as well as expand/contract and even drop profiles
according to whatever limits are in place.
|
void |
reorganize(boolean shouldCoalesce) |
void |
selectActiveNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches)
Return a set of Hashes for peers that are both not failing and we're actively
talking with.
|
void |
selectAllNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
boolean onlyNotFailing)
Return a set of Hashes for peers that are not failing.
|
Set<Hash> |
selectAllPeers()
Find the hashes for all peers we are actively profiling
|
void |
selectFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches)
I'm not quite sure why you'd want this...
|
void |
selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches)
Return a set of Hashes for peers that are both fast and reliable.
|
void |
selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
Hash randomKey,
ProfileOrganizer.Slice subTierMode)
Return a set of Hashes for peers that are both fast and reliable.
|
void |
selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask)
Return a set of Hashes for peers that are both fast and reliable.
|
void |
selectHighCapacityPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches)
Return a set of Hashes for peers that have a high capacity
|
void |
selectHighCapacityPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask) |
void |
selectNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches)
Return a set of Hashes for peers that are not failing, preferring ones that
we are already talking with
|
void |
selectNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
boolean onlyNotFailing) |
void |
selectNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
boolean onlyNotFailing,
int mask)
Return a set of Hashes for peers that are not failing, preferring ones that
we are already talking with
|
void |
selectNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask) |
List<Hash> |
selectPeersLocallyUnreachable()
Get the peers the transport layer thinks are unreachable, and
add in the peers with the SSU peer testing bug,
and peers requiring introducers.
|
List<Hash> |
selectPeersRecentlyRejecting()
Get the peers that have recently rejected us for bandwidth
recent == last 20s
|
void |
selectWellIntegratedPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches)
Deprecated.
unused
|
void |
selectWellIntegratedPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask)
Deprecated.
unused
|
void |
setUs(Hash us) |
public static final String PROP_MINIMUM_FAST_PEERS
getMinimumFastPeers()
public static final int DEFAULT_MINIMUM_FAST_PEERS
public static final String PROP_MINIMUM_HIGH_CAPACITY_PEERS
public static final int DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS
public ProfileOrganizer(RouterContext context)
public void setUs(Hash us)
public Hash getUs()
public double getSpeedThreshold()
public double getCapacityThreshold()
public double getIntegrationThreshold()
public PeerProfile getProfile(Hash peer)
public PeerProfile getProfileNonblocking(Hash peer)
public PeerProfile addProfile(PeerProfile profile)
public int countFastPeers()
public int countHighCapacityPeers()
@Deprecated public int countWellIntegratedPeers()
public int countNotFailingPeers()
public int countFailingPeers()
public int countActivePeers()
public boolean isFast(Hash peer)
public boolean isHighCapacity(Hash peer)
public boolean isWellIntegrated(Hash peer)
public boolean isFailing(Hash peer)
void clearProfiles()
public boolean peerSendsBadReplies(Hash peer)
public boolean exportProfile(Hash profile, OutputStream out) throws IOException
IOException
public void selectFastPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
howMany
- how many peers are desiredexclude
- set of Hashes for routers that we don't want selectedmatches
- set to store the return value inpublic void selectFastPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, int mask)
howMany
- how many peers are desiredexclude
- set of Hashes for routers that we don't want selectedmatches
- set to store the return value inmask
- 0-4 Number of bytes to match to determine if peers in the same IP range should
not be in the same tunnel. 0 = disable check; 1 = /8; 2 = /16; 3 = /24; 4 = exact IP matchpublic void selectFastPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, Hash randomKey, ProfileOrganizer.Slice subTierMode)
howMany
- how many peers are desiredexclude
- set of Hashes for routers that we don't want selectedmatches
- set to store the return value inrandomKey
- used for deterministic random partitioning into subtierssubTierMode
- 0 or 2-7:
0: no partitioning, use entire tier 2: return only from group 0 or 1 3: return only from group 2 or 3 4: return only from group 0 5: return only from group 1 6: return only from group 2 7: return only from group 3
public void selectHighCapacityPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
public void selectHighCapacityPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, int mask)
mask
- 0-4 Number of bytes to match to determine if peers in the same IP range should
not be in the same tunnel. 0 = disable check; 1 = /8; 2 = /16; 3 = /24; 4 = exact IP match@Deprecated public void selectWellIntegratedPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
@Deprecated public void selectWellIntegratedPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, int mask)
mask
- 0-4 Number of bytes to match to determine if peers in the same IP range should
not be in the same tunnel. 0 = disable check; 1 = /8; 2 = /16; 3 = /24; 4 = exact IP matchpublic void selectNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
public void selectNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, int mask)
mask
- ignored, should call locked_selectPeers, to be fixedpublic void selectNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, boolean onlyNotFailing)
public void selectNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, boolean onlyNotFailing, int mask)
howMany
- how many peers to findexclude
- what peers to skip (may be null)matches
- set to store the matches inonlyNotFailing
- if true, don't include any high capacity peersmask
- ignored, should call locked_selectPeers, to be fixedpublic void selectActiveNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
exclude
- non-null, WARNING - side effect, all not-connected peers are added
No mask parameter, to be fixedpublic void selectAllNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, boolean onlyNotFailing)
public void selectFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
public List<Hash> selectPeersLocallyUnreachable()
public List<Hash> selectPeersRecentlyRejecting()
public Set<Hash> selectAllPeers()
public void reorganize()
public void reorganize(boolean shouldCoalesce)
public boolean isSelectable(Hash peer)
protected int getMinimumFastPeers()
protected int getMaximumFastPeers()
protected int getMaximumHighCapPeers()
protected int getMinimumHighCapacityPeers()
public static void main(String[] args)
ProfileOrganizer [filename]*