Class RequestCounter

java.lang.Object
org.deltava.beans.system.RequestCounter
All Implemented Interfaces:
Serializable, ViewEntry

public class RequestCounter extends Object implements Serializable, ViewEntry
A bean to track Spider requests.
Since:
11.6
Version:
11.6
Author:
Luke
See Also:
  • Constructor Details

    • RequestCounter

      public RequestCounter(String addr)
      Initializes the counter.
      Parameters:
      addr - the remote address
    • RequestCounter

      public RequestCounter(RequestCounter rc)
      Clones a request counter.
      Parameters:
      rc - the RequestCounter
  • Method Details

    • increment

      public int increment()
      Increments the request counter.
      Returns:
      the number of requests
    • block

      public void block(int duration)
      Blocks this address for a specified period of time.
      Parameters:
      duration - the duration in seconds
    • setDegraded

      public void setDegraded(boolean isDegrade)
      Updates whether this request counter is in degraded status.
      Parameters:
      isDegrade - TRUE if degraded, otherwise FALSE
    • getAddress

      public String getAddress()
      Returns the remote address.
      Returns:
      the address
    • getIPInfo

      public IPBlock getIPInfo()
      Returns information about this remote address' net block.
      Returns:
      an IPBlock
    • getOldest

      public Instant getOldest()
      Returns the date/time of the oldest request.
      Returns:
      the date/time of the request, or null if none
    • getNewest

      public Instant getNewest()
      Returns the date/time of the newest request.
      Returns:
      the date/time of the request, or null if none
    • getRequests

      public int getRequests()
      Returns the number of requests for this address.
      Returns:
      the number of requests
    • merge

      public void merge(RequestCounter rc)
      Mereges the totals of two counters together. If the second counter is blocked, the later block time will be propagated.
      Parameters:
      rc - a RequestCounter
    • setIPInfo

      public void setIPInfo(IPBlock ip)
      Updates information about this remote address' net block.
      Parameters:
      ip - an IPInfo bean
    • contains

      public boolean contains(String addr)
      Returns whethre an IP address is contained within this counter's network block.
      Parameters:
      addr - the remote address
      Returns:
      TRUE if there is a network block and the address is contained within it, otherwise FALSE
    • purge

      public void purge(int maxTime)
      Purges all access times more than a certain period of time old.
      Parameters:
      maxTime - the time interval in seconds
    • getRowClassName

      public String getRowClassName()
      Description copied from interface: ViewEntry
      Returns the CSS class for this object if rendered in a view table.
      Specified by:
      getRowClassName in interface ViewEntry
      Returns:
      the CSS class name, or NULL if none