Cisco Systems Inc. Confidential

com.pcube.management.api
Class QuotaManagerApi

java.lang.Object
  extended by com.pcube.management.api.QuotaManagerApi
All Implemented Interfaces:
com.pcube.management.framework.rpc.ErrorCodes

public class QuotaManagerApi
extends java.lang.Object
implements com.pcube.management.framework.rpc.ErrorCodes

The Quota Manager API is a blocking API .Every method returns after its operation has been performed.

The purpose of this API is to be used by user interface systems to view & edit subscriber Quota data on Quota Manager.

Usage examples: TBD

For Support TBD


Field Summary
static int ADD_OPERATION
           
static int REPLENISH_OPERATION
           
static int SET_OPERATION
           
 
Fields inherited from interface com.pcube.management.framework.rpc.ErrorCodes
ERROR_CODE_API_NOT_CONNECTED, ERROR_CODE_ARRAY_ACCESS, ERROR_CODE_ATTRIBUTE_NOT_FOUND, ERROR_CODE_BAD_SUBSCRIBER_MAPPING, ERROR_CODE_BAD_VPN_MAPPING, ERROR_CODE_CASCADE_OPERATION_VIOLATION, ERROR_CODE_CLASS_CAST, ERROR_CODE_CLASS_NOT_FOUND, ERROR_CODE_DATABASE_EXCEPTION, ERROR_CODE_DOMAIN_NOT_FOUND, ERROR_CODE_FATAL_EXCEPTION, ERROR_CODE_ILLEGAL_ARGUMENT, ERROR_CODE_ILLEGAL_STATE, ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME, ERROR_CODE_INTERRUPTED_EXCEPTION, ERROR_CODE_INVALID_ATTRIBUTE_VALUE, ERROR_CODE_INVALID_BUCKETID, ERROR_CODE_INVALID_BUCKETSIZE, ERROR_CODE_INVALID_PARAMETER, ERROR_CODE_MALFORMED_OBJECT_NAME, ERROR_CODE_N0_QUOTA_INFO_FOR_SUBSCRIBER, ERROR_CODE_NATIVE_METHOD_ARG_ERROR, ERROR_CODE_NATIVE_METHOD_FAILED, ERROR_CODE_NO_APPLICATION_INSTALLED, ERROR_CODE_NO_SUCH_METHOD, ERROR_CODE_NOT_A_SUSBCRIBER_DOMAIN, ERROR_CODE_NULL_POINTER, ERROR_CODE_NUMBER_FORMAT, ERROR_CODE_OBJECT_EXISTS, ERROR_CODE_OBJECT_INTROSPECTION, ERROR_CODE_OBJECT_NOT_COMPLIANT, ERROR_CODE_OBJECT_NOT_FOUND, ERROR_CODE_OBJECT_REGISTRATION, ERROR_CODE_OPERATION_ABORTED, ERROR_CODE_OPERATION_NOT_FOUND, ERROR_CODE_OUT_OF_MEMORY, ERROR_CODE_REPLENISH_FAILED, ERROR_CODE_RESOURCE_SHORTAGE, ERROR_CODE_RUNTIME, ERROR_CODE_SE_ERROR, ERROR_CODE_SUBCRIBER_NOT_ASSIGNED_PROFILE, ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST, ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION, ERROR_CODE_SUBSCRIBER_MAPPING_CONGESTION, ERROR_CODE_SUSBSCRIBER_ALREADY_EXISTS, ERROR_CODE_UNKNOWN, ERROR_CODE_VALUE_DOES_NOT_MEET_CONSTRAINTS, ERROR_CODE_VPN_ALREADY_EXISTS, ERROR_CODE_VPN_DOES_NOT_EXIST
 
Constructor Summary
QuotaManagerApi()
          No Argument Constructor.
QuotaManagerApi(java.lang.String applicationName)
          Constructor.
 
