public class ProfileOrganizer extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ProfileOrganizer.Slice
Defines peer selection slicing modes for tier-based peer organization.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
ABSOLUTE_MAX_PROFILES |
static int |
DEFAULT_MINIMUM_FAST_PEERS |
static int |
DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS |
static String |
PROP_MAX_PROFILES |
static String |
PROP_MINIMUM_FAST_PEERS |
static String |
PROP_MINIMUM_HIGH_CAPACITY_PEERS |
| Constructor and Description |
|---|
ProfileOrganizer(RouterContext context) |
| Modifier and Type | Method and Description |
|---|---|
PeerProfile |
addProfile(PeerProfile profile) |
(package private) void |
clearProfiles() |
int |
countActivePeers() |
int |
countActivePeersInLastHour() |
int |
countFastPeers() |
int |
countHighCapacityPeers() |
int |
countNotFailingPeers() |
boolean |
exportProfile(Hash profile,
OutputStream out) |
double |
getCapacityThreshold() |
static int |
getDefaultMaxProfiles()
Calculate default max profiles based on available heap memory.
|
double |
getIntegrationThreshold() |
protected int |
getMaximumFastPeers() |
protected int |
getMaximumHighCapPeers() |
protected int |
getMinimumFastPeers() |
protected int |
getMinimumHighCapacityPeers() |
(package private) PeerProfile |
getOrCreateProfileNonblocking(Hash peer) |
PeerProfile |
getProfile(Hash peer) |
PeerProfile |
getProfileNonblocking(Hash peer) |
double |
getSpeedThreshold() |
double |
getTunnelBuildSuccess()
Get the current tunnel build success rate.
|
Hash |
getUs() |
boolean |
isFast(Hash peer) |
boolean |
isHighCapacity(Hash peer) |
boolean |
isLowBuildSuccess() |
boolean |
isSelectable(Hash peer) |
boolean |
isWellIntegrated(Hash peer) |
static void |
main(String[] args) |
boolean |
peerSendsBadReplies(Hash peer) |
void |
purgeStaleProfileFiles() |
(package private) void |
reorganize() |
(package private) void |
reorganize(boolean shouldCoalesce,
boolean shouldDecay)
Reorganizes peer profiles into performance-based tiers (fast, high-capacity, etc.) and expires stale entries.
|
void |
selectActiveNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches) |
void |
selectActiveNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask,
MaskedIPSet ipSet) |
void |
selectAllNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
boolean onlyNotFailing) |
Set<Hash> |
selectAllPeers() |
void |
selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches) |
void |
selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask,
MaskedIPSet ipSet) |
void |
selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
SessionKey randomKey,
ProfileOrganizer.Slice subTierMode,
int mask,
MaskedIPSet ipSet) |
void |
selectHighCapacityPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches) |
void |
selectHighCapacityPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask,
MaskedIPSet ipSet) |
void |
selectNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches) |
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) |
void |
selectNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask,
MaskedIPSet ipSet) |
void |
setUs(Hash us) |
public static final int ABSOLUTE_MAX_PROFILES
public static final int DEFAULT_MINIMUM_FAST_PEERS
public static final int DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS
public static final String PROP_MAX_PROFILES
public static final String PROP_MINIMUM_FAST_PEERS
public static final String PROP_MINIMUM_HIGH_CAPACITY_PEERS
public ProfileOrganizer(RouterContext context)
public PeerProfile addProfile(PeerProfile profile)
void clearProfiles()
public int countActivePeers()
public int countActivePeersInLastHour()
public int countFastPeers()
public int countHighCapacityPeers()
public int countNotFailingPeers()
public boolean exportProfile(Hash profile, OutputStream out) throws IOException
IOExceptionpublic double getCapacityThreshold()
public static int getDefaultMaxProfiles()
public double getIntegrationThreshold()
protected int getMaximumFastPeers()
protected int getMaximumHighCapPeers()
protected int getMinimumFastPeers()
protected int getMinimumHighCapacityPeers()
PeerProfile getOrCreateProfileNonblocking(Hash peer)
public PeerProfile getProfile(Hash peer)
public PeerProfile getProfileNonblocking(Hash peer)
public double getSpeedThreshold()
public double getTunnelBuildSuccess()
public Hash getUs()
public boolean isFast(Hash peer)
public boolean isHighCapacity(Hash peer)
public boolean isLowBuildSuccess()
public boolean isSelectable(Hash peer)
public boolean isWellIntegrated(Hash peer)
public static void main(String[] args)
public boolean peerSendsBadReplies(Hash peer)
public void purgeStaleProfileFiles()
void reorganize()
void reorganize(boolean shouldCoalesce,
boolean shouldDecay)
This method:
Memory Safety: To prevent unbounded memory growth (e.g., OOM after 8+ hours), this method ensures that expired profiles are removed from all data structures—even if the full reorganization is skipped due to lock contention. A best-effort expiration pass runs outside the write lock to mitigate leaks during high contention.
shouldCoalesce - if true, coalesce statistics for active profilesshouldDecay - if true and coalescing is performed, apply decay to historical statspublic void selectActiveNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches)
public void selectActiveNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask,
MaskedIPSet ipSet)
public void selectAllNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
boolean onlyNotFailing)
public void selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask,
MaskedIPSet ipSet)
public void selectFastPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
SessionKey randomKey,
ProfileOrganizer.Slice subTierMode,
int mask,
MaskedIPSet ipSet)
public 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)
public void selectNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches)
public 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)
public void selectNotFailingPeers(int howMany,
Set<Hash> exclude,
Set<Hash> matches,
int mask,
MaskedIPSet ipSet)
public void setUs(Hash us)