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()
Deprecated.
|
int |
countFastPeers() |
int |
countHighCapacityPeers() |
int |
countNotFailingPeers() |
int |
countWellIntegratedPeers()
Deprecated.
use ProfileManager.getPeersByCapability('f').size()
|
boolean |
exportProfile(Hash profile,
OutputStream out)
Only for console
|
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.
|
(package private) PeerProfile |
getOrCreateProfileNonblocking(Hash peer)
Retrieve the profile for the given peer, if one exists.
|
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.
unused
|
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).
|
(package private) void |
reorganize()
Place peers into the correct tier, as well as expand/contract and even drop profiles
according to whatever limits are in place.
|
(package private) void |
reorganize(boolean shouldCoalesce,
boolean shouldDecay) |
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 |
selectActiveNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask,
MaskedIPSet ipSet)
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 |
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,
int mask,
MaskedIPSet ipSet)
Return a set of Hashes for peers that are both fast and reliable.
|
void |
selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
SessionKey randomKey,
ProfileOrganizer.Slice subTierMode,
int mask,
MaskedIPSet ipSet)
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,
MaskedIPSet ipSet) |
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,
MaskedIPSet ipSet)
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,
MaskedIPSet ipSet) |
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)
PeerProfile getOrCreateProfileNonblocking(Hash peer)
public PeerProfile addProfile(PeerProfile profile)
public int countFastPeers()
public int countHighCapacityPeers()
@Deprecated public int countWellIntegratedPeers()
public int countNotFailingPeers()
@Deprecated public int countFailingPeers()
public int countActivePeers()
public boolean isFast(Hash peer)
public boolean isHighCapacity(Hash peer)
public boolean isWellIntegrated(Hash peer)
@Deprecated 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, MaskedIPSet ipSet)
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 matchipSet
- in/out param, use for multiple calls, may be null only if mask is 0public void selectFastPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, SessionKey randomKey, ProfileOrganizer.Slice subTierMode, int mask, MaskedIPSet ipSet)
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
mask
- 0-4ipSet
- in/out param, use for multiple calls, may be null only if mask is 0public void selectHighCapacityPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
public void selectHighCapacityPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, int mask, MaskedIPSet ipSet)
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 matchipSet
- in/out param, use for multiple calls, may be null only if mask is 0public void selectNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
public void selectNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, int mask, MaskedIPSet ipSet)
mask
- ignored, should call locked_selectPeers, to be fixedipSet
- 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, MaskedIPSet ipSet)
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 fixedipSet
- ignored, should call locked_selectPeers, to be fixedpublic void selectActiveNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches)
exclude
- non-null, not-connected peers will NOT be added, as of 0.9.58public void selectActiveNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, int mask, MaskedIPSet ipSet)
exclude
- non-null, not-connected peers will NOT be added, as of 0.9.58mask
- 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 matchipSet
- may be null only if mask is 0public void selectAllNotFailingPeers(int howMany, Set<Hash> exclude, Set<Hash> matches, boolean onlyNotFailing)
public Set<Hash> selectAllPeers()
void reorganize()
void reorganize(boolean shouldCoalesce, boolean shouldDecay)
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]*