Method Summary
 void addSubscriberQuota(java.lang.String subscriberName, int bucketId, long bucketSize)
          Adds quota to specific quota buckets of a subscriber without starting a new aggregation period.
 void connect(java.lang.String hostname)
          connect to the subscriber manager using the default port.
 void connect(java.lang.String hostname, int port)
          connect to the subscriber manager to a user specified port.
 void disconnect()
          disconnects from the susbcriber manager.
 java.lang.String[] getBreachedSubscriberNames(java.lang.String lastBulkEnd, int numOfSubscribers)
          Provides the list of subscribers in breached state.
 java.lang.String getClientVersion()
          provides the rpc-client version with which this Java QuotaManager API was compiled.
 java.lang.String[] getPenaltySubscriberNames(java.lang.String lastBulkEnd, int numOfSubscribers)
          Provides the list of subscribers in penalty state.
 java.lang.String getSMVersion()
          gets the (peer) SM version
 java.lang.Object[] getSubscriberQuotaInformation(java.lang.String subscriberName)
          This method is used to get the quota information of the specified subscriber.
 int getSubscriberQuotaProfileId(java.lang.String subscriberName)
          This method is used to get the subscriber profileId.
 void init(java.util.Properties properties)
          Initiates some configuration parameters of the client.
 boolean isConnected()
          tests whether the client is connected
 void replenishSubscriberQuota(java.lang.String subscriberName)
          Replenish all quota buckets for a subscriber without starting a new aggregation period.
 void setDisconnectListener(DisconnectListener disconnectListener)
          Sets a disconnect listener.
 void setReplyTimeout(long _timeout)
          sets a timeout, after which the methods of this API will return (with an exception) if the result has not yet arrived.
 void setSubscriberQuota(java.lang.String subscriberName, int bucketId, long bucketSize)
          Sets quota buckets of a subscriber to new values without starting a new aggregation period.
 java.lang.String toString()
          Automatically generated method: toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ADD_OPERATION

public static final int ADD_OPERATION
See Also:
Constant Field Values

SET_OPERATION

public static final int SET_OPERATION
See Also:
Constant Field Values

REPLENISH_OPERATION

public static final int REPLENISH_OPERATION
See Also:
Constant Field Values
Constructor Detail

QuotaManagerApi

public QuotaManagerApi()
No Argument Constructor.


QuotaManagerApi

public QuotaManagerApi(java.lang.String applicationName)
Constructor. Lets the caller set the applicationName.

Note:: The application name will be appended with the following suffix: .B.QM-API.J

For example

If the applicationName is 'my-QuotaManager-Application' then the actual applicationName sent at the greeting to the RPC server is 'my-QuotaManager-Application.B.QM-API.J'

Parameters:
applicationName - the name describing this application for failover, to enable several API instances to work from several hosts, it is recommended to include the hostname as part of the application name.
Method Detail

toString

public java.lang.String toString()
Automatically generated method: toString

Overrides:
toString in class java.lang.Object

init

public void init(java.util.Properties properties)
Initiates some configuration parameters of the client. Using this method is optional. use it only if you have a good reason to change the configuration parameters from their default.

Parameters:
properties - To find out which properties are configurable using this API please address Cisco's support.

connect

public void connect(java.lang.String hostname)
             throws java.lang.Exception
connect to the subscriber manager using the default port. The connect method can be called also after disconnect has been called (there is no need to create a new API after disconnecting)

Parameters:
hostname - a host running the SM software
Throws:
java.lang.Exception

connect

public void connect(java.lang.String hostname,
                    int port)
             throws java.lang.Exception
connect to the subscriber manager to a user specified port. useful when SM doesn't listen on the default port. The connect method can be called also after disconnect has been called (there is no need to create a new API after disconnecting)

Parameters:
hostname - a host running the SM software
port - the port number on which the SM's rpc server listens
Throws:
java.lang.Exception

disconnect

public void disconnect()
disconnects from the susbcriber manager. The connect method can be called also after disconnect has been called (there is no need to create a new API after disconnecting)


isConnected

public boolean isConnected()
tests whether the client is connected

Returns:
true/false if connected/not connected

getClientVersion

public java.lang.String getClientVersion()
provides the rpc-client version with which this Java QuotaManager API was compiled. This method doesn't require a connection to work.

Returns:
A version string.

getSMVersion

public java.lang.String getSMVersion()
gets the (peer) SM version

Returns:
the version of the SM as received in the connection negotiation

setDisconnectListener

public void setDisconnectListener(DisconnectListener disconnectListener)

Sets a disconnect listener.

The API supports only a single disconnect listener. The listener is notified when the API looses connection with the SM.

Important Note:The disconnect listener should not perform long operations from the calling thread. Performing long operations due to a disconnection event should be done in a separate thread. Not following this (strong) recommendation might result in resource leakage on the client side.

Parameters:
disconnectListener -

setReplyTimeout

public final void setReplyTimeout(long _timeout)

sets a timeout, after which the methods of this API will return (with an exception) if the result has not yet arrived. The default timeout is to wait for ever.

The timeout can be set again and again before each method call.

Parameters:
_timeout - either a positive number which is the number of milliseconds to wait or zero - wait forever

addSubscriberQuota

public void addSubscriberQuota(java.lang.String subscriberName,
                               int bucketId,
                               long bucketSize)
                        throws java.lang.InterruptedException,
                               OperationTimeoutException,
                               RpcErrorException
Adds quota to specific quota buckets of a subscriber without starting a new aggregation period.

