Package org.wso2.carbon.usage.agent.api
Class CustomMeteringAgent
java.lang.Object
org.wso2.carbon.usage.agent.api.CustomMeteringAgent
CustomMeteringAgent is used to get recorded duration, to check whether usage entry exists,
to persist and retrieve usage.
-
Constructor Summary
ConstructorsConstructorDescriptionCustomMeteringAgent(org.wso2.carbon.registry.core.Registry registry) Constructor for the custom metering agent -
Method Summary
Modifier and TypeMethodDescriptionlongAdd a long value to the usage, if there were no previous entry, this will start with value 0String[]getRecordedDurations(String measurement) Get recorded durationsbooleanisUsageEntryExists(String duration, String measurement) Check whether the usage entry exist or notvoidpersistUsage(String duration, String measurement, String value) Persist usage of a userretrieveUsage(String duration, String measurement) Retrieve usage of a user
-
Constructor Details
-
CustomMeteringAgent
public CustomMeteringAgent(org.wso2.carbon.registry.core.Registry registry) Constructor for the custom metering agent- Parameters:
registry- governance registry of super tenant
-
-
Method Details
-
getRecordedDurations
Get recorded durations- Parameters:
measurement- the measurement to get the duration- Returns:
- the durations array
- Throws:
UsageException
-
isUsageEntryExists
Check whether the usage entry exist or not- Parameters:
duration- the duration (e.g. year month), null for any durationmeasurement- measurement key- Returns:
- true if usage entry exists
- Throws:
UsageException
-
persistUsage
Persist usage of a user- Parameters:
duration- the duration (e.g. year month), null for any durationmeasurement- measurement keyvalue- measurement value- Throws:
UsageException
-
retrieveUsage
Retrieve usage of a user- Parameters:
duration- the duration (e.g. year month), null for any durationmeasurement- measurement key- Returns:
- measurement value
- Throws:
UsageException
-
addUsage
Add a long value to the usage, if there were no previous entry, this will start with value 0- Parameters:
duration- the duration (e.g. year month), null for any durationmeasurement- measurement keyvalue- measurement value- Returns:
- the added measurement value
- Throws:
UsageException
-