Package org.wso2.carbon.usage.agent.api
Class CustomMeteringAgent
- java.lang.Object
-
- org.wso2.carbon.usage.agent.api.CustomMeteringAgent
-
public class CustomMeteringAgent extends Object
CustomMeteringAgent is used to get recorded duration, to check whether usage entry exists, to persist and retrieve usage.
-
-
Constructor Summary
Constructors Constructor Description CustomMeteringAgent(org.wso2.carbon.registry.core.Registry registry)Constructor for the custom metering agent
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddUsage(String duration, String measurement, long value)Add 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 userStringretrieveUsage(String duration, String measurement)Retrieve usage of a user
-
-
-
Method Detail
-
getRecordedDurations
public String[] getRecordedDurations(String measurement) throws UsageException
Get recorded durations- Parameters:
measurement- the measurement to get the duration- Returns:
- the durations array
- Throws:
UsageException
-
isUsageEntryExists
public boolean isUsageEntryExists(String duration, String measurement) throws UsageException
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
public void persistUsage(String duration, String measurement, String value) throws UsageException
Persist usage of a user- Parameters:
duration- the duration (e.g. year month), null for any durationmeasurement- measurement keyvalue- measurement value- Throws:
UsageException
-
retrieveUsage
public String retrieveUsage(String duration, String measurement) throws UsageException
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
public long addUsage(String duration, String measurement, long value) throws UsageException
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
-
-