Class SharedParamManager

java.lang.Object
org.apache.synapse.commons.throttle.core.SharedParamManager

public class SharedParamManager extends Object
  • Method Details

    • getDistributedCounter

      public static long getDistributedCounter(String id)
      Return distributed shared counter for this caller context with given id. If it's not distributed will get from the local counter
      Parameters:
      id - of the shared counter
      Returns:
      shared hazelcast current shared counter
    • setDistributedCounter

      public static void setDistributedCounter(String id, long value)
      Set distribute counter of caller context of given id to the provided value. If it's not distributed do the same for local counter
      Parameters:
      id - of the caller context
      value - to set to the global counter
    • setDistributedCounterWithExpiry

      public static void setDistributedCounterWithExpiry(String id, long value, long expiryTime)
      Set the distributed counter with the given id key with an expiry time
      Parameters:
      id - key id
      value - value to set
      expiryTime - expiry time in milliseconds
    • setSharedTimestampWithExpiry

      public static void setSharedTimestampWithExpiry(String id, long timestamp, long expiryTime)
      Set the shared timestamp with the given id key with an expiry time
      Parameters:
      id - key id
      timestamp - timestamp value to set
      expiryTime - expiry time in milliseconds
    • addAndGetDistributedCounter

      public static long addAndGetDistributedCounter(String id, long value)
      Add given value to the distribute counter of caller context of given id. If it's not distributed return local counter
      Parameters:
      id - of the caller context
      value - to set to the global counter
    • asyncGetAndAddDistributedCounter

      public static long asyncGetAndAddDistributedCounter(String id, long value)
      Asynchronously add given value to the distribute counter of caller context of given id. If it's not distributed return local counter. This will return global value before add the provided counter
      Parameters:
      id - of the caller context
      value - to set to the global counter
    • asyncGetAndAlterDistributedCounter

      public static long asyncGetAndAlterDistributedCounter(String id, long value)
      Asynchronously add given value to the distribute counter of caller context of given id. If it's not distributed return local counter. This will return global value before add the provided counter
      Parameters:
      id - of the caller context
      value - to set to the global counter
    • removeCounter

      public static void removeCounter(String id)
      Destroy hazelcast global counter, if it's local then remove the map entry
      Parameters:
      id - of the caller context
    • getSharedTimestamp

      public static long getSharedTimestamp(String id)
      Return hazelcast shared timestamp for this caller context with given id. If it's not distributed will get from the local counter
      Parameters:
      id - of the shared counter
      Returns:
      shared hazelcast current shared counter
    • setSharedTimestamp

      public static void setSharedTimestamp(String id, long timestamp)
      Set distribute timestamp of caller context of given id to the provided value. If it's not distributed do the same for local counter
      Parameters:
      id - of the caller context
      timestamp - to set to the global counter
    • removeTimestamp

      public static void removeTimestamp(String id)
      Destroy hazelcast shared timggestamp counter, if it's local then remove the map entry
      Parameters:
      id - of the caller context
    • setExpiryTime

      public static void setExpiryTime(String id, long expiryTimeStamp)
    • getTtl

      public static long getTtl(String key)
      Get the time-to-live value for the given key
      Parameters:
      key - name key of the key
      Returns:
      time-to-live value
    • lockSharedKeys

      public static boolean lockSharedKeys(String callerContextId, String lockValue)
      Acquire lock for the given callerContext (with the given value), so that another process cannot acquire the same lock
      Returns:
      true if lock acquired, false if lock is not acquired within the configured timeout period
    • releaseSharedKeys

      public static void releaseSharedKeys(String callerContextId)
      Release the lock of the given callerContext