Class HostTrackingService
java.lang.Object
edu.ucsb.cs156.diningcachingproxy.services.HostTrackingService
- Direct Known Subclasses:
HostTrackingServiceImpl
Tracks which hosts have sent requests through the proxy, and how many times each has done so.
Abstracted behind this base class so the storage mechanism (in-memory today) can later be swapped
for a persisted one (Mongo/SQL) without changing callers.
Every address is tracked under its own raw form (e.g. an IP address) until a hostname is
resolved for it - resolution happens out-of-band (see ResolveHostnameJob), since it can
be asynchronous.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEvery host seen so far with its request count, sorted by host (hostname, or IP if unresolved).abstract 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).abstract 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
-
HostTrackingService
public HostTrackingService()
-
-
Method Details
-
recordRequest
Records a single request from the given remote address (the caller's true IP, already resolved from X-Forwarded-For where applicable).- Returns:
- true if this is the first time this exact address has been seen
-
resolveHostname
-
getHostCounts
-