Class HostTrackingServiceImpl
java.lang.Object
edu.ucsb.cs156.diningcachingproxy.services.HostTrackingService
edu.ucsb.cs156.diningcachingproxy.services.HostTrackingServiceImpl
In-memory implementation of
HostTrackingService. Everything is keyed by the raw remote
address internally, since a hostname (if any) is only known once resolveHostname(String, String) is called - which may happen well after the first request from that address was already
counted, since resolution runs as an asynchronous job.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEvery host seen so far with its request count, sorted by host (hostname, or IP if unresolved).booleanrecordRequest(String remoteAddress) Records a single request from the given remote address (the caller's true IP, already resolved from X-Forwarded-For where applicable).voidresolveHostname(String remoteAddress, String hostname) Updates the display name shown for a previously-seen address - called once a hostname resolution attempt for it completes (successfully or not).
-
Constructor Details
-
HostTrackingServiceImpl
public HostTrackingServiceImpl()
-
-
Method Details
-
recordRequest
Description copied from class:HostTrackingServiceRecords a single request from the given remote address (the caller's true IP, already resolved from X-Forwarded-For where applicable).- Specified by:
recordRequestin classHostTrackingService- Returns:
- true if this is the first time this exact address has been seen
-
resolveHostname
Description copied from class:HostTrackingServiceUpdates the display name shown for a previously-seen address - called once a hostname resolution attempt for it completes (successfully or not).- Specified by:
resolveHostnamein classHostTrackingService
-
getHostCounts
Description copied from class:HostTrackingServiceEvery host seen so far with its request count, sorted by host (hostname, or IP if unresolved).- Specified by:
getHostCountsin classHostTrackingService
-