public class PeerProfile extends Object
| Constructor and Description |
|---|
PeerProfile(RouterContext context,
Hash peer)Caller should call setLastHeardAbout() and setFirstHeardAbout() |
| Modifier and Type | Method and Description |
|---|---|
(package private) void | coalesceOnly(boolean shouldDecay)Caller must next call updateValues(). |
void | coalesceStats()Coalesce all stats and update values |
(package private) void | dataPushed(int size)Record data pushed through this peer. |
(package private) void | dataPushed1m(int size)The tunnel pushed that much data in a 1 minute period. |
boolean | equals(Object obj) |
void | expandDBProfile()For floodfills |
void | expandProfile()When the given peer is performing well enough that we want to keep detailed
stats on them again, call this to set up the info we dropped during shrinkProfile. |
int | getCapacityBonus()extra factor added to the capacity ranking - this can be updated in the profile
written to disk to affect how the algorithm ranks capacity. |
(package private) long | getCapacityBonusLastUpdate() |
(package private) int | getCapacityBonusRaw() |
float | getCapacityValue()How many tunnels do we think this peer can handle over the next hour? |
(package private) RouterContext | getContext()Helper for calculators. |
DBHistory | getDBHistory()History of DB activity with the peer. |
RateStat | getDbIntroduction()How many new peers we get from dbSearchReplyMessages or dbStore messages. |
RateStat | getDbResponseTime()How long it takes to get a DB response from the peer (in milliseconds). |
long | getFirstHeardAbout()When did we first hear about this peer? |
int | getIntegrationBonus()extra factor added to the integration ranking - this can be updated in the profile
written to disk to affect how the algorithm ranks integration. |
float | getIntegrationValue()How well integrated into the network is this peer (as measured by how much they've
told us that we didn't already know). |
boolean | getIsActive()Is this peer active at the moment (sending/receiving messages within the last
10 minutes) |
boolean | getIsActive(long now)Is this peer active at the moment (sending/receiving messages within the last 10 minutes) |
boolean | getIsActive(long period,
long now)Is this peer active at the moment (sending/receiving messages within the
given period?)
Also mark active if it is connected, as this will tend to encourage use
of already-connected peers. |
boolean | getIsExpanded()Whether the tunnel profile data has been allocated (RateStats, TunnelHistory). |
boolean | getIsExpandedDB()Whether the DB profile data has been allocated. |
long | getLastHeardAbout()when did we last hear about this peer? |
long | getLastHeardFrom()When did we last hear from the peer? |
long | getLastSendFailed()When did we last have a problem sending to this peer? |
long | getLastSendSuccessful()When did we last send to this peer successfully? |
long | getLastTestedSuccessfully()When the peer last passed a tunnel test successfully. |
long | getLastTestStarted() |
(package private) long | getLastThroughputUpdate() |
float | getPeakThroughputKBps() |
float | getPeakTunnel1mThroughputKBps()This is the speed value |
float | getPeakTunnelThroughputKBps() |
Hash | getPeer()what peer is being profiled |
float | getPeerTestTimeAverage() |
int | getSpeedBonus()Obsolete — prefer isLowLatency(). |
float | getSpeedValue()How fast is the peer, taking into consideration both throughput and latency. |
double | getTunnelAcceptanceRatio()Tunnel acceptance ratio from tunnel history. |
RateStat | getTunnelCreateResponseTime()How long it takes to get a tunnel create response from the peer (in milliseconds). |
TunnelHistory | getTunnelHistory()History of tunnel activity with the peer. |
float | getTunnelTestTimeAverage() |
(package private) long | getTunnelTestTimeAvgLastUpdate() |
(package private) int | getXORDistance()For now, just a one-byte comparison |
int | hashCode() |
(package private) boolean | isEstablished()Is this peer established? |
boolean | isLowLatency()Low latency flag, set when this peer has been observed to respond quickly
to tunnel build requests. |
(package private) boolean | isSameCountry()Is the peer in the same country as us? |
(package private) void | recalculateLowLatency()Recalculate the low-latency flag from the accumulated peer test time average. |
void | setCapacityBonus(int bonus) |
(package private) void | setCapacityBonusLastUpdate(long ts) |
void | setDBHistory(DBHistory hist)Set the DB history. |
(package private) void | setFirstHeardAbout(long when)Set when did we first heard about this peer, only if older. |
void | setIntegrationBonus(int bonus) |
void | setLastHeardAbout(long when)Set when did we last hear about this peer, only if unset or newer. |
void | setLastHeardFrom(long when)Set when we last heard from the peer. |
void | setLastSendFailed(long when)Set when we last had a problem sending to this peer. |
void | setLastSendSuccessful(long when)Set when we last sent to this peer successfully. |
(package private) void | setLastTestStarted(long ts) |
(package private) void | setLastThroughputUpdate(long ts) |
void | setLowLatency(boolean low)Set the low latency flag. |
(package private) void | setPeakThroughputKBps(float kBps)Only for restoration from persisted profile. |
(package private) void | setPeakTunnel1mThroughputKBps(float kBps)Only for restoration from persisted profile. |
(package private) void | setPeakTunnelThroughputKBps(float kBps)Only for restoration from persisted profile. |
(package private) void | setPeerTestTimeAverage(float testAvg) |
void | setSpeedBonus(int bonus)Obsolete — prefer setLowLatency(boolean). |
void | setTunnelHistory(TunnelHistory history)Set the tunnel history. |
(package private) void | setTunnelTestTimeAverage(float avg)Set the tunnel test time average. |
(package private) void | setTunnelTestTimeAvgLastUpdate(long ts)Set the timestamp of the last tunnel test time average update. |
void | shrinkDBProfile()Shrink the DB-specific part of the profile. |
void | shrinkProfile()Shrink the profile by dropping the RateStat objects. |
String | toString() |
(package private) void | tunnelDataTransferred(long tunnelByteLifetime)The tunnel pushed that much data in its lifetime. |
(package private) void | updatePeerTestTimeAverage(float ms)Update peer test time average. |
(package private) void | updateTunnelTestTimeAverage(float ms)Update the tunnel test time average with a new measurement. |
void | updateValues()Update the speed, capacity, and integration values from the new values. |
boolean | wasUnreachable()Was the peer previously unreachable? |
public PeerProfile(RouterContext context, Hash peer)
context - the router contextpeer - non-nullvoid coalesceOnly(boolean shouldDecay)
shouldDecay - whether to decay peak throughput valuespublic void coalesceStats()
void dataPushed(int size)
size - the number of bytes pushedvoid dataPushed1m(int size)
size - the number of bytes in that minutepublic void expandDBProfile()
public void expandProfile()
public int getCapacityBonus()
long getCapacityBonusLastUpdate()
int getCapacityBonusRaw()
public float getCapacityValue()
RouterContext getContext()
public DBHistory getDBHistory()
public RateStat getDbIntroduction()
public RateStat getDbResponseTime()
public long getFirstHeardAbout()
public int getIntegrationBonus()
public float getIntegrationValue()
public boolean getIsActive()
public boolean getIsActive(long now)
now - current timepublic boolean getIsActive(long period,
long now)period - must be one of the periods in the RateStat constructors below
(5*60*1000 or 60*60*1000)now - current timepublic boolean getIsExpanded()
public boolean getIsExpandedDB()
public long getLastHeardAbout()
public long getLastHeardFrom()
public long getLastSendFailed()
public long getLastSendSuccessful()
public long getLastTestedSuccessfully()
public long getLastTestStarted()
long getLastThroughputUpdate()
public float getPeakThroughputKBps()
public float getPeakTunnel1mThroughputKBps()
public float getPeakTunnelThroughputKBps()
public Hash getPeer()
public float getPeerTestTimeAverage()
public int getSpeedBonus()
isLowLatency(). Retained for backward compatibility
with stored profile data. Returns 0 unconditionally if not set, or the stored
value with a 4-hour expiry for existing profiles that still carry it.public float getSpeedValue()
public double getTunnelAcceptanceRatio()
public RateStat getTunnelCreateResponseTime()
public TunnelHistory getTunnelHistory()
public float getTunnelTestTimeAverage()
long getTunnelTestTimeAvgLastUpdate()
int getXORDistance()
boolean isEstablished()
public boolean isLowLatency()
boolean isSameCountry()
void recalculateLowLatency()
public void setCapacityBonus(int bonus)
bonus - the capacity bonusvoid setCapacityBonusLastUpdate(long ts)
ts - the timestamppublic void setDBHistory(DBHistory hist)
hist - the DBHistoryvoid setFirstHeardAbout(long when)
when - the time to setpublic void setIntegrationBonus(int bonus)
bonus - the integration bonuspublic void setLastHeardAbout(long when)
when - the time to setpublic void setLastHeardFrom(long when)
when - the timestamppublic void setLastSendFailed(long when)
when - the timestamppublic void setLastSendSuccessful(long when)
when - the timestampvoid setLastTestStarted(long ts)
ts - the timestampvoid setLastThroughputUpdate(long ts)
ts - the timestamppublic void setLowLatency(boolean low)
low - true for low latencyvoid setPeakThroughputKBps(float kBps)
kBps - the peak throughput in KBpsvoid setPeakTunnel1mThroughputKBps(float kBps)
kBps - the peak 1-minute throughput in KBpsvoid setPeakTunnelThroughputKBps(float kBps)
kBps - the peak tunnel throughput in KBpsvoid setPeerTestTimeAverage(float testAvg)
testAvg - the peer test time averagepublic void setSpeedBonus(int bonus)
setLowLatency(boolean). Retained for
backward compatibility with stored profile data.bonus - the speed bonuspublic void setTunnelHistory(TunnelHistory history)
history - the TunnelHistoryvoid setTunnelTestTimeAverage(float avg)
avg - the average in msvoid setTunnelTestTimeAvgLastUpdate(long ts)
ts - the timestamppublic void shrinkDBProfile()
public void shrinkProfile()
void tunnelDataTransferred(long tunnelByteLifetime)
tunnelByteLifetime - total bytes transferredvoid updatePeerTestTimeAverage(float ms)
ms - the new measurement in msvoid updateTunnelTestTimeAverage(float ms)
ms - the new measurement in mspublic void updateValues()
public boolean wasUnreachable()