Package org.apache.synapse.commons.throttle.core

## Class CallerContext

- java.lang.Object
- - org.apache.synapse.commons.throttle.core.CallerContext

- All Implemented Interfaces:
    `Serializable`, `Cloneable`
  Direct Known Subclasses:
    `DomainBaseCallerContext`, `IPBaseCallerContext`, `RoleBaseCallerContext`

      public abstract class CallerContext
      extends Object
      implements Serializable, Cloneable

  Contains all runtime data for a particular remote caller. provides the default rate based access controller algorithm implementation. This is not thread-safe
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CallerContext​(String ID)` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `canAccess​(ThrottleContext throttleContext, CallerConfiguration configuration, long currentTime)` | Check whether that caller can access or not ,based on current state and pre-defined policy
    `boolean` | `canAccess​(ThrottleContext throttleContext, CallerConfiguration configuration, long currentTime, Long eventCount)` | Check whether that caller can access or not, based on current state and pre-defined policy
    `void` | `cleanUpCallers​(CallerConfiguration configuration, ThrottleContext throttleContext, long currentTime)` | Clean up the callers - remove all callers that have expired their time window
    `CallerContext` | `clone()` |
    `long` | `getFirstAccessTime()` |
    `long` | `getGlobalCounter()` |
    `String` | `getId()` |
    `long` | `getLocalCounter()` |
    `long` | `getLocalHits()` |
    `long` | `getLocalQuota()` |
    `long` | `getNextAccessTime()` |
    `long` | `getNextTimeWindow()` | Returns the next time window
    `String` | `getRoleId()` |
    `abstract int` | `getType()` | Gets type of throttle that this caller belong ex : ip/domain
    `long` | `getUnitTime()` |
    `UUID` | `getUuid()` |
    `void` | `incrementGlobalCounter​(int incrementBy)` |
    `void` | `incrementLocalCounter()` |
    `void` | `incrementLocalHits()` |
    `boolean` | `isThrottleParamSyncingModeSync()` |
    `void` | `resetGlobalCounter()` |
    `void` | `resetLocalCounter()` |
    `void` | `setFirstAccessTime​(long firstAccessTime)` |
    `void` | `setGlobalCounter​(long counter)` |
    `void` | `setIsThrottleParamSyncingModeSync​(boolean isThrottleParamSyncingModeSync)` |
    `void` | `setLocalCounter​(long counter)` |
    `void` | `setLocalHits​(long counter)` |
    `void` | `setLocalQuota​(long localQuota)` |
    `void` | `setNextAccessTime​(long nextAccessTime)` |
    `void` | `setNextTimeWindow​(long nextTimeWindow)` |
    `void` | `setRoleId​(String roleId)` |
    `void` | `setUnitTime​(long unitTime)` |

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CallerContext

          public CallerContext​(String ID)

  - ### Method Detail

    - #### clone

          public CallerContext clone()
                              throws CloneNotSupportedException

      Overrides:
        `clone` in class `Object`
      Throws:
        `CloneNotSupportedException`

    - #### getUuid

          public UUID getUuid()

    - #### getId

          public String getId()

      Returns:
        Returns Id of caller

    - #### cleanUpCallers

          public void cleanUpCallers​(CallerConfiguration configuration,
                                     ThrottleContext throttleContext,
                                     long currentTime)

      Clean up the callers - remove all callers that have expired their time window
      Parameters:
        `configuration` - -The Configuration for this caller
        `throttleContext` - -The Throttle that caller having pass
        `currentTime` - -The system current time

    - #### canAccess

          public boolean canAccess​(ThrottleContext throttleContext,
                                   CallerConfiguration configuration,
                                   long currentTime)
                            throws ThrottleException

      Check whether that caller can access or not ,based on current state and pre-defined policy
      Parameters:
        `throttleContext` - -The Context for this caller - runtime state
        `configuration` - -The Configuration for this caller - data from policy
        `currentTime` - -The current system time
      Returns:
        boolean -The boolean value which say access will allow or not
      Throws:
        `ThrottleException` - throws for invalid throttle configuration

    - #### canAccess

          public boolean canAccess​(ThrottleContext throttleContext,
                                   CallerConfiguration configuration,
                                   long currentTime,
                                   Long eventCount)
                            throws ThrottleException

      Check whether that caller can access or not, based on current state and pre-defined policy
      Parameters:
        `throttleContext` - -The Context for this caller - runtime state
        `configuration` - -The Configuration for this caller - data from policy
        `currentTime` - -The current system time
        `eventCount` - -The event count
      Returns:
        boolean -The boolean value which say access will allow or not
      Throws:
        `ThrottleException` - throws for invalid throttle configuration

    - #### getNextTimeWindow

          public long getNextTimeWindow()

      Returns the next time window
      Returns:
        long value of next time window

    - #### incrementGlobalCounter

          public void incrementGlobalCounter​(int incrementBy)

    - #### incrementLocalCounter

          public void incrementLocalCounter()

    - #### getGlobalCounter

          public long getGlobalCounter()

    - #### setGlobalCounter

          public void setGlobalCounter​(long counter)

    - #### setLocalCounter

          public void setLocalCounter​(long counter)

    - #### getLocalCounter

          public long getLocalCounter()

    - #### setLocalHits

          public void setLocalHits​(long counter)

    - #### getLocalHits

          public long getLocalHits()

    - #### incrementLocalHits

          public void incrementLocalHits()

    - #### resetLocalCounter

          public void resetLocalCounter()

    - #### resetGlobalCounter

          public void resetGlobalCounter()

    - #### getType

          public abstract int getType()

      Gets type of throttle that this caller belong ex : ip/domain
      Returns:
        Returns the type of the throttle

    - #### getFirstAccessTime

          public long getFirstAccessTime()

    - #### setFirstAccessTime

          public void setFirstAccessTime​(long firstAccessTime)

    - #### setNextTimeWindow

          public void setNextTimeWindow​(long nextTimeWindow)

    - #### getUnitTime

          public long getUnitTime()

    - #### setUnitTime

          public void setUnitTime​(long unitTime)

    - #### getRoleId

          public String getRoleId()

    - #### setRoleId

          public void setRoleId​(String roleId)

    - #### setIsThrottleParamSyncingModeSync

          public void setIsThrottleParamSyncingModeSync​(boolean isThrottleParamSyncingModeSync)

    - #### isThrottleParamSyncingModeSync

          public boolean isThrottleParamSyncingModeSync()

    - #### getLocalQuota

          public long getLocalQuota()

    - #### setLocalQuota

          public void setLocalQuota​(long localQuota)

    - #### getNextAccessTime

          public long getNextAccessTime()

    - #### setNextAccessTime

          public void setNextAccessTime​(long nextAccessTime)