- All Implemented Interfaces:
ProfileManager
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RouterContextThe router context the profiles belong to.private final LogLogger for this class.Constructor Summary
ConstructorsConstructorDescriptionProfileManagerImpl(RouterContext context) Creates the manager and its logger from the given context.Method Summary
Modifier and TypeMethodDescriptionvoiddbLookupFailed(Hash peer) Note that the peer was unable to reply to a db lookup - either with data or with a lookupReply redirecting the user elsewherevoiddbLookupReceived(Hash peer) Note that the local router received a db lookup from the given peervoiddbLookupReply(Hash peer, int newPeers, int oldPeers, int invalid, int duplicate, long responseTimeMs) The peer replied to a db lookup with a redirect to other routers.voiddbLookupSuccessful(Hash peer, long responseTimeMs) Note that the peer was able to return the valid data for a db lookupvoiddbStoreFailed(Hash peer) Note that we were unable to confirm a successful send of db data to the peer, at least not within our timeout periodvoiddbStoreReceived(Hash peer, boolean wasNewKey) Note that the local router received an unprompted db store from the given peervoiddbStoreSent(Hash peer, long responseTimeMs) Note that we've confirmed a successful send of db data to the peer (though we haven't necessarily requested it again from them, so they /might/ be lying)voiddbStoreSuccessful(Hash peer) Note that we've verified a successful send of db data to the floodfill peer by querying another floodfill.private PeerProfilegetProfile(Hash peer) Blocking.private PeerProfilegetProfileNonblocking(Hash peer) Non-blocking.voidheardAbout(Hash peer) Note that the local router received a reference to the given peer, either through an explicit dbStore or in a dbLookupReply Non-blocking.voidheardAbout(Hash peer, long when) Note that the local router received a reference to the given peer at a certain time.voidmessageFailed(Hash peer) Note that the router failed to send a message to the peer over any transport.voidmessageFailed(Hash peer, String transport) Note that the router failed to send a message to the peer over the transport specified.voidmessageReceived(Hash peer, String style, long msToReceive, int bytesRead) Note that the router received a message from the given peer on the specified transport.voidmessageSent(Hash peer, String transport, long msToSend, long bytesSent) Note that it took msToSend to send a message of size bytesSent to the peer over the transport.voidpeerLossEvent(Hash peer, float ratio) Record the packet-loss (retransmit) ratio measured by the transport for a peer.voidtunnelDataPushed(Hash peer, long rtt, long size) Non-blocking.voidtunnelDataPushed1m(Hash peer, long size) Non-blocking.voidtunnelFailed(Hash peer, int pct) Note that the peer participated in a tunnel that failed.voidtunnelJoined(Hash peer, long responseTimeMs) Note that the router agreed to participate in a tunnel.voidtunnelLifetimePushed(Hash peer, long lifetime, long size) Non-blocking.voidtunnelRejected(Hash peer, long responseTimeMs, int severity) Note that a router explicitly rejected joining a tunnel.voidtunnelTestSucceeded(Hash peer, long responseTimeMs) Note that a tunnel that the router is participating in was successfully tested with the given round trip latencyvoidtunnelTimedOut(Hash peer) Note that a router did not respond to a tunnel join.(package private) voidCompute floodfill reliability fromDBHistory.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ProfileManager
commErrorOccurredModifier and TypeMethodDescriptionvoidcommErrorOccurred(Hash peer) Note that there was some sort of communication error talking with the peer.
Field Details
_log
Logger for this class._context
The router context the profiles belong to.
Constructor Details
ProfileManagerImpl
Creates the manager and its logger from the given context.- Parameters:
context- the router context whose log manager supplies our logger
Method Details
messageSent
Note that it took msToSend to send a message of size bytesSent to the peer over the transport. This should only be called if the transport considered the send successful. Non-blocking. Will not update the profile if we can't get the lock.This runs per message, so the cost is one
getOrCreateProfileNonblocking— atryReadLock()plus a map probe — and, on the rare miss, onetryWriteLock()to insert the newly created profile. Both are non-blocking, so neither can stall the transport thread behind reorganize; seepeerLossEvent(Hash, float)for why the write-lock attempt is not a contention hazard. Left unchanged deliberately: the profile must exist forsetLastSendSuccessfulto be recorded at all, so a non-creating variant would silently drop first-contact send-success timestamps.- Specified by:
messageSentin interfaceProfileManager- Parameters:
peer- hash of the peer the message was sent totransport- style of the transport that carried the messagemsToSend- milliseconds the send tookbytesSent- size of the message in bytes
peerLossEvent
Record the packet-loss (retransmit) ratio measured by the transport for a peer. Non-blocking. Will not update the profile if we can't get the lock.Note on the write lock below:
ProfileOrganizer.demoteIfLossy(Hash)does attempt the reorganize write lock, but it usestryWriteLock(), which returns immediately rather than waiting, and the caller is already committed to the non-blocking contract of this method — so the message path cannot be stalled by reorganize. Frequency is also bounded well below message rate:PeerState.reportLossRatioonly calls this when the retransmit ratio crosses a 5% bucket after at leastProfileOrganizer.PROP_LOSSY_MIN_PACKETSpackets, so the write-lock attempt happens at most once per bucket per connection, not per packet. The check is left in place deliberately: dropping it would leave a lossy peer in the fast/high-cap tiers until the next reorganize judged it.- Specified by:
peerLossEventin interfaceProfileManager- Parameters:
peer- hash of the peer the loss was measured onratio- retransmitted / transmitted packets, 0.0 = healthy
messageFailed
Note that the router failed to send a message to the peer over the transport specified. Non-blocking. Will not update the profile if we can't get the lock.- Specified by:
messageFailedin interfaceProfileManager- Parameters:
peer- hash of the peer the send to failedtransport- style of the transport the send failed on
messageFailed
Note that the router failed to send a message to the peer over any transport. Non-blocking. Will not update the profile if we can't get the lock.- Specified by:
messageFailedin interfaceProfileManager- Parameters:
peer- hash of the peer the send to failed
tunnelJoined
Note that the router agreed to participate in a tunnel.- Specified by:
tunnelJoinedin interfaceProfileManager- Parameters:
peer- hash of the peer that agreed to joinresponseTimeMs- milliseconds the peer took to accept the request
tunnelRejected
Note that a router explicitly rejected joining a tunnel.- Specified by:
tunnelRejectedin interfaceProfileManager- Parameters:
peer- who rejected usresponseTimeMs- response time in msseverity- how much the peer doesnt want to participate in the tunnel (large == more severe)
tunnelTimedOut
Note that a router did not respond to a tunnel join.Since TunnelHistory doesn't have a timeout stat, pretend we were rejected for bandwidth reasons.
- Specified by:
tunnelTimedOutin interfaceProfileManager- Parameters:
peer- who rejected us
tunnelTestSucceeded
Note that a tunnel that the router is participating in was successfully tested with the given round trip latencyNon-blocking. Will not update the profile if we can't get the lock.
- Specified by:
tunnelTestSucceededin interfaceProfileManager- Parameters:
peer- hash of the peer on the far end of the tunnelresponseTimeMs- round trip latency of the test in milliseconds
tunnelDataPushed
Non-blocking. Will not update the profile if we can't get the lock.- Specified by:
tunnelDataPushedin interfaceProfileManager- Parameters:
peer- hash of the peer participating in the tunnelrtt- round trip latency in milliseconds, not used in the rate accountingsize- bytes pushed, accumulated into a long so a period total exceeding 2 GB is not truncated
tunnelDataPushed1m
Non-blocking. Will not update the profile if we can't get the lock.- Specified by:
tunnelDataPushed1min interfaceProfileManager- Parameters:
peer- hash of the peer participating in the tunnelsize- bytes pushed during the period, normalized to a minute
tunnelLifetimePushed
Non-blocking. Will not update the profile if we can't get the lock.- Specified by:
tunnelLifetimePushedin interfaceProfileManager- Parameters:
peer- hash of the peer participating in the tunnellifetime- age of the tunnel in millisecondssize- bytes pushed over the lifetime of the tunnel
tunnelFailed
Note that the peer participated in a tunnel that failed. Its failure may not have been the peer's fault however. Blame the peer with a probability of pct/100.- Specified by:
tunnelFailedin interfaceProfileManager- Parameters:
peer- hash of the peer that participated in the tunnelpct- chance of blaming the peer for the failure, 0-100 percent
dbLookupSuccessful
Note that the peer was able to return the valid data for a db lookupThis will force creation of DB stats Non-blocking. Will not update the profile if we can't get the lock.
- Specified by:
dbLookupSuccessfulin interfaceProfileManager- Parameters:
peer- hash of the peer that answeredresponseTimeMs- milliseconds the peer took to answer
dbLookupFailed
Note that the peer was unable to reply to a db lookup - either with data or with a lookupReply redirecting the user elsewhereThis will force creation of DB stats Non-blocking. Will not update the profile if we can't get the lock.
- Specified by:
dbLookupFailedin interfaceProfileManager- Parameters:
peer- hash of the peer that did not answer
dbLookupReply
public void dbLookupReply(Hash peer, int newPeers, int oldPeers, int invalid, int duplicate, long responseTimeMs) The peer replied to a db lookup with a redirect to other routers. The redirect list included newPeers routers we did not previously know about, oldPeers routers we already had profiles for, the given invalid routers that were unusable, and a count of duplicates we had explicitly asked them not to send but they did anywayNon-blocking. Will not update the profile if we can't get the lock.
- Specified by:
dbLookupReplyin interfaceProfileManager- Parameters:
peer- hash of the peer that sent the redirectnewPeers- redirected routers we did not previously know aboutoldPeers- redirected routers we already had profiles forinvalid- redirected routers that were unusableduplicate- redirected routers we had explicitly excludedresponseTimeMs- milliseconds the peer took to answer
dbLookupReceived
Note that the local router received a db lookup from the given peerNon-blocking. Will not update the profile if we can't get the lock.
- Specified by:
dbLookupReceivedin interfaceProfileManager- Parameters:
peer- hash of the peer that sent the lookup to us
dbStoreReceived
Note that the local router received an unprompted db store from the given peerNon-blocking. Will not update the profile if we can't get the lock.
- Specified by:
dbStoreReceivedin interfaceProfileManager- Parameters:
peer- hash of the peer that sent the storewasNewKey- true if the stored key was not already in our database
dbStoreSent
Note that we've confirmed a successful send of db data to the peer (though we haven't necessarily requested it again from them, so they /might/ be lying)As of 0.9.53 we update the DbResponseTime.
This will force creation of DB stats.
- Specified by:
dbStoreSentin interfaceProfileManager- Parameters:
peer- hash of the peer we sent the data toresponseTimeMs- the measured send duration in milliseconds, used as both the value and the event time
dbStoreSuccessful
Note that we've verified a successful send of db data to the floodfill peer by querying another floodfill.This will force creation of DB stats.
- Specified by:
dbStoreSuccessfulin interfaceProfileManager- Parameters:
peer- hash of the peer that verified the stored data
updateFloodfillReliability
Compute floodfill reliability fromDBHistory. Updates the peer's reliability classification based on successful/failed lookup and store counts.Thresholds: - UNKNOWN: 0 successful lookups (probing target) - OK: 1-4 successful lookups with >=50% success rate - GOOD: >=5 successful lookups with >=80% success rate - BAD: >=5 total lookups with <50% success rate.
- Parameters:
data- the peer profile, must have expanded DB profile
dbStoreFailed
Note that we were unable to confirm a successful send of db data to the peer, at least not within our timeout periodThis will force creation of DB stats.
- Specified by:
dbStoreFailedin interfaceProfileManager- Parameters:
peer- hash of the peer that did not verify the stored data
heardAbout
Note that the local router received a reference to the given peer, either through an explicit dbStore or in a dbLookupReply Non-blocking. Will not update the profile if we can't get the lock.- Specified by:
heardAboutin interfaceProfileManager- Parameters:
peer- the hash of the peer we learned about
heardAbout
Note that the local router received a reference to the given peer at a certain time. Only update the time if newer. Non-blocking. Will not update the profile if we can't get the lock.- Specified by:
heardAboutin interfaceProfileManager- Parameters:
peer- the hash of the peer we learned aboutwhen- the timestamp when we learned about the peer
messageReceived
Note that the router received a message from the given peer on the specified transport. Messages received without any "from" information aren't recorded through this metric. If msToReceive is negative, there was no timing information available. Non-blocking. Will not update the profile if we can't get the lock.Same per-message cost profile as
messageSent(Hash, String, long, long), and the same decision to leave it alone: onetryReadLock()plus a map probe on the hot path, with no lock escalation that could block the caller.- Specified by:
messageReceivedin interfaceProfileManager- Parameters:
peer- hash of the peer that sent the messagestyle- transport style the message arrived overmsToReceive- milliseconds the receive took, negative if untimedbytesRead- size of the message in bytes
getProfile
Blocking. Creates a new profile if it didn't exist.- Parameters:
peer- the router hash whose profile is wanted- Returns:
- non-null
getProfileNonblocking
Non-blocking. Creates a new profile if it didn't exist.- Parameters:
peer- the router hash whose profile is wanted- Returns:
- null if the fetch or create would have blocked