Class HostTrackingServiceImpl

java.lang.Object
edu.ucsb.cs156.diningcachingproxy.services.HostTrackingService
edu.ucsb.cs156.diningcachingproxy.services.HostTrackingServiceImpl

@Service public class HostTrackingServiceImpl extends HostTrackingService
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 Details

    • HostTrackingServiceImpl

      public HostTrackingServiceImpl()
  • Method Details

    • recordRequest

      public boolean recordRequest(String remoteAddress)
      Description copied from class: HostTrackingService
      Records a single request from the given remote address (the caller's true IP, already resolved from X-Forwarded-For where applicable).
      Specified by:
      recordRequest in class HostTrackingService
      Returns:
      true if this is the first time this exact address has been seen
    • resolveHostname

      public void resolveHostname(String remoteAddress, String hostname)
      Description copied from class: HostTrackingService
      Updates the display name shown for a previously-seen address - called once a hostname resolution attempt for it completes (successfully or not).
      Specified by:
      resolveHostname in class HostTrackingService
    • getHostCounts

      public List<HostCount> getHostCounts()
      Description copied from class: HostTrackingService
      Every host seen so far with its request count, sorted by host (hostname, or IP if unresolved).
      Specified by:
      getHostCounts in class HostTrackingService