org.wso2.carbon.usage.agent.api
Class CustomMeteringAgent

java.lang.Object
  extended by 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
CustomMeteringAgent(org.wso2.carbon.registry.core.Registry registry)
          Constructor for the custom metering agent
 
Method Summary
 long addUsage(String duration, String measurement, long value)
          Add a long value to the usage, if there were no previous entry, this will start with value 0
 String[] getRecordedDurations(String measurement)
          Get recorded durations
 boolean isUsageEntryExists(String duration, String measurement)
          Check whether the usage entry exist or not
 void persistUsage(String duration, String measurement, String value)
          Persist usage of a user
 String retrieveUsage(String duration, String measurement)
          Retrieve usage of a user
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomMeteringAgent

public CustomMeteringAgent(org.wso2.carbon.registry.core.Registry registry)
Constructor for the custom metering agent

Parameters:
registry - governance registry of super tenant
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 duration
measurement - 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 duration
measurement - measurement key
value - 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 duration
measurement - 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 duration
measurement - measurement key
value - measurement value
Returns:
the added measurement value
Throws:
UsageException


Copyright © 2015 WSO2. All rights reserved.