org.apache.synapse.commons.throttle.core

## Class ThrottleContext

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

- Direct Known Subclasses:
    DomainBaseThrottleContext, IPBaseThrottleContext, RoleBaseThrottleContext

      public abstract class ThrottleContext
      extends java.lang.Object

  Holds the all runtime data corresponding to call remote callers. In addition to that this hold clean list for callers.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ThrottleContext(ThrottleConfiguration throttleConfiguration, ThrottleReplicator throttleReplicator)` default constructor – expects a throttle configuration.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAndFlushCallerContext(CallerContext callerContext, java.lang.String id)` To add the caller and replicates the states of the given caller
    `void` | `addCallerContext(CallerContext callerContext, java.lang.String id)` setting callerContext - put callersMap against time and put time against remote caller id (ip/domain)
    `void` | `cleanupCallers(long time)` This method will clean up callers which has next access time below from provided time This will first check the prohibited period and then it will check next access time lesser than unit time before a cleanup a caller
    `void` | `flushCallerContext(CallerContext callerContext, java.lang.String id)` To replicates the states of the already exist caller
    `CallerContext` | `getCallerContext(java.lang.String id)` To get the runtime states of a remote caller
    `org.apache.axis2.context.ConfigurationContext` | `getConfigurationContext()`
    `ThrottleConfiguration` | `getThrottleConfiguration()` To get the ThrottleConfiguration
    `java.lang.String` | `getThrottleId()`
    `abstract int` | `getType()`
    `void` | `processCleanList(long time)` /** processing cleaning list- only process callerContexts which unit time already had over
    `void` | `removeAndDestroyShareParamsOfCaller(java.lang.String id)` Removes the caller and destroy shared params of caller
    `void` | `removeAndFlushCaller(java.lang.String id)` Removes the caller and replicate the states
    `void` | `removeCallerContext(java.lang.String id)` removing a caller with a given id - caller will remove from clean list
    `void` | `replicateTimeWindow(java.lang.String id)` Replicate the time window of this caller
    `void` | `setConfigurationContext(org.apache.axis2.context.ConfigurationContext configurationContext)`
    `void` | `setThrottleId(java.lang.String throttleId)`

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

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

- - ### Constructor Detail

    - #### ThrottleContext

          public ThrottleContext(ThrottleConfiguration throttleConfiguration,
                                 ThrottleReplicator throttleReplicator)

      default constructor – expects a throttle configuration.
      Parameters:
        `throttleConfiguration` - - configuration data according to the policy

  - ### Method Detail

    - #### getThrottleConfiguration

          public ThrottleConfiguration getThrottleConfiguration()

      To get the ThrottleConfiguration
      Returns:
        ThrottleConfiguration returns the ThrottleConfiguration of this context

    - #### getCallerContext

          public CallerContext getCallerContext(java.lang.String id)

      To get the runtime states of a remote caller
      Parameters:
        `id` - the remote caller id ex: domain , ip
      Returns:
        Returns the CallerContext which holds runtime state of a remote caller

    - #### addCallerContext

          public void addCallerContext(CallerContext callerContext,
                                       java.lang.String id)

      setting callerContext - put callersMap against time and put time against remote caller id (ip/domain)
      Parameters:
        `callerContext` - - The remote caller's runtime data.
        `id` - - The id of the remote caller

    - #### removeCallerContext

          public void removeCallerContext(java.lang.String id)

      removing a caller with a given id - caller will remove from clean list
      Parameters:
        `id` - Caller ID

    - #### processCleanList

          public void processCleanList(long time)

      /** processing cleaning list- only process callerContexts which unit time already had over
      Parameters:
        `time` - - the current System Time
      Throws:
        `ThrottleException`

    - #### setThrottleId

          public void setThrottleId(java.lang.String throttleId)

    - #### getThrottleId

          public java.lang.String getThrottleId()

    - #### getConfigurationContext

          public org.apache.axis2.context.ConfigurationContext getConfigurationContext()

    - #### setConfigurationContext

          public void setConfigurationContext(org.apache.axis2.context.ConfigurationContext configurationContext)

    - #### getType

          public abstract int getType()

      Returns:
        Returns the type of throttle ex : ip /domain

    - #### addAndFlushCallerContext

          public void addAndFlushCallerContext(CallerContext callerContext,
                                               java.lang.String id)

      To add the caller and replicates the states of the given caller
      Parameters:
        `callerContext` - The states of the caller
        `id` - The id of the caller

    - #### flushCallerContext

          public void flushCallerContext(CallerContext callerContext,
                                         java.lang.String id)

      To replicates the states of the already exist caller
      Parameters:
        `callerContext` - The states of the caller
        `id` - The id of the remote caller

    - #### removeAndFlushCaller

          public void removeAndFlushCaller(java.lang.String id)

      Removes the caller and replicate the states
      Parameters:
        `id` - The Id of the caller

    - #### removeAndDestroyShareParamsOfCaller

          public void removeAndDestroyShareParamsOfCaller(java.lang.String id)

      Removes the caller and destroy shared params of caller
      Parameters:
        `id` - The Id of the caller

    - #### replicateTimeWindow

          public void replicateTimeWindow(java.lang.String id)

      Replicate the time window of this caller
      Parameters:
        `id` -

    - #### cleanupCallers

          public void cleanupCallers(long time)

      This method will clean up callers which has next access time below from provided time This will first check the prohibited period and then it will check next access time lesser than unit time before a cleanup a caller
      Parameters:
        `time` - to clean up the caller contexts

Copyright © 2005-2021 Apache Software Foundation. All Rights Reserved.