|
Table Of Contents
ReplyTimeout and OperationTimeout Exception
Information About Blocking API Methods
getNumberOfSubscribersInDomain
Adding a Subscriber, Printing Information, and Removing a Subscriber
Blocking API
This module introduces the Reply Timeout, a feature unique to the Blocking API.
The rest of the module lists all operations of the Blocking API, and provides code examples.
Note If you only need to develop an automatic integration , skip this module and go directly to Chapter 4, "Non-blocking API."
• ReplyTimeout and OperationTimeout Exception
• Information About Blocking API Methods
Multi-threading Support
The Blocking API supports unlimited number of threads calling its methods simultaneously.
Note In a multi-threaded scenario for the Blocking API, the order of invocation is not guaranteed.
Example:
Thread-0 calls operation-0 at time-0, and thread-1 calls operation-1 at time-1, where time-1 is later than time-0. In this example, it is possible that operation-1 may be performed before operation-0, as shown in the following diagram (the vertical scale is time):
Figure 3-1 Multi-threading Support
The SM allocates five threads to handle each API instance. It is recommended to develop a multi-threaded application that uses the API with a number of threads in the order of the five threads. Implementing with more threads might result in longer delays for the calling threads.
ReplyTimeout and OperationTimeout Exception
A blocking operation returns only when the operation result has been retrieved from the SM. If a networking malfunction or other error prevents the operation result from being retrieved, the caller will wait indefinitely. The SM API provides means of working around this situation.
The reply timeout feature (the setReplyTimeout method) lets the caller set a timeout. It will fire a com.pcube.management.framework.rpc.OperationTimeoutException when a reply does not return within the timeout period.
Calling the setReplyTimeout method with a long value sets a reply timeout. The reply timeout is interpreted in milliseconds. A zero value indicates that the operation should wait (freeze, hang) until a result arrives - or indefinitely, if no result arrives.
There is an alternative way to release a method call that is blocking the caller, who is waiting for a result to arrive: Call the interrupt method of the calling thread: a java.lang.InterruptedException will then be returned to the caller.
Information About Blocking API Methods
This section lists the methods of the Blocking API. A description of each method's input parameters and return values follows the syntax of each method.
The Blocking API is a superset of the Non-Blocking API. Except for differences in return values and result handling, identical operations in both APIs have the same functions and syntax structure.
All the methods throw a java.lang.IllegalStateException when called before a connection with the SM is established.
The Blocking API methods can be classified into the following categories:
•Dynamic IP and property allocation —For using the SM API for integration with an AAA system, the following methods are relevant. These methods are not designed to add or remove subscribers from the database, but to modify dynamic parameters (such as IP addresses) of existing subscribers:
– login
•Static/Manual Subscriber configuration —For example, for GUI usage, the following methods are relevant:
•For simple read-only operations, performed independently on the subscriber awareness mode, the following methods are relevant:
– getNumberOfSubscribersInDomain
– getSubscriberNamesWithPrefix
– getSubscriberNamesWithSuffix
It is possible to mix methods from different categories in a single application. The classification is presented for clarification purposes only.
• login
• getNumberOfSubscribersInDomain
• getSubscriberNamesWithPrefix
• getSubscriberNamesWithSuffix
login
• Syntax
• Examples
Syntax
public void login(String subscriberName,
String[] mappings,
short[] mappingTypes,
String[] propertyKeys,
String[] propertyValues,
String domain,
boolean isMappingAdditive,
int autoLogoutTime)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
The login method adds or modifies a domain, mappings, and possibly properties of a subscriber that already exists in the SM database. It can be called with partial data; for example, with only mappings or only properties provided and NULL put in the unchanged fields.
If another subscriber with the same (or colliding) mappings already exists in the same domain, the colliding mappings will be removed from the other subscriber and assigned to the new subscriber.
If the subscriber does not exist in the SM database, it will be created with the data provided.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
mappings —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section. If no mappings are specified, and the isMappingAdditive flag is TRUE, the previous mappings will be retained. If no such mappings exist, the operation will fail.
mappingTypes —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
propertyKeys —See explanation of property keys and values in the Subscriber Properties, page 2-6 section.
propertyValues —See explanation of property keys and values in the Subscriber Properties, page 2-6 section.
domain —See explanation of Subscriber Domains, page 2-5.
If domain is NULL, but the subscriber already has a domain, the existing domain will be retained.
If the domain is different to the domain that was previously assigned to the subscriber, the subscriber will be removed automatically from the SCEs of the previous domain and moved to the SCEs of the new domain.
isMappingAdditive
•TRUE —Adds the mappings provided by this call to the subscriber record.
•FALSE —Overrides the mappings provided by this call with mappings that already exist in the subscriber record.
autoLogoutTime —Applies only to mappings provided as arguments to this method.
•Positive value (N)—Automatically logs out the mappings (similar to a logout method being called) after N seconds.
•0 value—Maintains current expiration time for the given mappings.
•Negative value—Disables any expiration time that might have been set for the mappings given.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE_BAD_SUBSCRIBER_MAPPING
•ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION
•ERROR_CODE_DATABASE_EXCEPTION
•ERROR_CODE_UNKNOWN
This error can be caused by the following:
–NULL value for domain parameter for the subscriber that does not exist or does not have a domain
–Invalid values for propertyValues parameter
For a description of error codes, see List of Error Codes, page A-1.
Return Value
None.
Examples
To add the IP address 192.168.12.5 to an existing subscriber named john without affecting existing mappings:
login(
"john", // subscriber name
new String[]{"192.168.12.5"},
SMApiConstants.ALL_IP_MAPPINGS,
null, null,
"subscribers", // domain
true, // isMappingAdditive is true
-1); // autoLogoutTime set to infinite
To add the IP address 192.168.12.5 overriding previous mappings:
login(
"john", // subscriber name
new String[]{"192.168.12.5"},
SMApiConstants.ALL_IP_MAPPINGS,
null, null, "subscribers", // domain
false, // isMappingAdditive is false
-1); // autoLogoutTime set to infinite
To extend the auto logout time of 192.168.12.5 that was previously assigned to john :
login(
"john", //the previously assigned IP
new String[]{"192.168.12.5"},
SMApiConstants.ALL_IP_MAPPINGS,
null, null,
"subscribers", // domain
false, // isMappingAdditive
300); // autoLogoutTime set to 300 seconds
To modify a dynamic property of john (e.g. package ID):
login(
"john",
null, null,
new String[]{"packageId"}, // property key
new String[]{"10"}, // property value
"subscribers", // domain
false, -1);
To add the IP address 192.168.12.5 to an existing subscriber named john without affecting existing mappings and modify a dynamic property of john (e.g. package ID):
login(
"john",
new String[]{"192.168.12.5"},
SMApiConstants.ALL_IP_MAPPINGS, new String[]{"packageId"}, // property key
new String[]{"10"}, // property value
"subscribers", // domain
true, // isMappingAdditive is set to true
-1);
logoutByName
• Syntax
• Examples
Syntax
public boolean logoutByName(String subscriberName,
String[] mappings,
short[] mappingTypes)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Locates the subscriber in the database and removes mappings from it. If the subscriber does not exist, it does nothing.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
mappings —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section. If no mappings are specified, all subscriber mappings will be removed.
mappingTypes —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
Return Value
•TRUE—If the subscriber was found and the subscriber's mappings were removed from the subscriber database.
•FALSE—If the subscriber was not found in the subscriber database.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST
•ERROR_CODE _BAD_SUBSCRIBER_MAPPING
•ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION
•ERROR_CODE_DOMAIN_NOT_FOUND
•ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
Examples
To remove IP address 192.168.12.5 of subscriber john :
boolean isExist = logoutByName(
"john",
new String[]{"192.168.12.5"},
SMApiConstants.ALL_IP_MAPPINGS);
To remove all IP addresses of subscriber john :
boolean isExist = logoutByName("john", null, null);
logoutByNameFromDomain
• Syntax
• Example
Syntax
public boolean logoutByNameFromDomain(String subscriberName,
String[] mappings,
short[] mappingTypes,
String domain)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Similar to logoutByName , but also lets the caller provide the name of the domain to which the subscriber belongs. When the subscriber domain is known, use this method to get improved performance.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
mappings —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section. If no mappings are specified, all the subscriber mappings will be removed
mappingTypes —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
domain —See explanation of Subscriber Domains, page 2-5.
The operation will fail if either of the following conditions exists:
•The domain is null, but the subscriber exists in the database and belongs to a domain.
•The domain specified is incorrect.
Return Value
•TRUE—If the subscriber was found and removed from the subscriber database.
•FALSE—If the subscriber was not found in the subscriber database.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST
•ERROR_CODE _BAD_SUBSCRIBER_MAPPING
•ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION
•ERROR_CODE_DOMAIN_NOT_FOUND
•ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
Example
To remove IP address 192.168.12.5 of subscriber john from domain subscribers :
boolean isExist = logoutByNameFromDomain( "john", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, "subscribers");
boolean isExist = logoutByNameFromDomain( "john", null, null, "subscribers");
logoutByMapping
• Syntax
• Example
Syntax
public boolean logoutByMapping(String mapping,
short mappingType,
String domain)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Locates a subscriber based on domain and mapping, and removes the mapping (the subscriber stays in the database).
Parameters
mapping —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
mappingType —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
domain—See description in the Parameters section of the logoutByNameFromDomain operation.
Return Value
•TRUE—If the subscriber was found and removed from the subscriber database.
•FALSE—If the subscriber was not found in the subscriber database.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST
•ERROR_CODE _BAD_SUBSCRIBER_MAPPING
•ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION
•ERROR_CODE_DOMAIN_NOT_FOUND
•ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
Example
To remove IP address 192.168.12.5 from domain subscribers :
boolean isExist = logoutByMapping( "192.168.12.5", SMApiConstants. MAPPING_TYPE_IP, "subscribers");
loginCable
• Syntax
• Examples
Syntax
public void loginCable(String CPE,
String CM,
String IP,
int lease,
String domain,
String[] propertyKeys,
String[] propertyValues)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
A login method adapted for the cable environment (calls the cable support module in the SM). This method is designed to log in CPEs and CMs to the SM. To log in a CPE, specify its CM MAC in the CM argument and the CPE MAC in the CPE argument. To log in a CM, specify the CM MAC address in both CPE and CM arguments. Note that the login of a CPE whose CM does not exist in the SM database will be ignored: the CM has to exist in the database, either by import or by a CM login operation. For additional information, see the "CPE as Subscriber in Cable Environment" chapter of the Cisco SCMS Subscriber Manager User Guide .
Note The name of the CPE in the SM database is the concatenation of the CPE and CM values with two underscore ['_'] characters between them. The caller must make sure that the lengths of CPE and CM add up to no more than 38 characters.
Parameters
CPE —A unique identifier of the CPE (usually a MAC address)
CM —A unique identifier of the cable modem (usually a MAC address)
IP —The CPE IP address
lease —The CPE lease time
domain —See explanation of Subscriber Domains, page 2-5. The domain will usually be CMTS IP.
Note Domain aliases must be set on the SM in order for the CMTS IP to be correctly interpreted as a domain name. For information regarding aliases configuration see the "Configuring Domains" section of Cisco SCMS Subscriber Manager User Guide .
propertyKeys —See explanation of property keys and values in the Subscriber Properties, page 2-6 section.
If the CPE is provided with partial or no application properties, the values for the missing application properties will be copied from the application properties of the CM to which this CPE belongs. Each CM application property thus serves as a default for the CPE under it.
propertyValues —See explanation of property keys and values in the Subscriber Properties, page 2-6 section.
Return Value
None.
RPC Exception Error Codes
None.
Examples
To add the IP address 192.168.12.5 to a CM called CM1 with 2 hours lease time:
loginCable(
"CM1",
"CM1",
"192.168.12.5",
7200, // lease time in seconds
"subscribers", null, null);
To add the IP address 192.168.12.50 to a CPE called CPE1 which is behind CM1 with lease time of 1 hours:
loginCable(
"CPE1",
"CM1",
"192.168.12.50",
3600, // lease time in seconds
"subscribers", null, null);
logoutCable
• Syntax
• Examples
Syntax
public boolean logoutCable(String CPE,
String CM,
String IP,
String domain)
Description
Indicates a logout (CPE becoming offline) event to the SM cable support module.
Parameters
CPE —See description in the Parameters section of the loginCable method.
CM —See description in the Parameters section of the loginCable method.
IP —See description in the Parameters section of the loginCable method.
domain —See description in the Parameters section of the loginCable method.
Return Value
•TRUE—If the CPE was found and removed from the subscriber database.
•FALSE—If the CPE was not found in the subscriber database.
RPC Exception Error Codes
None.
Examples
To remove the IP address 192.168.12.5 from CPE1 which is behind CM1 :
boolean isExist = logoutCable(
"CPE1",
"CM1",
"192.168.12.5",
"subscribers");
addSubscriber
• Syntax
• Example
• Examples
Syntax
public void addSubscriber(String subscriberName,
String[] mappings,
short[] mappingTypes,
String[] propertyKeys,
String[] propertyValues,
String[] customPropertyKeys,
String[] customPropertyValues,
String domain)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Creates a new subscriber record according to the method parameters and adds the record to the SM database.
If a subscriber by this name already exists, it will be removed before the new one is added. In contrast to login , which modifies fields and leaves unspecified fields unchanged, addSubscriber sets the subscriber exactly as specified by the parameters passed to it.
Note It is recommended to call login method for existing subscribers, instead of addSubscriber. Dynamic mappings and properties should be set by using login. Static mappings and properties should be set at the first time the subscriber is created by using addSubscriber.
Note With addSubscriber , the auto-logout feature is always disabled. To enable auto-logout, use login.
Example
Subscriber AB , already set up in the subscriber database, has a single IP mapping: IP1 .
If an addSubscriber operation for AB is called with no mappings specified (NULL in both the mappings and mappingTypes fields), AB will be left with no mappings.
However, calling the login operation with these NULL-value parameters will not change AB 's mappings; AB will still have its previous IP mapping of IP1 .
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
mappings —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
mappingTypes —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
propertyKeys —See explanation of property keys and values in the Subscriber Properties, page 2-6 section.
propertyValues —See explanation of property keys and values in the Subscriber Properties, page 2-6 section.
customPropertyKeys —See explanation of custom property keys and values in the Custom Properties, page 2-6 section.
customPropertyValues —See explanation of custom property keys and values in the Custom Properties, page 2-6 section.
domain —See explanation of Subscriber Domains, page 2-5.
A NULL value indicates that the subscriber is domain-less.
If domain is NULL, but the subscriber already has a domain, the existing domain will be retained.
Return Value
None.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE _BAD_SUBSCRIBER_MAPPING
•ERROR_CODE_DOMAIN_NOT_FOUND
•ERROR_CODE_SUBSCRIBER_ALREADY_EXISTS
•ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION
•ERROR_CODE_UNKNOWN
This error code may indicate invalid values that were supplied for propertyValues parameter.
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
Examples
To add a new subscriber, john , with some custom properties:
addSubscriber("john",
null, null, // dynamic mappings will be set by login
null, null // dynamic properties will be set by login
new String[]{ // custom property keys
"work phone",
"home phone"},
new String[]{ // custom property values
"6543212"
"5059927"},
"subscribers"); // default domain
removeSubscriber
• Syntax
• Example
Syntax
public boolean removeSubscriber(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Removes a subscriber completely from the SM database.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
Return Value
•TRUE—If the subscriber was found in the database and successfully removed.
•FALSE—If the conditions for TRUE were not met; i.e., the subscriber was not found in the database, or the subscriber was found but was not successfully removed.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
Example
To remove subscriber john entirely from the database:
boolean isExist = removeSubscriber("john");
removeAllSubscribers
• Syntax
Syntax
public void removeAllSubscribers()
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Removes all subscribers from the SM, leaving the database with no subscribers.
Note This method may take time to execute. To avoid operation timeout exceptions, set a high operation timeout (up to 5 minutes) before calling this method.
Return Value
None.
RPC Exception Error Codes
None.
getNumberOfSubscribers
• Syntax
Syntax
public int getNumberOfSubscribers()
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Retrieves the total number of subscribers in the SM database.
Return Value
The number of subscribers in the SM.
RPC Exception Error Codes
None.
getNumberOfSubscribersInDomain
• Syntax
Syntax
public int getNumberOfSubscribersInDomain(String domain) throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Retrieves the number of subscribers in a subscriber domain.
Parameters
domain —A name of a subscriber domain that exists in the SM's domain repository.
Return Value
The number of subscribers in the domain provided.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN
•ERROR_CODE _DOMAIN_NOT_FOUND
For a description of error codes, see List of Error Codes, page A-1.
getSubscriber
• Syntax
• Example
Syntax
public Object[] getSubscriber(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Retrieves a subscriber record. Each field is formatted as an integer, string, or string array, as described below in the Return Value section for this method.
If the subscriber does not exist in the SM database, an exception will be returned.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
Return Value
An Object Array with nine elements. The following table lists the index values. No array element is NULL.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
Example
To retrieve the subscriber record of john :
Object[] subRecord = getSubscriber("john");
String[] mappings = (String[])subRecord[1]
short[] mappingTypes = {short[])subRecord[2];
String domainName = (String)subRecord[3];
String[] propertyNames = (String[])subRecord[4];
String[] propertyValues = (String[])subRecord[5];
String[] customPropertyName = (String[])subRecord[6];
String[] customPropertyValues = (String[])subRecord[7];
long[] autoLogoutTime = (long[])subRecord[8];
subscriberExists
• Syntax
Syntax
public boolean subscriberExists(String subscriberName)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Verifies that a subscriber exists in the SM database.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
Return Value
•TRUE—If the subscriber was found in the SM database.
•FALSE—If the subscriber could not be found.
RPC Exception Error Codes
None.
subscriberLoggedIn
• Syntax
Syntax
public boolean subscriberLoggedIn(String subscriberName)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Checks whether a subscriber that already exists in the SM database is logged in; i.e., if the subscriber also exists in an SCE database.
When the SM is configured to work in Pull mode , a TRUE value returned by this method does not guarantee that the subscriber actually exists in an SCE database, but rather the subscriber is available to be pulled by an SCE if needed.
If the subscriber does not exist in the SM database, an exception will be thrown.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
Return Value
•TRUE—If the subscriber is logged in.
•FALSE—If the subscriber is not logged in.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
getSubscriberNameByMapping
• Syntax
Syntax
public String getSubscriberNameByMapping(String mapping,
short mappingType,
String domain)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Finds a subscriber name according to a mapping and a domain.
Parameters
mapping —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
mappingType —See explanation of mappings and mapping types in the Information About Network ID Mappings, page 2-4 section.
domain —The name of the domain to which the subscriber belongs. The operation will fail if either of the following conditions exists:
•The domain is null, but the subscriber exists in the database and belongs to a domain.
•The specified domain is incorrect.
Return Value
•Subscriber name—If a subscriber record was found.
•NULL—If no subscriber record could be found.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_DOMAIN_NOT_FOUND
•ERROR_CODE _BAD_SUBSCRIBER_MAPPING
•ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
getSubscriberNames
• Syntax
• Example
Syntax
public String[] getSubscriberNames(String lastBulkEnd,
int numOfSubscribers)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Gets a bulk of subscriber names from the SM database, starting with lastBulkEnd followed by the next numOfSubscribers subscribers (in alphabetical order).
If lastBulkEnd is NULL, the (alphabetically) first subscriber name that exists in the SM database will be used.
Note There is no guarantee that the total number of subscribers (in all bulks) will equal the value returned from getNumOfSubscribers at any time. This may differ, for example, if some subscribers are added or removed while bulks are being retrieved.
Parameters
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.
Note Providing values higher than 500 to this parameter is not recommended.
Return Value
An array of subscriber names 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).
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
Example
boolean hasMoreSubscribers;
String lastBulkEnd = null;
int bulkSize = 100;
do {
String[] subscribers = smApi.getSubscriberNames(lastBulkEnd, bulkSize);
hasMoreSubscribers = false;
if (subscribers != null) {
for (int i = 0; i <subscribers.length; i++) {
// do something with subscribers[i]
}
if (subscribers.length == bulkSize) {
hasMoreSubscribers = true;
lastBulkEnd = subscribers[bulkSize - 1];
}
}
} while (hasMoreSubscribers);
getSubscriberNamesInDomain
• Syntax
Syntax
public String[] getSubscriberNamesInDomain(String lastBulkEnd,
int numOfSubscribers,
String domain)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Gets subscribers in the SM database that are associated with the specified domain.
The semantics of this operation are the same as the semantics of the getSubscriberNames operation.
Parameters
lastBulkEnd —See description in the Parameters section of the getSusbcriberNames operation.
numOfSubscribers —See description in the Parameters section of the getSusbcriberNames operation.
domain —The name of a subscriber domain that exists in the SM domain repository.
Return Value
An alphabetically ordered array of subscriber names that belong to the domain provided.
See also the Return Value section of the getSubscriberNames operation.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE _DOMAIN_NOT_FOUND
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
getSubscriberNamesWithPrefix
• Syntax
Syntax
public String[] getSubscriberNamesWithPrefix(String lastBulkEnd,
int numOfSubscribers,
String prefix)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Gets subscribers in the SM database whose name begins with a specified prefix.
The semantics of this operation are the same as the semantics of the getSubscriberNames operation.
Parameters
lastBulkEnd —See description in the Parameters section of the getSusbcriberNames operation.
numOfSubscribers —See description in the Parameters section of the getSusbcriberNames operation.
prefix —A case-sensitive string that marks the prefix of the required subscriber names.
Return Value
An alphabetically ordered array of subscriber names that start with the prefix required.
See also the Return Value section of the getSubscriberNames operation.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
getSubscriberNamesWithSuffix
• Syntax
Syntax
public String[] getSubscriberNamesWithSuffix(String lastBulkEnd,
int numOfSubscribers,
String suffix)
throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Gets subscribers in the SM database whose names end with the specified suffix.
The semantics of this operation are the same as the semantics of the getSubscriberNames operation.
Parameters
lastBulkEnd —See description in the Parameters section of the getSusbcriberNames operation.
numOfSubscribers —See description in the Parameters section of the getSusbcriberNames operation.
suffix —A case-sensitive string that marks the suffix of the required subscriber names.
Return Value
An alphabetically ordered array of subscriber names that end with the suffix required.
See also the Return Value section of the getSubscriberNames operation.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
getDomains
• Syntax
Syntax
public String[] getDomains() throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Provides the list of current subscriber domains in the SM domain repository.
Return Value
A complete list of subscriber domain names in the SM.
RPC Exception Error Codes
None.
setPropertiesToDefault
• Syntax
Syntax
public void setPropertiesToDefault(String subscriberName, String[] properties) throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Resets the specified application properties of a subscriber. If an application is installed, the relevant application properties will be set to the default value of the properties according to the currently loaded application information. If an application is not installed, a java.lang.IllegalStateException will be returned.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
properties —See explanation of property keys and values in the Subscriber Properties, page 2-6 section.
Return Value
None.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE _BAD_SUBSCRIBER_MAPPING
•ERROR_CODE_DOMAIN_NOT_FOUND
•ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST
•ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
removeCustomProperties
• Syntax
Syntax
public void removeCustomProperties(String subscriberName, String[] customProperties) throws InterruptedException, OperationTimeoutException, RpcErrorException
Description
Resets the specified custom properties of a subscriber.
Parameters
subscriberName —See explanation of Subscriber Name Format, page 2-4.
CustomProperties —See explanation of custom property keys and values in the Custom Properties, page 2-6 section.
Return Value
None.
RPC Exception Error Codes
The following is the list of error codes that this method might return:
•ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME
•ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST
•ERROR_CODE_DATABASE_EXCEPTION
For a description of error codes, see List of Error Codes, page A-1.
Blocking API Code Examples
This section gives two code examples:
•Getting number of subscribers
•Adding subscriber, printing subscriber information, removing subscriber
• Getting Number of Subscribers
• Adding a Subscriber, Printing Information, and Removing a Subscriber
Getting Number of Subscribers
The following example prints to stdout the total number of subscribers in the SM database and the number of subscribers in each subscriber domain.
package blocking;
import com.pcube.management.api.SMBlockingApi;
public class PrintInfo {
public static void main (String args[]) throws Exception {
SMBlockingApi bapi = new SMBlockingApi();
try {
//initiation
bapi.setReplyTimeout(300000); //set timeout for 5 minutes
bapi.connect(args[0]); // connect to the SM
//operations
String[] domains=bapi.getDomains();
int totalSubscribers=bapi.getNumberOfSubscribers();
System.out.println(
"number of susbcribers in the database:\t\t "+
totalSubscribers);
for (int i=0; i<domains.length; i++) {
int numberOfSusbcribersInDomain=
bapi.getNumberOfSubscribersInDomain(domains[i]);
System.out.println(
"number of susbcribers domain "+domains[i]+
":\t\t "+numberOfSusbcribersInDomain);
}
} finally {
//finalization
bapi.disconnect();
}
}
}
Adding a Subscriber, Printing Information, and Removing a Subscriber
The following program adds a subscriber to the subscriber database, then gets its information and prints it to stdout , and finally removes the subscriber from the subscriber database.
package blocking;
import com.pcube.management.api.SMBlockingApi;
import com.pcube.management.api.SMApiConstants;
public class AddPrintRemove {
public static void main (String args[]) throws Exception {
checkArguments(args);
SMBlockingApi bapi = new SMBlockingApi();
try {
//initiation
bapi.setReplyTimeout(10000); //set timeout for 10 seconds
bapi.connect(args[0]); // connect to the SM
//add subscriber
System.out.println("+ adding subscriber to SM");
bapi.addSubscriber(
args[1], //name
new String[]{args[2]}, //mapping`
SMApiConstants.ALL_IP_MAPPINGS,
new String[]{args[3]}, //property key
new String[]{args[4]}, //property value
new String[]{"custom-key"}, //custom property key
new String[]{"10"}, //custom property value
args[5]); //domain
//Print subscriber
System.out.println("+ Printing subscriber");
Object[] subfields = bapi.getSubscriber(args[1]);
System.out.println("\tname:\t\t"+subfields[0]);
System.out.println("\tmapping:\t"+
((String[])subfields[1])[0]);
System.out.println("\tdomain:\t\t"+subfields[3]);
System.out.println("\tautologout:\t"+subfields[8]);
//Remove subscriber
System.out.println("+ removing subscriber from SM");
bapi.removeSubscriber(args[1]);
} finally {
//finalization
bapi.disconnect();
}
}
static void checkArguments(String[] args) throws Exception{
if (args.length != 6) {
System.err.println(
"usage: java AddPrintRemove <SM-address>"+
" <subscriber-name><IP mapping><property-key>"+
" <property-value><domain>");
System.exit(1);
}
}
}
Posted: Thu May 31 06:28:23 PDT 2007
All contents are Copyright © 1992--2007 Cisco Systems, Inc. All rights reserved.
Important Notices and Privacy Statement.