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 Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Every host seen so far with its request count (broken down by request path), sorted by host (hostname, or IP if unresolved).
    boolean
    recordRequest(String remoteAddress, String requestPath)
    Records a single request from the given remote address (the caller's true IP, already resolved from X-Forwarded-For where applicable), made to the given request path.
    void
    resolveHostname(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).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HostTrackingServiceImpl

      public HostTrackingServiceImpl()
  • Method Details

    • recordRequest

      public boolean recordRequest(String remoteAddress, String requestPath)
      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), made to the given request path.
      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 (broken down by request path), sorted by host (hostname, or IP if unresolved).
      Specified by:
      getHostCounts in class HostTrackingService