Parameters:
subscriberName - name of the subscriber for whom the quota need to be added
bucketId - the bucketId to which the quota to be added
bucketSize - the size of the bucket
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
OperationTimeoutException - if the reply does not return within the timeout period set by the caller using setReplyTimeout method.
RpcErrorException - this provides all of the functional errors of the SM Java API.

replenishSubscriberQuota

public void replenishSubscriberQuota(java.lang.String subscriberName)
                              throws java.lang.InterruptedException,
                                     OperationTimeoutException,
                                     RpcErrorException
Replenish all quota buckets for a subscriber without starting a new aggregation period.

Parameters:
subscriberName - name of the subscriber for whom the quota need to be replenished
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
OperationTimeoutException - if the reply does not return within the timeout period set by the caller using setReplyTimeout method.
RpcErrorException - this provides all of the functional errors of the SM Java API.

setSubscriberQuota

public void setSubscriberQuota(java.lang.String subscriberName,
                               int bucketId,
                               long bucketSize)
                        throws java.lang.InterruptedException,
                               OperationTimeoutException,
                               RpcErrorException
Sets quota buckets of a subscriber to new values without starting a new aggregation period.

Parameters:
subscriberName - name of the subscriber for whom the quota need to be set
bucketId - the bucketId to which the quota to be set
bucketSize - the size of the bucket
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
OperationTimeoutException - if the reply does not return within the timeout period set by the caller using setReplyTimeout method.
RpcErrorException - this provides all of the functional errors of the SM Java API.

getBreachedSubscriberNames

public java.lang.String[] getBreachedSubscriberNames(java.lang.String lastBulkEnd,
                                                     int numOfSubscribers)
                                              throws java.lang.InterruptedException,
                                                     OperationTimeoutException,
                                                     RpcErrorException
Provides the list of subscribers in breached state.

Parameters:
lastBulkEnd - lastBulkEnd—Last subscriber name from last bulk. Use NULL to start with the first (alphabetic) subscriber.
numOfSubscribers - Limit on number of subscribers that will be returned. If this value is higher than the SM limit (1000), the SM limit will be used.
Returns:
An array of names of the subscribers in Breached state ordered alphabetically. The method will return as many subscribers as are found in the SM database, starting at the requested subscriber. The array size is limited by the minimum between numOfSubscribers and the SM limit (1000).
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
OperationTimeoutException - if the reply does not return within the timeout period set by the caller using setReplyTimeout method.
RpcErrorException - this provides all of the functional errors of the SM Java API.

getPenaltySubscriberNames

public java.lang.String[] getPenaltySubscriberNames(java.lang.String lastBulkEnd,
                                                    int numOfSubscribers)
                                             throws java.lang.InterruptedException,
                                                    OperationTimeoutException,
                                                    RpcErrorException
Provides the list of subscribers in penalty state.

Parameters:
lastBulkEnd - lastBulkEnd—Last subscriber name from last bulk. Use NULL to start with the first (alphabetic) subscriber.
numOfSubscribers - Limit on number of subscribers that will be returned. If this value is higher than the SM limit (1000), the SM limit will be used.
Returns:
An array of names of the subscribers in Penalty ordered alphabetically. The method will return as many subscribers as are found in the SM database, starting at the requested subscriber. The array size is limited by the minimum between numOfSubscribers and the SM limit (1000).
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
OperationTimeoutException - if the reply does not return within the timeout period set by the caller using setReplyTimeout method.
RpcErrorException - this provides all of the functional errors of the SM Java API.

getSubscriberQuotaInformation

public java.lang.Object[] getSubscriberQuotaInformation(java.lang.String subscriberName)
                                                 throws java.lang.InterruptedException,
                                                        OperationTimeoutException,
                                                        RpcErrorException
This method is used to get the quota information of the specified subscriber.

Parameters:
subscriberName - name of the subscriber for whom the quota information is to be retrieved.
Returns:
the quota information of the specified subscriber.
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
OperationTimeoutException - if the reply does not return within the timeout period set by the caller using setReplyTimeout method.
RpcErrorException - this provides all of the functional errors of the SM Java API.

getSubscriberQuotaProfileId

public int getSubscriberQuotaProfileId(java.lang.String subscriberName)
                                throws java.lang.InterruptedException,
                                       OperationTimeoutException,
                                       RpcErrorException
This method is used to get the subscriber profileId.

Parameters:
subscriberName - name of the subscriber for whose profileId is to be retrieved.
Returns:
the quota profileId of the specified subscriber.
Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
OperationTimeoutException - if the reply does not return within the timeout period set by the caller using setReplyTimeout method.
RpcErrorException - this provides all of the functional errors of the SM Java API.

Cisco Systems Inc. Confidential