cisco service control subscriber manager java api ... · iii cisco service control subscriber...

102
Americas Headquarters Cisco Systems, Inc. 170 West Tasman Drive San Jose, CA 95134-1706 USA http://www.cisco.com Tel: 408 526-4000 800 553-NETS (6387) Fax: 408 527-0883 Cisco Service Control Subscriber Manager Java API Programmer Guide Release 3.8.x December 21, 2012 Text Part Number: OL-26795-02

Upload: others

Post on 22-May-2020

31 views

Category:

Documents


0 download

TRANSCRIPT

Cisco Service Control Subscriber Manager Java API Programmer GuideRelease 3.8.x December 21, 2012

Americas HeadquartersCisco Systems, Inc.170 West Tasman DriveSan Jose, CA 95134-1706 USAhttp://www.cisco.comTel: 408 526-4000

800 553-NETS (6387)Fax: 408 527-0883

Text Part Number: OL-26795-02

THE SPECIFICATIONS AND INFORMATION REGARDING THE PRODUCTS IN THIS MANUAL ARE SUBJECT TO CHANGE WITHOUT NOTICE. ALL STATEMENTS, INFORMATION, AND RECOMMENDATIONS IN THIS MANUAL ARE BELIEVED TO BE ACCURATE BUT ARE PRESENTED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. USERS MUST TAKE FULL RESPONSIBILITY FOR THEIR APPLICATION OF ANY PRODUCTS.

THE SOFTWARE LICENSE AND LIMITED WARRANTY FOR THE ACCOMPANYING PRODUCT ARE SET FORTH IN THE INFORMATION PACKET THAT SHIPPED WITH THE PRODUCT AND ARE INCORPORATED HEREIN BY THIS REFERENCE. IF YOU ARE UNABLE TO LOCATE THE SOFTWARE LICENSE OR LIMITED WARRANTY, CONTACT YOUR CISCO REPRESENTATIVE FOR A COPY.

The Cisco implementation of TCP header compression is an adaptation of a program developed by the University of California, Berkeley (UCB) as part of UCB’s public domain version of the UNIX operating system. All rights reserved. Copyright © 1981, Regents of the University of California.

NOTWITHSTANDING ANY OTHER WARRANTY HEREIN, ALL DOCUMENT FILES AND SOFTWARE OF THESE SUPPLIERS ARE PROVIDED “AS IS” WITH ALL FAULTS. CISCO AND THE ABOVE-NAMED SUPPLIERS DISCLAIM ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THOSE OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE.

IN NO EVENT SHALL CISCO OR ITS SUPPLIERS BE LIABLE FOR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, OR INCIDENTAL DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST PROFITS OR LOSS OR DAMAGE TO DATA ARISING OUT OF THE USE OR INABILITY TO USE THIS MANUAL, EVEN IF CISCO OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL: www.cisco.com/go/trademarks. Third-party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1110R)

Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental.

Cisco Service Control Subscriber Manager Java API Programmer Guide © 2012 Cisco Systems, Inc. All rights reserved.

OL-26795-02

C O N T E N T S

About this Guide xi

Introduction xi

Document Revision History xii

Organization xiii

Related Documentation xiii

Conventions xiv

Obtaining Documentation and Submitting a Service Request xv

C H A P T E R 1 Getting Started 1-1

Introduction 1-1

The Java API 1-2

Introduction 1-2

Platforms 1-2

Package Content 1-2

Installing the Java API 1-4

Cisco Service Control Subscriber Manager Setup 1-4

Installing on a UNIX Platform 1-4

Installing on a Windows Platform 1-4

Compiling and Running a Program That Uses API 1-5

C H A P T E R 2 General API Concepts 2-1

Introduction 2-1

Blocking API and the Nonblocking API 2-2

Blocking API 2-2

Nonblocking API 2-2

API Initialization 2-3

API Construction 2-3

Constructor that Accepts a LEG Name 2-3

Blocking API—Example 2-3

Setup Operations 2-3

Blocking API Setup 2-4

Nonblocking API Setup 2-4

Connecting to the Cisco Service Control Subscriber Manager 2-4

iiiCisco Service Control Subscriber Manager Java API Programmer Guide

Contents

API Finalization 2-5

Subscriber Name Format 2-5

Network ID Mappings 2-6

Specifying IP Address Mapping 2-6

Specifying IPv6 Address Mapping 2-7

Specifying IP Range Mapping 2-7

Specifying Private IP Address or Private IP Range over VPN Mapping 2-7

Specifying VLAN Tag Mapping 2-8

Subscriber Domains 2-9

Subscriber Properties 2-9

Custom Properties 2-10

DisconnectListener Interface 2-10

DisconnectListener Interface Example 2-10

Exceptions 2-11

Practical Tips 2-11

C H A P T E R 3 Blocking API 3-1

Introduction 3-1

Multithreading Support 3-2

ReplyTimeout and OperationTimeout Exception 3-3

Cisco Service Control Subscriber Manager Blocking API Methods 3-4

login 3-5

Syntax 3-5

Description 3-5

Parameters 3-5

RPC Exception Error Codes 3-6

Return Value 3-6

Examples 3-6

logoutByName 3-8

Syntax 3-8

Description 3-9

Parameters 3-9

Return Value 3-9

RPC Exception Error Codes 3-9

Examples 3-9

logoutByNameFromDomain 3-10

Syntax 3-10

Description 3-10

ivCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Contents

Parameters 3-10

Return Value 3-10

RPC Exception Error Codes 3-11

Example 3-11

logoutByMapping 3-11

Syntax 3-11

Description 3-12

Parameters 3-12

Return Value 3-12

RPC Exception Error Codes 3-12

Example 3-12

loginCable 3-13

Syntax 3-13

Description 3-13

Parameters 3-13

Return Value 3-14

RPC Exception Error Codes 3-14

Examples 3-14

logoutCable 3-16

Syntax 3-16

Description 3-16

Parameters 3-16

Return Value 3-16

RPC Exception Error Codes 3-16

Example 3-16

addSubscriber 3-17

Syntax 3-17

Description 3-17

Example 3-18

Parameters 3-18

Return Value 3-18

RPC Exception Error Codes 3-18

Examples 3-19

removeSubscriber 3-19

Syntax 3-19

Description 3-19

Parameters 3-19

Return Value 3-19

RPC Exception Error Codes 3-20

Example 3-20

vCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Contents

removeAllSubscribers 3-20

Syntax 3-20

Description 3-20

Return Value 3-20

RPC Exception Error Codes 3-20

getNumberOfSubscribers 3-21

Syntax 3-21

Description 3-21

Return Value 3-21

RPC Exception Error Codes 3-21

getNumberOfSubscribersInDomain 3-21

Syntax 3-21

Description 3-22

Parameters 3-22

Return Value 3-22

RPC Exception Error Codes 3-22

getSubscriber 3-22

Syntax 3-22

Description 3-22

Parameters 3-23

Return Value 3-23

RPC Exception Error Codes 3-23

Example 3-23

subscriberExists 3-25

Syntax 3-25

Description 3-25

Parameters 3-25

Return Value 3-25

RPC Exception Error Codes 3-25

subscriberLoggedIn 3-25

Syntax 3-26

Description 3-26

Parameters 3-26

Return Value 3-26

RPC Exception Error Codes 3-26

getSubscriberNameByMapping 3-26

Syntax 3-27

Description 3-27

Parameters 3-27

Return Value 3-27

viCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Contents

RPC Exception Error Codes 3-27

getSubscriberNames (all) 3-28

Syntax 3-28

Description 3-28

Parameters 3-28

Return Value 3-28

RPC Exception Error Codes 3-29

Example 3-29

getSubscriberNames (filter by property) 3-29

Syntax 3-29

Description 3-30

Parameters 3-30

Return Value 3-30

RPC Exception Error Codes 3-30

getSubscriberNamesInDomain 3-30

Syntax 3-31

Description 3-31

Parameters 3-31

Return Value 3-31

RPC Exception Error Codes 3-31

getSubscriberNamesWithPrefix 3-31

Syntax 3-32

Description 3-32

Parameters 3-32

Return Value 3-32

RPC Exception Error Codes 3-32

getSubscriberNamesWithSuffix 3-32

Syntax 3-33

Description 3-33

Parameters 3-33

Return Value 3-33

RPC Exception Error Codes 3-33

getDomains 3-33

Syntax 3-34

Description 3-34

Return Value 3-34

RPC Exception Error Codes 3-34

setPropertiesToDefault 3-34

Syntax 3-34

Description 3-34

viiCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Contents

Parameters 3-35

Return Value 3-35

RPC Exception Error Codes 3-35

removeCustomProperties 3-35

Syntax 3-35

Description 3-35

Parameters 3-36

Return Value 3-36

RPC Exception Error Codes 3-36

Quota Manager Blocking API Methods 3-37

addSubscriberQuota 3-37

Syntax 3-37

Description 3-37

Parameters 3-37

RPC Exception Error Codes 3-38

setSubscriberQuota 3-38

Syntax 3-38

Description 3-38

Parameters 3-38

RPC Exception Error Codes 3-39

replenishSubscriberQuota 3-39

Syntax 3-39

Description 3-39

Parameters 3-39

RPC Exception Error Codes 3-39

getSubscriberQuotaInformation 3-40

Syntax 3-40

Description 3-40

Parameters 3-40

Return Value 3-40

RPC Exception Error Codes 3-41

getSubscriberQuotaProfileId 3-41

Syntax 3-41

Description 3-42

Parameters 3-42

Return Value 3-42

RPC Exception Error Codes 3-42

getBreachedSubscriberNames 3-42

Syntax 3-42

Description 3-42

viiiCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Contents

Parameters 3-43

Return Value 3-43

RPC Exception Error Codes 3-43

getPenaltySubscriberNames 3-43

Syntax 3-43

Description 3-43

Parameters 3-43

Return Value 3-44

RPC Exception Error Codes 3-44

Blocking API Code Examples 3-45

Getting Number of Subscribers 3-45

Adding a Subscriber, Printing Information, and Removing a Subscriber 3-46

Getting Subscriber Quota Information 3-47

C H A P T E R 4 Nonblocking API 4-1

Introduction 4-1

Reliability Support 4-2

Reliable Mode 4-2

Nonreliable Mode 4-2

Autoreconnect Support 4-3

Multithreading Support 4-3

ResultHandler Interface 4-4

ResultHandler Interface Example 4-4

Nonblocking API Construction 4-6

Nonblocking API Syntax 4-6

Nonblocking API Arguments 4-6

Nonblocking API Examples 4-6

Nonblocking API Initialization 4-8

Nonblocking API Initialization Syntax 4-8

Nonblocking API Initialization Parameters 4-8

Nonblocking API Initialization Example 4-8

Nonblocking API Methods 4-9

login 4-9

Syntax 4-9

logoutByName 4-10

Syntax 4-10

logoutByNameFromDomain 4-10

Syntax 4-10

logoutByMapping 4-10

ixCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Contents

Syntax 4-10

loginCable 4-10

Syntax 4-11

logoutCable 4-11

Syntax 4-11

Nonblocking API Code Examples 4-12

Login and Logout 4-12

A P P E N D I X A List of Error Codes A-1

Introduction A-1

List of Error Codes A-1

xCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

About this Guide

Revised: December 21, 2012, OL-26795-02

IntroductionThis document describes the Cisco Service Control Subscriber Manager Java API.

You use the Cisco Service Control Subscriber Manager Java API to update, query, and configure the Cisco Service Control Subscriber Manager. The API has of two parts, which you can use separately or together without restriction:

• Cisco Service Control Subscriber Manager Nonblocking Java API—High-performance API with low visibility to errors and other operation results. Supports automatic integrations with operations support (OSS) systems and authentication, authorization, and accounting (AAA) systems.

• Cisco Service Control Subscriber Manager Blocking Java API—Supports user-interface applications for accessing and managing the Cisco Service Control Subscriber Manager.

Note A set of APIs with the same functionality is also available for the C/C++ environment.

This document is for networking or computer technicians who are responsible for configuring the Cisco Service Control Subscriber Manager. It is also intended for operators who manage Cisco Service Control Engine (Cisco SCE) platforms.

xiCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

About this Guide

Document Revision HistoryThe following Document Revision History table records the changes made to this document.

Table 1 Document Revision History

RevisionCisco Service Control Release and Date Change Summary

OL-26795-02 Release 3.8.5

December 21, 2012

Updated for Release 3.8.5.

• Added new mapping type in the “Network ID Mappings” section on page 6.

OL-26795-01 Release 3.8.x

September 17, 2012

First version of this document (new for the Release 3.8.x train).

xiiCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

About this Guide

OrganizationThis guide contains the following sections.

Related DocumentationUse this document in conjunction with all the Cisco Service Control Subscriber Manager user, API, and reference guides.

Table 2 Document Organization

Section Title Description

Chapter 1 Getting Started Describes the platforms on which you can use the Java API. This chapter also describes how to install, compile, and run the Java API component.

Chapter 2 General API Concepts Describes various concepts that pertain to working with the Cisco Service Control Subscriber Manager Java API.

Chapter 3 Blocking API Describes the features and operation of the blocking API and provides code examples.

Chapter 4 Nonblocking API Describes the features and operation of the nonblocking API and provides code examples.

Appendix A List of Error Codes Lists error codes that are used in the Java API.

xiiiCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

About this Guide

ConventionsThis document uses the following conventions.

Note Means reader take note.

Tip Means the following information will help you solve a problem.

Caution Means reader be careful. In this situation, you might perform an action that could result in equipment damage or loss of data.

Timesaver Means the described action saves time. You can save time by performing the action described in the paragraph.

Warning Means reader be warned. In this situation, you might perform an action that could result in bodily injury.

Table 3 Conventions

Convention Indication

bold font Commands and keywords and user-entered text appear in bold font.

italic font Document titles, new or emphasized terms, and arguments for which you supply values are in italic font.

[ ] Elements in square brackets are optional.

{x | y | z } Required alternative keywords are grouped in braces and separated by vertical bars.

[ x | y | z ] Optional alternative keywords are grouped in brackets and separated by vertical bars.

string A nonquoted set of characters. Do not use quotation marks around the string or the string will include the quotation marks.

courier font Terminal sessions and information the system displays appear in courier font.

< > Nonprinting characters such as passwords are in angle brackets.

[ ] Default responses to system prompts are in square brackets.

!, # An exclamation point (!) or a pound sign (#) at the beginning of a line of code indicates a comment line.

xivCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

About this Guide

Obtaining Documentation and Submitting a Service RequestFor information on obtaining documentation, submitting a service request, and gathering additional information, see the monthly What’s New in Cisco Product Documentation, which also lists all new and revised Cisco technical documentation, at:

http://www.cisco.com/en/US/docs/general/whatsnew/whatsnew.html

Subscribe to What’s New in Cisco Product Documentation as a Really Simple Syndication (RSS) feed and set content to be delivered directly to your desktop using a reader application. The RSS feeds are a free service and Cisco currently supports RSS version 2.0.

xvCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

About this Guide

xviCisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Cisco Service ControOL-26795-02

C H A P T E R 1

Getting Started

Revised: December 21, 2012, OL-26795-02

IntroductionThis chapter identifies the platforms on which you can use the Java API. The chapter also describes how to install, compile, and run the API.

This chapter consists of the following sections:

• The Java API, page 1-2

• Installing the Java API, page 1-4

• Compiling and Running a Program That Uses API, page 1-5

1-1l Subscriber Manager Java API Programmer Guide

Chapter 1 Getting Started The Java API

The Java APIThe following sections provide information about the Java API:

• Introduction, page 1-2

• Platforms, page 1-2

• Package Content, page 1-2

Introduction The Java API enables you to update, query, and configure the Cisco Service Control Subscriber Manager. The API has two parts, which you can use separately or together without restriction.

• Cisco Service Control Subscriber Manager Nonblocking Java API—High-performance API with low visibility to errors and other operation results. This API supports automatic integrations with OSS/AAA systems.

• Cisco Service Control Subscriber Manager Blocking Java API—Supports user-interface applications that enable you to access and manage the Cisco Service Control Subscriber Manager.

Platforms The Cisco Service Control Subscriber Manager Java API was developed and tested on a Windows platform, but it is operable on any platform that supports Java Version 5.0.

Package Content For brevity, <installdir> refers to the installation directory, sm-java-api-vvv.bb.

The <installdir>/javadoc folder contains the API JAVADOC documentation.

The <installdir>lib folder contains the smapi.jar file, which is the API executable. It also contains additional JAR files that are required to operate the API.

Table 1-1 provides the layout of the installation directory.

Table 1-1 Layout of Installation Directory

Path Name Description

<installdir> — —

— README API readme file

<installdir>/javadoc — —

— index.html Index of all API specifications

— (API specification files, and so on.)

API specification documents

<installdir>/lib — —

— smapi.jar Cisco Service Control Subscriber Manager API executable

1-2Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 1 Getting Started Package Content

— asn1rt.jar Utility jar used by the API

— jdmkrt.jar Utility jar used by the API

— log4j.jar Utility jar used by the API

— log4j.properties Property file needed for the API logging functionalities

— xerces.jar Utility jar used by the API

— jce-jdk13-133.jar Provides an implementation of the Java Cryptography Extension API

Table 1-1 Layout of Installation Directory (continued)

Path Name Description

1-3Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 1 Getting Started Installing the Java API

Installing the Java API The Java API is part of the Cisco Service Control Subscriber Manager Login Event Generator (LEG) distribution file and is located in the SM_API directory.

The Cisco Service Control Subscriber Manager Java API is packaged in a UNIX tar file. The API is compiled with log4j 1.2. You can extract the Java API by using the UNIX tar utility or most Windows compression utilities:

• Cisco Service Control Subscriber Manager Setup, page 1-4

• Installing on a UNIX Platform, page 1-4

• Installing on a Windows Platform, page 1-4

Cisco Service Control Subscriber Manager Setup The API connects to the Proprietary Remote Procedure Call (PRPC) server on the Cisco Service Control Subscriber Manager. To enable the API to operate, the following conditions must be met:

• The Cisco Service Control Subscriber Manager must be operating, and reachable from the machine that hosts the API.

• The PRPC server must be started.

The PRPC server is a proprietary RPC protocol designed by Cisco. For more information about the PRPC server, see the Cisco Service Control Management Suite Subscriber Manager User Guide.

Installing on a UNIX Platform

Note The abbreviations vvv and bb represent the Cisco Service Control Subscriber Manager Java API version and build number.

To install Cisco Service Control Subscriber Manager Java API:

Step 1 Extract the Cisco Service Control Subscriber Manager LEG distribution file.

Step 2 Locate the Cisco Service Control Subscriber Manager Java API distribution tar, sm-java-api-dist.tar.

Step 3 Extract the Cisco Service Control Subscriber Manager Java API distribution tar and obtain sm-java-api-vvv.bb.tar.

#>tar -xvf sm-java-api-dist.tar

Step 4 Extract the Cisco Service Control Subscriber Manager Java API package tar.

#>tar -xvf sm-java-api-vvv.bb.tar

Installing on a Windows Platform Use a zip extractor (such as WinZip).

1-4Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 1 Getting Started Compiling and Running a Program That Uses API

Compiling and Running a Program That Uses APITo compile and run a program that uses the Cisco Service Control Subscriber Manager Java API, smapi.jar must be in the CLASSPATH.

For example, if the program source is in SMApiProgram.java, use the following command to compile the program:

#>javac -classpath smapi.jar SMApiProgram.java

After compiling the program, use the following command to run the program:

#>java -cp .;<installdir>/lib/smapi.jar SMApiProgram

1-5Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 1 Getting Started Compiling and Running a Program That Uses API

1-6Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Cisco Service ControOL-26795-02

C H A P T E R 2

General API Concepts

Revised: December 21, 2012, OL-26795-02

IntroductionThis chapter describes the concepts that pertain to working with the Cisco Service Control Subscriber Manager Java API.

This chapter consists of the following sections:

• Blocking API and the Nonblocking API, page 2-2

• API Initialization, page 2-3

• API Finalization, page 2-5

• Subscriber Name Format, page 2-5

• Network ID Mappings, page 2-6

• Subscriber Domains, page 2-9

• Subscriber Properties, page 2-9

• Custom Properties, page 2-10

• DisconnectListener Interface, page 2-10

• Exceptions, page 2-11

• Practical Tips, page 2-11

2-1l Subscriber Manager Java API Programmer Guide

Chapter 2 General API Concepts Blocking API and the Nonblocking API

Blocking API and the Nonblocking APIThis section describes the differences between the Blocking API and the Nonblocking API.

• Blocking API, page 2-2

• Nonblocking API, page 2-2

Blocking API In a Blocking API operation, which is the most common, every method returns after its operation is performed.

The Cisco Service Control Subscriber Manager Blocking Java API provides a wide range of operations. It contains most of the functionality of the Nonblocking API and many functions that the Nonblocking API does not provide. The Blocking API does not support reliability and autoreconnect functionality.

Nonblocking API In a Nonblocking Java API operation, every method returns immediately, even before the completion of its operation. The operation results are either returned to an observer object (listener) or not returned at all.

The Nonblocking API method is preferred when the operation is lengthy and involves I/O. When the operation is performed in a separate thread, the calling program can continue performing other tasks, which improves the overall system performance.

The Cisco Service Control Subscriber Manager Nonblocking Java API contains a small number of nonblocking operations. The API supports the retrieval of operation results by using a result listener.

The Cisco Service Control Subscriber Manager Nonblocking Java API supports two modes—reliable and nonreliable. For more information about the reliability modes, see the “Reliability Support” section on page 4-2.

2-2Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts API Initialization

API Initialization To initialize the API, you must complete three tasks:

• Construct the API by using one of its constructors. For details, see the “API Construction” section on page 2-3.

• Perform the API-specific setup operations. For details, see the “Setup Operations” section on page 2-3.

• Connect the API to the Cisco Service Control Subscriber Manager. For details, see the “Connecting to the Cisco Service Control Subscriber Manager” section on page 2-4.

API Construction Blocking and Nonblocking APIs have two constructors:

• An Empty constructor

• A Constructor that accepts a Login Event Generator (LEG) name as a parameter.

Constructor that Accepts a LEG Name

Set the LEG name if you intend to turn on the Cisco Service Control Subscriber Manager LEG failure processing options in the Cisco Service Control Subscriber Manager. For more information about the LEG software components and SM-LEG failure handling, see the Cisco Service Control Management Suite Subscriber Manager User Guide.

The Cisco Service Control Subscriber Manager uses the LEG name when recovering from a connection failure. A constant string that identifies the API is appended to the LEG name as follows:

• For blocking API—.B.SM-API.J

• For nonblocking API—.NB.SM-API.J

Blocking API—Example

If the provided LEG name is my-leg.10.1.12.45-version-1.0, the actual LEG name is my-leg.10.1.12.45-version-1.0.B.SM-API.J.

If no name is set, the LEG uses the hostname of the machine as the prefix of the name.

Additional constructors are available for the Nonblocking API. For more information, see the “Nonblocking API Construction” section on page 4-6.

Setup Operations The setup operations differ for the two APIs. Both APIs support setting a disconnect listener, which is described in detail in the “DisconnectListener Interface” section on page 2-10.

• Blocking API Setup, page 2-4

• Nonblocking API Setup, page 2-4

2-3Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts Connecting to the Cisco Service Control Subscriber Manager

Blocking API Setup

To set up the Blocking API, you must set an operation timeout value. For more information, see Chapter 3, “Blocking API”.

Nonblocking API Setup

To set up the Nonblocking API, you must set a disconnect listener. For more details, see Chapter 4, “Nonblocking API”.

Connecting to the Cisco Service Control Subscriber Manager To connect to the Cisco Service Control Subscriber Manager, use one of the following connect methods.

• Use the following method to connect to the Cisco Service Control Subscriber Manager by using the default remote procedure call (RPC) TCP port (14374):

connect(String host)

• Use the following method to allow the caller to set the TCP port to which the API connects:

connect(String host, int port)

For both methods, the host parameter can be either an IP address or a reachable hostname.

At any time during the API operation, you can check if the API is connected by using the isConnected method.

2-4Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts API Finalization

API FinalizationTo free the resources of both the server and the client, use the disconnect method.

Use a finally statement in your main class, as follows:

public static void main(String [] args) throws Exception { SMNonBlockingApi smnbapi = new SMNonBlockingApi(); try { ... } finally { smnbapi.disconnect(); }}

Subscriber Name FormatMost methods of both APIs require the subscriber name as an input parameter.

A subscriber name can contain up to 64 characters. You can use all printable characters with an ASCII code between 32 and 126 (inclusive), except for 34 ("), 39 ('), and 96 (`).

2-5Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts Network ID Mappings

Network ID MappingsA network ID mapping is a network identifier that the Service Control Engine (SCE) device can map to a specific subscriber record. A typical example of a network ID mapping (or simply, mapping) is an IP address. Currently, the Cisco Service Control solution supports IP address, IP range, private IP address over VPN, private IP range over VPN, and VLAN mappings.

Both Blocking and Nonblocking APIs contain operations that accept mappings as a parameter, such as the following:

• The addSubscriber operation (Blocking API)

• The login method (Blocking or Nonblocking API)

When passing mappings to an API method, the caller is requested to provide two parameters:

• The java.lang.String mapping identifier or array of mapping types

• The short mapping type or array of mapping types

When passing arrays, the mappingTypes array must contain either the same number of elements as the mappings array or a single element. If the mappingTypes array contains a single element, all the mappings have the same type, specified by this single element.

Note Only one mapping type is allowed in a call to any of the APIs.

APIs supports the following subscriber mapping types:

• IP addresses or IP ranges

• (From Cisco Service Control Subscriber Manager, Release 3.8.5) IPv6 address

• Private IP addresses or private IP ranges over VPN

• VLAN tags

• (From Cisco Service Control Subscriber Manager, Release 3.8.5) IPv6 addresses or IPv6 prefix

For additional information, see the Cisco Service Control Management Suite Subscriber Manager User Guide.

Specifying IP Address Mapping The string format of an IP address is the commonly used decimal notation:

IP-Address=[0-255].[0-255].[0-255].[0-255]

Example:

• 216.109.118.66

The mapping type of an IP address is provided in the com.pcube.management.api.SMApiConstants interface:

• com.pcube.management.api.SMApiConstants.MAPPING_TYPE_IP specifies a single IP mapping that matches the mapping identifier with the same index in the mapping identifier array.

• com.pcube.management.api.SMApiConstants.ALL_IP_MAPPINGS specifies that all the entries in the mapping identifier array are IP mappings.

2-6Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts Specifying IPv6 Address Mapping

Specifying IPv6 Address MappingThe string format of an IP address is the commonly used hexadecimal colon-separated notation:

IPV6-Address=[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000-FFFF]/[32-64]

Note The prefix value of all IPv6 addresses should be between 32 and 64. Only the first 64-bit of the IPv6 address is considered.

The mapping type of an IP address is provided in the com.pcube.management.api.SMApiConstants interface:

• com.pcube.management.api.SMApiConstants.MAPPING_TYPE_IPV6 specifies a single IP mapping that matches the mapping identifier with the same index in the mapping identifier array.

• com.pcube.management.api.SMApiConstants.ALL_IPV6_MAPPINGS specifies that all entries in the mapping identifier array are IPv6 mappings.

Example:

• 2001:db8:85a3::8a2e:370:7334/64

Specifying IP Range Mapping The string format of an IP range is an IPv4 address in decimal notation and a decimal specifying the number of 1s in a bit mask:

IP-Range=[0-255].[0-255].[0-255].[0-255]/[0-32]

Examples:

• 10.1.1.10/32 is an IP range with a complete mask, that is, a regular IP address.

• 10.1.1.0/24 is an IP range with a 24-bit mask, that is, all the addresses ranging between 10.1.1.0 and 10.1.1.255.

Note The mapping type of an IP range is identical to the mapping type of the IP address.

Specifying Private IP Address or Private IP Range over VPN MappingThe string format of an IPv4 address and an IP range are described in the “Specifying IP Address Mapping” section on page 2-6 and in the “Specifying IP Range Mapping” section on page 2-7. When the network ID mapping uses an IP address or range over VPN, the string format includes the VPN name.

Examples:

• 10.1.1.10@VPN1 is an IP address over the VPN named VPN1.

• 10.1.1.0/24@VPN2 is an IP range with a 24-bit mask, that is, all of the addresses in the range from 10.1.1.0 to 10.1.1.255 over the VPN named VPN2.

2-7Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts Specifying VLAN Tag Mapping

Note The mapping type of an IP address or IP range over VPN is identical to the mapping type of the IP address.

Specifying VLAN Tag Mapping The string format for VLAN tag mapping is VLAN-tag = 0 to 4095.

The value is a decimal in the specified range.

The com.pcube.management.api.SMApiConstants interface also provides the mapping type:

• com.pcube.management.api.SMApiConstants.MAPPING_TYPE_VPN specifies a single VLAN mapping that matches the mapping identifier with the same index in the mapping identifier array.

• com.pcube.management.api.SMApiConstants.ALL_VPN_MAPPINGS specifies that all the entries in the mapping identifiers array are VLAN mappings.

Note The SMApiConstants.TYPE_VLAN and SMApiConstants.ALL_VLAN_MAPPINGS constants are deprecated. You should use the SMApiConstants.TYPE_VPN and SMApiConstants.ALL_VPN_MAPPINGS constants instead.

2-8Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts Subscriber Domains

Subscriber DomainsThe Cisco Service Control Management Suite Subscriber Manager User Guide defines the domain concept. Briefly, a domain identifies for the Cisco Service Control Subscriber Manager the Cisco SCE devices to which it updates subscriber records.

A domain name is a type of String. During system installation, the network administrator determines the system domain names, which, therefore, vary between installations. The APIs include methods that specify the domain to which a subscriber belongs. The APIs also provide methods that enable queries about system domain names. If an API operation specifies a domain name that does not exist in the Cisco Service Control Subscriber Manager domain repository, it is considered an error and RpcErrorException is returned.

The Cisco Service Control Subscriber Manager automatic domain roaming feature enables you to move subscribers between domains by calling the login method for a subscriber with an updated domain parameter as described in the “login” section on page 3-5.

Note Automatic domain roaming is not backward compatible with previous versions of the Cisco Service Control Subscriber Manager API. Previous versions did not permit changing the domain of the subscriber.

Subscriber PropertiesSeveral operations manipulate subscriber properties. A subscriber property is a key/value pair that affects the way the Cisco SCE analyzes and reacts to network traffic generated by the subscriber.

For information about properties, see the Cisco Service Control Management Suite Subscriber Manager User Guide and the Cisco Service Control Application for Broadband User Guide. The latter provides application-specific information; it lists the subscriber properties that exist in the application running on your system, the allowed value set, and the significance of each property value.

To format subscriber properties for Java API operations, use the String arrays propertyKeys and propertyValues.

Note The arrays must be of the same length, and NULL entries are forbidden. Each key in the keys array has a matching entry in the values array; the value for propertyKeys[j] resides in propertyValues[j]. The mapping type of an IP range is identical to the mapping type of the IP address.

Example:

If the property keys array is {"packageId","monitor"} and the property values array is {"5","1"}, the properties are packageId=5, monitor=1.

2-9Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts Custom Properties

Custom PropertiesSome operations manipulate custom properties. Custom properties are similar to subscriber properties, but do not affect how the SCE analyzes and manipulates the subscriber traffic. The application management modules use custom properties to store additional information for each subscriber.

To format custom properties, use the String arrays customPropertyKeys and customPropertyValues. This formatting is the same as in the subscriber properties formatting described in the “Subscriber Properties” section on page 2-9.

DisconnectListener InterfaceBoth APIs (Blocking and Nonblocking) enable you to set a disconnect listener. The disconnect listener is an interface with a single method:

public interface DisconnectListener { /** * called when the connection with the server is down. */ public void connectionIsDown();}

Implement this interface to be notified when the API is disconnected from the Cisco Service Control Subscriber Manager.

To set a disconnect listener, use the setDisconnectListener method.

DisconnectListener Interface ExampleThe following example is a basic implementation of a disconnect listener that prints a message to stdout and exits:

import com.pcube.management.framework.rpc.DisconnectListener;

public class MyDisconnectListener implements DisconnectListener {

public void connectionIsDown(){ System.out.println("Message: connection is down."); System.exit(0); }}

2-10Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts Exceptions

ExceptionsThe same Java class, com.pcube.management.framework.rpc.RpcErrorException, provides all of the functional errors of the Cisco Service Control Subscriber Manager Java API. This is contrary to the normal Java usage. This approach was chosen because of the cross-language nature of the Cisco Service Control Subscriber Manager API. It enables all Cisco Service Control Subscriber Manager API implementations (Java, C, and C++) to appear similar.

Each exception provides the following information:

• Unique error code (long)

• Informative message (java.lang.String)

• Server-side stack trace (java.lang.String)

The error code can be interpreted by using com.pcube.management.api.SMApiConstants. See Appendix A, “List of Error Codes” for details about error codes and their significance.

Note Several types of errors can occur only if you use the Blocking API. These are operational errors that are related to operation-timeout handling. These errors are described in Chapter 3, “Blocking API.”

Practical TipsWhen implementing the code that integrates the API with your application, consider the following practical tips:

• Connect to the Cisco Service Control Subscriber Manager once and maintain an open API connection to the Cisco Service Control Subscriber Manager at all times, using the API many times. Establishing a connection is a timely procedure, which allocates resources on the Cisco Service Control Subscriber Manager side and the API client side.

• Share the API connection between your threads. It is best to have one connection per LEG. Multiple connections require more resources on the Cisco Service Control Subscriber Manager side and client side.

• Do not implement synchronization of the calls to the API. The client automatically synchronizes calls to the API.

• Place the API clients (LEGs) in the same order as the Cisco Service Control Subscriber Manager machine processor number.

• If the LEG application has bursts of login operations, enlarge the internal buffer size accordingly to hold these bursts (Nonblocking API).

• During the integration, set the Cisco Service Control Subscriber Manager logon_logging_enabled configuration parameter to enable viewing the API operations in the Cisco Service Control Subscriber Manager log. Setting this parameter enables you to troubleshoot the integration, if any problems arise.

• Use the debug mode for the LEG application that logs the return values of the nonblocking operations.

• Use the automatic reconnect feature to improve the resiliency of the connection to the Cisco Service Control Subscriber Manager.

• In cluster setups, connect the API by using the virtual IP address of the cluster and not the management IP address of one of the machines.

2-11Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 2 General API Concepts Practical Tips

2-12Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Cisco Service ControOL-26795-02

C H A P T E R 3

Blocking API

Revised: December 21, 2012, OL-26795-02

IntroductionThis chapter introduces the Reply Timeout, a feature unique to the Blocking API.

The chapter also lists all the operations of the Blocking API, and provides code examples.

Note If you need to develop only an automatic integration, skip this chapter and go directly to Chapter 4, “Nonblocking API.”

This chapter consists of the following sections:

• Multithreading Support, page 3-2

• ReplyTimeout and OperationTimeout Exception, page 3-3

• Cisco Service Control Subscriber Manager Blocking API Methods, page 3-4

• Quota Manager Blocking API Methods, page 3-37

• Blocking API Code Examples, page 3-45

3-1l Subscriber Manager Java API Programmer Guide

Chapter 3 Blocking API Multithreading Support

Multithreading SupportThe Blocking API supports an unlimited number of threads calling its methods simultaneously.

Note In a multithreaded 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 might be performed before operation-0, as shown in Figure 3-1 (the vertical scale is time):

Figure 3-1 Multithreading Support

The Cisco Service Control Subscriber Manager allocates five threads to manage each API instance. Develop a multithreaded application that uses the API with several threads in the order of the five threads. Implementing with more threads might result in longer delays for the calling threads.

1571

10

Thread 0 :

op-0 : operation

op-1 : operation

op-1 : result

op-0 : result

Thread 1 : SM Blocking API :

3-2Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API ReplyTimeout and OperationTimeout Exception

ReplyTimeout and OperationTimeout ExceptionA blocking operation returns only when the operation result is retrieved from the Cisco Service Control Subscriber Manager. If a networking malfunction or other error prevents the operation result from being retrieved, the caller waits indefinitely. The Cisco Service Control Subscriber Manager API provides a means of working around this situation.

The reply timeout feature (the setReplyTimeout method) enables the caller to set a timeout. It will generate 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, stop responding) 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; java.lang.InterruptedException will then be returned to the caller.

3-3Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API Cisco Service Control Subscriber Manager Blocking API Methods

Cisco Service Control Subscriber Manager Blocking API Methods

This section lists the methods of the Cisco Service Control Subscriber Manager Blocking API. The description of each method includes its syntax, input parameters, and return values.

The Blocking API is a superset of the Nonblocking 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 generate java.lang.IllegalStateException when called before the API establishes a connection with the Cisco Service Control Subscriber Manager.

The Blocking API methods are classified as follows:

• Dynamic IP and property allocation—Use the following methods to integrate the Cisco Service Control Subscriber Manager API with an authentication, authorization, and accounting (AAA) system. These methods are not designed to add or remove subscribers from the database. Instead, they modify dynamic parameters (such as IP addresses) of the existing subscribers:

– login, page 3-5

– logoutByName, page 3-8

– logoutByNameFromDomain, page 3-10

– logoutByMapping, page 3-11

– loginCable, page 3-13

– logoutCable, page 3-16

• Static or Manual Subscriber configuration—Use the following methods for a GUI:

– addSubscriber, page 3-17

– removeSubscriber, page 3-19

– removeAllSubscribers, page 3-20

– setPropertiesToDefault, page 3-34

– removeCustomProperties, page 3-35

• Use the following methods for simple read-only operations, performed independently in the subscriber awareness mode:

– getNumberOfSubscribers, page 3-21

– getNumberOfSubscribersInDomain, page 3-21

– getSubscriber, page 3-22

– subscriberExists, page 3-25

– subscriberLoggedIn, page 3-25

– getSubscriberNameByMapping, page 3-26

– getSubscriberNames (all), page 3-28

– getSubscriberNames (filter by property), page 3-29

– getSubscriberNamesInDomain, page 3-30

– getSubscriberNamesWithPrefix, page 3-31

– getSubscriberNamesWithSuffix, page 3-32

– getDomains, page 3-33

3-4Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API login

You can mix methods from different categories in a single application. The classification is presented only for clarity.

loginThe following sections provide information about the login operation:

• Syntax, page 3-5

• Description, page 3-5

• Parameters, page 3-5

• RPC Exception Error Codes, page 3-6

• Return Value, page 3-6

• Examples, page 3-6

Syntax

The login syntax is as follows:

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 Cisco Service Control Subscriber Manager database. The login method can be called with partial data; for example, it might provide mappings or properties only, and put NULL ++++ in the unchanged fields.

If another subscriber with the same (or conflicting) mappings already exists in the same domain, the conflicting mappings are removed from the other subscriber and assigned to the new subscriber.

If the subscriber does not exist in the Cisco Service Control Subscriber Manager database, the login method creates it with the data provided.

Parameters

The parameters of the login method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings and mapping types in the “Network ID Mappings” section on page 2-6. If no mappings are specified, and the isMappingAdditive parameter is TRUE, the previous mappings are retained. If no such mappings exist, the operation fails.

• mappingTypes—See the description of mappings and mapping types in the “Network ID Mappings” section on page 2-6.

3-5Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API login

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-9.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-9.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-9.

If domain is NULL, but the subscriber already has a domain, the existing domain is retained.

If the domain is different from the domain that was previously assigned to the subscriber, the subscriber is removed automatically from the Cisco 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 the mappings provided as arguments to this method.

– Positive value (N)—Automatically logs out the mappings (similar to calling a logout method) after N seconds.

– 0 value—Maintains the current expiration time for the given mappings.

– Negative value—Disables any expiration time set for the given mappings.

RPC Exception Error Codes

The following list presents the error codes the login 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 parameter settings:

– NULL value for the domain parameter for the subscriber that does not exist or does not have a domain

– Invalid values for the propertyValues parameter

For a description of error codes, see Appendix A, “List of Error Codes”.

Return Value

None.

Examples

To add the IP address 192.168.12.5 to an existing subscriber named alpha without affecting existing mappings:

login(

3-6Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API login

"alpha", // 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( "alpha", // 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, which was previously assigned to alpha:

login( "alpha", //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 alpha (for example, package ID):

login( "alpha", 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 alpha without affecting existing mappings and to modify a dynamic property of alpha (for example, package ID):

login( "alpha", 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);

To add the IPv6 address 2000:2001:2002:abcd::/64 to an existing subscriber named alpha without affecting existing mappings:

login( "alpha", // subscriber name new String[]{"2000:2001:2002:abcd::/64"}, SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain true, // isMappingAdditive is true -1); // autoLogoutTime set to infinite

3-7Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API logoutByName

To add the IPv6 address 2000:2001:2002:abcd::/64 overriding previous mappings:

login( "alpha", // subscriber name new String[]{"2000:2001:2002:abcd::/64"}, SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain false, // isMappingAdditive is false -1); // autoLogoutTime set to infinite

To extend the auto logout time of 2000:2001:2002:abcd::/64 that was previously assigned to alpha:

login( "alpha", //the previously assigned IP new String[]{"2000:2001:2002:abcd::/64"}, SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain false, // isMappingAdditive 300); // autoLogoutTime set to 300 seconds

To add the IPv6 address 2000:2001:2002:abcd::/64 to an existing subscriber named alpha without affecting the existing mappings, and to modify a dynamic property of alpha,for example, package ID:

login( "alpha", new String[]{"2000:2001:2002:abcd::/64"}, SMApiConstants.ALL_IPV6_MAPPINGS, new String[]{"packageId"}, // property key new String[]{"10"}, // property value "subscribers", // domain true, // isMappingAdditive is set to true -1);

logoutByNameThe following sections provide information about the logoutByName operation:

• Syntax, page 3-8

• Description, page 3-9

• Parameters, page 3-9

• Return Value, page 3-9

• RPC Exception Error Codes, page 3-9

• Examples, page 3-9

Syntax

The logoutByName syntax is as follows:

public boolean logoutByName(String subscriberName, String[] mappings, short[] mappingTypes)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-8Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API logoutByName

Description

The logoutByName method locates the subscriber in the database and removes mappings from it. If the subscriber does not exist, the logoutByName operation does not do anything.

Parameters

The parameters of the logoutByName method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings in the “Network ID Mappings” section on page 2-6. If no mappings are specified, all subscriber mappings are removed.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

Return Value

• TRUE—If the subscriber was found and the subscriber mappings were removed from the subscriber database

• FALSE—If the subscriber was not found in the subscriber database

RPC Exception Error Codes

The following list presents the error codes the logoutByName 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 Appendix A, “List of Error Codes”.

Examples

To remove IP address 192.168.12.5 of subscriber alpha:

boolean isExist = logoutByName( "alpha", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS);

To remove all IP addresses of subscriber alpha:

boolean isExist = logoutByName("alpha", null, null);

3-9Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API logoutByNameFromDomain

logoutByNameFromDomainThe following sections provide information about the logoutByNameFromDomain operation:

• Syntax, page 3-10

• Description, page 3-10

• Parameters, page 3-10

• Return Value, page 3-10

• RPC Exception Error Codes, page 3-11

• Example, page 3-11

Syntax

The logoutByNameFromDomain syntax is as follows:

public boolean logoutByNameFromDomain(String subscriberName, String[] mappings, short[] mappingTypes, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The logoutByNameFromDomain similar to logoutByName, but this method also enables the caller to provide the name of the domain to which the subscriber belongs. When the subscriber domain is known, use this method to improve performance.

Parameters

The parameters of the logoutByNameFromDomain method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings in the “Network ID Mappings” section on page 2-6. If no mappings are specified, all subscriber mappings are removed.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-9.

The operation fails if either of the following conditions exists:

• Domain is null, but the subscriber exists in the database and belongs to a domain.

• 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

3-10Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API logoutByMapping

RPC Exception Error Codes

The following list presents error codes the logoutByNameFromDomain 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 Appendix A, “List of Error Codes”.

Example

To remove IP address 192.168.12.5 of subscriber alpha from domain subscribers:

boolean isExist = logoutByNameFromDomain( "alpha", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, "subscribers");boolean isExist = logoutByNameFromDomain( "alpha", null, null, "subscribers");

logoutByMappingThe following sections provide information about the logoutByMapping operation:

• Syntax, page 3-11

• Description, page 3-12

• Parameters, page 3-12

• Return Value, page 3-12

• RPC Exception Error Codes, page 3-12

• Example, page 3-12

Syntax

The logoutByMapping syntax is as follows:

public boolean logoutByMapping(String mapping, short mappingType, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-11Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API logoutByMapping

Description

The logoutByMapping locates a subscriber based on domain and mapping, and removes the mapping (the subscriber stays in the database).

Parameters

The parameters of the logoutByMapping method are as follows:

• mapping—See the description of mappings in the “Network ID Mappings” section on page 2-6.

• mappingType—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—See the description of the logoutByNameFromDomain operation in the “Parameters” section on page 3-10.

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 list presents error codes the logoutByMapping 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 Appendix A, “List of Error Codes”.

Example

To remove IP address 192.168.12.5 from domain subscribers:

boolean isExist = logoutByMapping( "192.168.12.5", SMApiConstants. MAPPING_TYPE_IP, "subscribers");

To remove IPv6 address 2001:db8:85a3::8a2e:370:7334/64 from domain subscribers:

boolean isExist = logoutByMapping( "2001:db8:85a3::8a2e:370:7334/64", SMApiConstants. MAPPING_TYPE_IPV6, "subscribers");

3-12Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API loginCable

loginCableThe following sections provide information about the loginCable operation:

• Syntax, page 3-13

• Description, page 3-13

• Parameters, page 3-13

• Return Value, page 3-14

• RPC Exception Error Codes, page 3-14

• Examples, page 3-14

Syntax

The loginCable syntax is as follows:

public void loginCable(String CPE, String CM, String IP, int lease, String domain, String[] propertyKeys, String[] propertyValues)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The loginCable method is an operation adapted for the cable environment; it calls the cable support module in the Cisco Service Control Subscriber Manager. This method is designed to log in the customer premise equipment (CPE) and content managers to the Cisco Service Control Subscriber Manager. To log in a CPE, specify its cable modem (CM) MAC in the CM argument and the CPE MAC in the CPE argument. To log in a cable modem, specify the cable modem MAC address in both CPE and CM arguments. Note that the login of a CPE whose CM does not exist in the Cisco Service Control Subscriber Manager database is 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 Cisco Service Control Management Suite Subscriber Manager User Guide.

Note The name of the CPE in the Cisco Service Control Subscriber Manager database is the concatenation of the CPE and CM values with two underscore characters (“_”) between them. The caller must ensure that the lengths of CPE and CM add up to no more than 38 characters.

Parameters

The parameters of the loginCable method are as follows:

• CPE—Unique identifier of the CPE (usually a MAC address)

• CM—Unique identifier of the cable modem (usually a MAC address)

• IP—CPE IP address (IPv4 address or IPv6 address)

• lease—CPE lease time

3-13Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API loginCable

• domain—See the description of the subscriber domains in the “Subscriber Domains” section on page 2-9. The domain is usually cable modem termination system (CMTS) IP.

Note Domain aliases must be set on the Cisco Service Control Subscriber Manager so that the cable modem termination system (CMTS) IP is correctly interpreted as a domain name. For information about configuring aliases, see the Default Domains Configuration section of Cisco SCMS Subscriber Manager User Guide.

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-9.

If the CPE is provided with partial or no application properties, the values for the missing application properties are copied from the application properties of the cable modem to which this CPE belongs. Each cable modem application property thus serves as a default for the CPE with which it is associated.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-9.

Return Value

None.

RPC Exception Error Codes

None.

Examples

To add the IP address 192.168.12.5 to a cable modem called CM1 with two hours of 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 a lease time of one hour:

loginCable( "CPE1", "CM1", "192.168.12.50", 3600, // lease time in seconds "subscribers", null, null);

To add the IPv6 address 2001:db8:85a3::8a2e:370:7334/64 to a cable modem called CM1 with two hours of lease time:

loginCable( "CM1", "CM1", "2001:db8:85a3::8a2e:370:7334/64", 7200, // lease time in seconds

3-14Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API loginCable

"subscribers", null, null);

3-15Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API logoutCable

logoutCableThe following sections provide information about the logoutCable operation:

• Syntax, page 3-16

• Description, page 3-16

• Parameters, page 3-16

• Return Value, page 3-16

• RPC Exception Error Codes, page 3-16

• Example, page 3-16

Syntax

The logoutCable syntax is as follows:

public boolean logoutCable(String CPE, String CM, String IP, String domain)

Description

The logoutCable method indicates to the Cisco Service Control Subscriber Manager cable support module that a logout event has happened.

Parameters

The parameters of the logoutCable method are as follows:

• CPE—See the description in the “Parameters” section on page 3-13.

• CM—See the description in the “Parameters” section on page 3-13.

• IP—See the description in the “Parameters” section on page 3-13.

• domain—See the description in the “Parameters” section on page 3-13.

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.

Example

To remove the IP address 192.168.12.5 from CPE1, which is associated with CM1:

boolean isExist = logoutCable( "CPE1",

3-16Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API addSubscriber

"CM1", "192.168.12.5", "subscribers");

addSubscriberThe following sections provide information about the addSubscriber operation:

• Syntax, page 3-17

• Description, page 3-17

• Example, page 3-18

• Parameters, page 3-18

• Return Value, page 3-18

• RPC Exception Error Codes, page 3-18

• Examples, page 3-19

Syntax

The addSubscriber syntax is as follows:

public void addSubscriber(String subscriberName, String[] mappings, short[] mappingTypes, String[] propertyKeys, String[] propertyValues, String[] customPropertyKeys, String[] customPropertyValues, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The addSubscriber method creates a new subscriber record according to the method parameters and adds the record to the Cisco Service Control Subscriber Manager database.

When adding a new subscriber name, if the name already exists in Cisco Service Control Subscriber Manager database, the first instance of the name is removed before the new one is added. In contrast to login method, which modifies fields and leaves unspecified fields unchanged, the addSubscriber method sets the subscriber exactly as specified by the parameters passed to it.

Note Use the call login method for existing subscribers, instead of the addSubscriber command. You should set dynamic mappings and properties by using the login command. Set static mappings and properties the first time the subscriber is created by using the addSubscriber command.

Note With the addSubscriber command, the autologout feature is always disabled. To enable autologout, use the login command.

3-17Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API addSubscriber

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 is left with no mappings.

However, calling the login operation with these NULL-value parameters does not change the subscriber mappings of AB; AB retains its previous IP mapping of IP1.

Parameters

The parameters of the addSubscriber method are as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description in the “Network ID Mappings” section on page 2-6.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-9.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-9.

• customPropertyKeys—See the description of custom property keys in the “Custom Properties” section on page 2-10.

• customPropertyValues—See the description of custom property values in the “Custom Properties” section on page 2-10.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-9.

A NULL value indicates that the subscriber has no domain. If domain is NULL, but the subscriber already has a domain, the existing domain is retained.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the addSubscriber 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 might indicate invalid values that were supplied for the propertyValues parameter.

• ERROR_CODE_DATABASE_EXCEPTION

3-18Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API removeSubscriber

For a description of error codes, see Appendix A, “List of Error Codes”.

Examples

The following example code adds a new subscriber, alpha, with some custom properties:

addSubscriber("alpha", 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

removeSubscriberThe following sections provide information about the removeSubscriber operation:

• Syntax, page 3-19

• Description, page 3-19

• Parameters, page 3-19

• Return Value, page 3-19

• RPC Exception Error Codes, page 3-20

• Example, page 3-20

Syntax

The removeSubscriber syntax is as follows:

public boolean removeSubscriber(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeSubscriber method removes a subscriber completely from the Cisco Service Control Subscriber Manager database.

Parameters

The only parameter of the removeSubscriber method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber was found in the database and successfully removed.

• FALSE—If the conditions for TRUE were not met; in other words, the subscriber was not found in the database, or the subscriber was found but was not successfully removed.

3-19Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API removeAllSubscribers

RPC Exception Error Codes

The following list presents error codes that the removeSubscriber method 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 Appendix A, “List of Error Codes”.

Example

The following example code removes subscriber alpha entirely from the database:

boolean isExist = removeSubscriber("alpha");

removeAllSubscribersThe following sections provide information about the removeAllSubscribers operation:

• Syntax, page 3-20

• Description, page 3-20

• Return Value, page 3-20

• RPC Exception Error Codes, page 3-20

Syntax

The removeAllSubscribers syntax is as follows:

public void removeAllSubscribers() throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeAllSubscribers method removes all subscribers from the Cisco Service Control Subscriber Manager, leaving the database with no subscribers.

Note This method might 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.

3-20Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getNumberOfSubscribers

getNumberOfSubscribersThe following sections provide information about the getNumberOfSubscribers operation:

• Syntax, page 3-21

• Description, page 3-21

• Return Value, page 3-21

• RPC Exception Error Codes, page 3-21

Syntax

The getNumberOfSubscribers syntax is as follows:

public int getNumberOfSubscribers() throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getNumberOfSubscribers method retrieves the total number of subscribers in the Cisco Service Control Subscriber Manager database.

Return Value

The number of subscribers in the Cisco Service Control Subscriber Manager.

RPC Exception Error Codes

None.

getNumberOfSubscribersInDomainThe following sections provide information about the getNumberOfSubscribersInDomain operation:

• Syntax, page 3-21

• Description, page 3-22

• Parameters, page 3-22

• Return Value, page 3-22

• RPC Exception Error Codes, page 3-22

Syntax

The getNumberOfSubscribersInDomain syntax is as follows:

public int getNumberOfSubscribersInDomain(String domain) throws InterruptedException, OperationTimeoutException, RpcErrorException

3-21Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriber

Description

The getNumberOfSubscribersInDomain method retrieves the number of subscribers in a subscriber domain.

Parameters

The only parameter of the getNumberOfSubscribersInDomain method is as follows:

• domain—Name of a subscriber domain that exists in the Cisco Service Control Subscriber Manager domain repository.

Return Value

The number of subscribers in the provided domain.

RPC Exception Error Codes

The following list presents the error codes that the getNumberOfSubscribersInDomain method might return:

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE _DOMAIN_NOT_FOUND

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberThe following sections provide information about the getSubscriber operation:

• Syntax, page 3-22

• Description, page 3-22

• Parameters, page 3-23

• Return Value, page 3-23

• RPC Exception Error Codes, page 3-23

• Example, page 3-23

Syntax

The getSubscriber syntax is as follows:

public Object[] getSubscriber(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriber method retrieves a subscriber record. Each field is formatted as an integer, string, or string array.

3-22Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriber

If the subscriber does not exist in the Cisco Service Control Subscriber Manager database, the operation returns an exception.

Parameters

The only parameter of the getSubscriber method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

An object array with nine elements. Table 3-1 lists the index values and descriptions. No array element has a NULL value.

RPC Exception Error Codes

The following list presents error codes that the getSubscriber method method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

The following example code retrieves the subscriber record of alpha:

Object[] subRecord = getSubscriber("alpha"); 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];

Table 3-1 Indexes and Descriptions

Index Value Description

Index 0 Subscriber name (java.lang.String)

Index 1 Array of mappings (java.lang.String[])

Index 2 Array of mapping types (short[])

Index 3 Domain name (java.lang.String)

Index 4 Array of property names (java.lang.String[])

Index 5 Array of property values (java.lang.String[])

Index 6 Array of custom property names (java.lang.String[])

Index 7 Array of custom property values (java.lang.String[])

Index 8 Autologout time, in seconds from the present time, or -1 if not set (long[])

3-23Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriber

String[] customPropertyName = (String[])subRecord[6]; String[] customPropertyValues = (String[])subRecord[7]; long[] autoLogoutTime = (long[])subRecord[8];

3-24Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API subscriberExists

subscriberExistsThe following sections provide information about the subscriberExists operation:

• Syntax, page 3-25

• Description, page 3-25

• Parameters, page 3-25

• Return Value, page 3-25

• RPC Exception Error Codes, page 3-25

Syntax

The subscriberExists syntax is as follows:

public boolean subscriberExists(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The subscriberExists method verifies that a subscriber exists in the Cisco Service Control Subscriber Manager database.

Parameters

The only parameter of the subscriberExists method is as follows:

subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber was found in the Cisco Service Control Subscriber Manager database.

• FALSE—If the subscriber was not found.

RPC Exception Error Codes

None.

subscriberLoggedInThe following sections provide information about the subscriberLoggedIn operation:

• Syntax, page 3-26

• Description, page 3-26

• Parameters, page 3-26

• Return Value, page 3-26

• RPC Exception Error Codes, page 3-26

3-25Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberNameByMapping

Syntax

The subscriberLoggedIn syntax is as follows:

public boolean subscriberLoggedIn(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The subscriberLoggedIn method checks whether a subscriber that already exists in the Cisco Service Control Subscriber Manager database is logged in, that is, if the subscriber also exists in a Cisco SCE database.

When the Cisco Service Control Subscriber Manager 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 Cisco Service Control Subscriber Manager database, an exception is generated.

Parameters

The only parameter of the subscriberLoggedIn method is as follows:

subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber is logged in.

• FALSE—If the subscriber is not logged in.

RPC Exception Error Codes

The following list presents error codes that the subscriberLoggedIn method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNameByMappingThe following sections provide information about the getSubscriberNameByMapping operation:

• Syntax, page 3-27

• Description, page 3-27

• Parameters, page 3-27

• Return Value, page 3-27

• RPC Exception Error Codes, page 3-27

3-26Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberNameByMapping

Syntax

The getSubscriberNameByMapping syntax is as follows:

public String getSubscriberNameByMapping(String mapping, short mappingType, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNameByMapping method finds a subscriber name according to a mapping and a domain.

Parameters

The parameters of the getSubscriberNameByMapping method are as follows:

• mapping—See the description of mappings in the “Network ID Mappings” section on page 2-6.

• mappingType—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—Name of the domain to which the subscriber belongs. The operation fails if either of the following conditions exists:

– 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 was found.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNameByMapping 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 Appendix A, “List of Error Codes”.

3-27Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberNames (all)

getSubscriberNames (all)The following sections provide information about the getSubscriberNames (all) operation:

• Syntax, page 3-28

• Description, page 3-28

• Parameters, page 3-28

• Return Value, page 3-28

• RPC Exception Error Codes, page 3-29

• Example, page 3-29

Syntax

The getSubscriberNames (all) syntax is as follows:

public String[] getSubscriberNames(String lastBulkEnd, int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNames (all) method retrieves a bulk of subscriber names from the Cisco Service Control Subscriber Manager database, starting with lastBulkEnd followed by numOfSubscribers (in alphabetical order).

If lastBulkEnd is NULL, the first subscriber name (alphabetically) that exists in the Cisco Service Control Subscriber Manager database is retrieved.

Note There is no guarantee that the total number of subscribers (in all the bulks) will equal the value returned from getNumOfSubscribers at any time. The values might differ if some subscribers are added or removed when the bulks are being retrieved.

Parameters

The parameters of the getSubscriberNames (all) method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• numOfSubscribers—The limit on the number of subscribers that is returned. If this value is higher than the Cisco Service Control Subscriber Manager limit (1000), the operation uses the Cisco Service Control Subscriber Manager limit.

Note Do not provide a value of more than 500 subscribers.

Return Value

An array of subscriber names, alphabetically ordered.

3-28Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberNames (filter by property)

The getSubscriberNames (all) method returns as many subscribers as are found in the Cisco Service Control Subscriber Manager database, starting at the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Cisco Service Control Subscriber Manager limit (1000).

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNames (all) method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

The following example code returns an array of subscriber names:

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);

getSubscriberNames (filter by property)The following sections provide information about the getSubscriberNames (filter by property) operation:

• Syntax, page 3-29

• Description, page 3-30

• Parameters, page 3-30

• Return Value, page 3-30

• RPC Exception Error Codes, page 3-30

Syntax

The getSubscriberNames (filter by property) method syntax is as follows:

public String[] getSubscriberNames(String lastBulkEnd,String propertyName,String propertyValue,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-29Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberNamesInDomain

Description

The getSubscriberNames (filter by property) method retrieves a bulk of subscriber names from the Cisco Service Control Subscriber Manager database, starting with lastBulkEnd followed by numOfSubscribers (in alphabetical order), and based on the property name and property value.

If lastBulkEnd is NULL, the first subscriber name (alphabetically) that exists in the Cisco Service Control Subscriber Manager database is retrieved.

Note There is no guarantee that the total number of subscribers (in all the bulks) will equal the value returned from getNumOfSubscribers at any time. The values might differ if some subscribers are added or removed when the bulks are being retrieved.

Parameters

The parameters of the getSubscriberNames (filter by property) method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• propertyName—The property name of the string type used to filter subscriber names.

• propertyValue—The property value of the string type used to filter subscriber names.

• numOfSubscribers—The limit on the number of subscribers that is returned. If this value is higher than the Cisco Service Control Subscriber Manager limit (1000), the operation uses the Cisco Service Control Subscriber Manager limit.

Note Do not provide a value of more than 500 subscribers.

Return Value

An array of alphabetically ordered subscriber names that matches the property name and its given value. The method returns as many subscribers as are found in the Cisco Service Control Subscriber Manager database, starting at the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Cisco Service Control Subscriber Manager limit (1000).

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNames (filter by property) method might return:

• ERROR_CODE_DATABASE_EXCEPTION

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesInDomainThe following sections provide information about the getSubscriberNamesInDomain operation:

• Syntax, page 3-31

3-30Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberNamesWithPrefix

• Description, page 3-31

• Parameters, page 3-31

• Return Value, page 3-31

• RPC Exception Error Codes, page 3-31

Syntax

The getSubscriberNamesInDomain syntax is as follows:

public String[] getSubscriberNamesInDomain(String lastBulkEnd, int numOfSubscribers, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesInDomain method retrieves subscribers in the Cisco Service Control Subscriber Manager database that are associated with the specified domain.

The semantics of this operation are the same as that of the getSubscriberNames operation described in the “getSubscriberNames (all)” section on page 3-28.

Parameters

The parameters of the getSubscriberNamesInDomain method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-28.

• numOfSubscribers—See description in the “Parameters” section on page 3-28.

• domain—The name of a subscriber domain that exists in the Cisco Service Control Subscriber Manager domain repository.

Return Value

An alphabetically ordered array of subscriber names that belong to the domain provided.

See the “Return Value” section on page 3-28 (the getSubscriberNames (all) operation).

RPC Exception Error Codes

The following list presents the error codes that the getSubscriberNamesInDomain method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DOMAIN_NOT_FOUND

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesWithPrefixThe following sections provide information about the getSubscriberNamesWithPrefix operation:

3-31Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberNamesWithSuffix

• Syntax, page 3-32

• Description, page 3-32

• Parameters, page 3-32

• Return Value, page 3-32

• RPC Exception Error Codes, page 3-32

Syntax

The getSubscriberNamesWithPrefix syntax is as follows:

public String[] getSubscriberNamesWithPrefix(String lastBulkEnd, int numOfSubscribers, String prefix)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesWithPrefix method retrieves subscribers in the Cisco Service Control Subscriber Manager database whose name begins with a specified prefix.

The semantics of this operation are the same as that of the getSubscriberNames operation described in the “getSubscriberNames (all)” section on page 3-28.

Parameters

The parameters of the getSubscriberNamesWithPrefix method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-28.

• numOfSubscribers—See the description in the “Parameters” section on page 3-28.

• prefix—Case-sensitive string that marks the prefix of the required subscriber names.

Return Value

An alphabetically ordered array of subscriber names that begin with the required prefix.

See, the “Return Value” section on page 3-28.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNamesWithPrefix method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesWithSuffixThe following sections provide information about the getSubscriberNamesWithSuffix operation:

• Syntax, page 3-33

3-32Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getDomains

• Description, page 3-33

• Parameters, page 3-33

• Return Value, page 3-33

• RPC Exception Error Codes, page 3-33

Syntax

The getSubscriberNamesWithSuffix syntax is as follows:

public String[] getSubscriberNamesWithSuffix(String lastBulkEnd, int numOfSubscribers, String suffix)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesWithSuffix method retrieves subscribers in the Cisco Service Control Subscriber Manager database whose names end with the specified suffix.

The semantics of this operation are the same as that of the getSubscriberNames (all) operation described in the “getSubscriberNames (all)” section on page 3-28.

Parameters

The parameters of the getSubscriberNamesWithSuffix method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-28.

• numOfSubscribers—See the description in the “Parameters” section on page 3-28.

• suffix—Case-sensitive string that represents the suffix of the required subscriber names.

Return Value

An alphabetically ordered array of subscriber names that end with the required suffix.

See, the “Return Value” section on page 3-28 (the getSubscriberNames (all) operation).

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNamesWithSuffix method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getDomainsThe following sections provide information about the getDomains operation:

• Syntax, page 3-34

• Description, page 3-34

3-33Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API setPropertiesToDefault

• Return Value, page 3-34

• RPC Exception Error Codes, page 3-34

Syntax

The getDomains syntax is as follows:

public String[] getDomains() throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getDomains method provides the list of current subscriber domains in the Cisco Service Control Subscriber Manager domain repository.

Return Value

A complete list of subscriber domain names in the Cisco Service Control Subscriber Manager.

RPC Exception Error Codes

None.

setPropertiesToDefaultThe following sections provide information about the setPropertiesToDefault operation:

• Syntax, page 3-34

• Description, page 3-34

• Parameters, page 3-35

• Return Value, page 3-35

• RPC Exception Error Codes, page 3-35

Syntax

The setPropertiesToDefault syntax is as follows:

public void setPropertiesToDefault(String subscriberName, String[] properties)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The setPropertiesToDefault method resets the specified application properties of a subscriber. If an application is installed, the relevant application properties are set to the default values of the properties according to the currently loaded application information. If an application is not installed, the operation returns java.lang.IllegalStateException.

3-34Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API removeCustomProperties

Parameters

The parameters of the setPropertiesToDefault method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• properties—See the description of property keys and values in the “Subscriber Properties” section on page 2-9.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the setPropertiesToDefault 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 Appendix A, “List of Error Codes”.

removeCustomPropertiesThe following sections provide information about the removeCustomProperties operation:

• Syntax, page 3-35

• Description, page 3-35

• Parameters, page 3-36

• Return Value, page 3-36

• RPC Exception Error Codes, page 3-36

Syntax

The removeCustomProperties syntax is as follows:

public void removeCustomProperties(String subscriberName, String[] customProperties)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeCustomProperties method resets the specified custom properties of a subscriber.

3-35Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API removeCustomProperties

Parameters

The parameters of the removeCustomProperties method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• CustomProperties—See the description of custom property keys and values in the “Custom Properties” section on page 2-10.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the removeCustomProperties 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 Appendix A, “List of Error Codes”.

3-36Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API Quota Manager Blocking API Methods

Quota Manager Blocking API MethodsThis section lists the methods of the Quota Manager (QM) Blocking API. The description of each method includes the syntax, input parameters, and return values.

• Use the following methods for static or manual subscriber quota configuration:

– addSubscriberQuota, page 3-37

– setSubscriberQuota, page 3-38

– replenishSubscriberQuota, page 3-39

• Use the following methods for basic read-only operations:

– getSubscriberQuotaInformation, page 3-40

– getSubscriberQuotaProfileId, page 3-41

– getBreachedSubscriberNames, page 3-42

– getPenaltySubscriberNames, page 3-43

addSubscriberQuotaThe following sections provide information about the addSubscriberQuota operation:

• Syntax, page 3-37

• Description, page 3-37

• Parameters, page 3-37

• RPC Exception Error Codes, page 3-38

Syntax

The addSubscriberQuota syntax is as follows:

public void addSubscriberQuota(String subscriberName,int bucketId,long bucketSize)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The addSubscriberQuota method adds the quota for the given bucket ID of a subscriber.

Parameters

The parameters of the addSubscriberQuota method are as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

• bucketId—An integer value for the bucket ID to add.

• bucketSize—A long value for the bucket size to add.

3-37Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API setSubscriberQuota

RPC Exception Error Codes

The following list presents error codes that the addSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_CODE_INVALID_BUCKETID

• ERROR_CODE_INVALID_BUCKETSIZE

setSubscriberQuotaThe following sections provide information about the setSubscriberQuota operation:

• Syntax, page 3-38

• Description, page 3-38

• Parameters, page 3-38

• RPC Exception Error Codes, page 3-39

Syntax

The setSubscriberQuota syntax is as follows:

public void setSubscriberQuota(String subscriberName,int bucketId,long bucketSize)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The setSubscriberQuota method updates the quota for the given bucket ID of a subscriber.

Parameters

The parameters of the setSubscriberQuota method are as follows:

• subscriberName—See the description for the subscriber name format in the “Subscriber Name Format” section on page 2-5.

• bucketId—An integer value of the bucket ID to update.

• bucketSize—A long value of the bucket size to update.

3-38Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API replenishSubscriberQuota

RPC Exception Error Codes

The following list presents error codes that the setSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_CODE_INVALID_BUCKETID

• ERROR_CODE_INVALID_BUCKETSIZE

replenishSubscriberQuotaThe following sections provide information about the replenishSubscriberQuota operation:

• Syntax, page 3-39

• Description, page 3-39

• Parameters, page 3-39

• RPC Exception Error Codes, page 3-39

Syntax

The replenishSubscriberQuota syntax is as follows:

public void replenishSubscriberQuota(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The replenishSubscriberQuota method replenishes the quota for the given subscriber.

Parameters

The only parameter of the replenishSubscriberQuota method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

RPC Exception Error Codes

The following list presents error codes that the replenishSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_REPLENISH_FAILED

3-39Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberQuotaInformation

getSubscriberQuotaInformationThe following sections provide information about the getSubscriberQuotaInformation operation:

• Syntax, page 3-40

• Description, page 3-40

• Parameters, page 3-40

• Return Value, page 3-40

• RPC Exception Error Codes, page 3-41

Syntax

The getSubscriberQuotaInformation syntax is as follows:

public Object[] getSubscriberQuotaInformation(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberQuotaInformation method gets a bulk of quota information for a specified subscriber.

Parameters

The only parameter of the getSubscriberQuotaInformation method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

An object array with five elements. Table 3-2 lists the index values and descriptions. None of the array elements have a NULL value.

Table 3-2 Indexes and Descriptions

Index Value Description

Index 0 Package ID (java.lang.String)

Index 1 Last replenish time (java.lang.String)

Index 2 Last SCE that consumed quota (java.lang.String)

3-40Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getSubscriberQuotaProfileId

RPC Exception Error Codes

The following list presents error codes that the getSubscriberQuotaInformation method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

getSubscriberQuotaProfileIdThe following sections provide information about the getSubscriberQuotaProfileId operation:

• Syntax, page 3-41

• Description, page 3-42

• Parameters, page 3-42

• Return Value, page 3-42

• RPC Exception Error Codes, page 3-42

Syntax

The getSubscriberQuotaProfileId syntax is as follows:

public int getSubscriberQuotaProfileId(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Index 3 Aggregation period end (java.lang.String)

Index 4 Quota buckets (java.lang.Object[][])

Bucket 1:

[0][0]=500 (quota size)

[0][1]=500 (remaining quota)

[0][2]=50 (last quota reported by SCE)

[0][3]=time not set (penalty start)

[0][4]=time not set (next penalty monitor)

Bucket 2:

[1][0]=500 (quota size)

[1][1]=500 (remaining quota)

[1][2]=50 (last quota reported by SCE)

[1][3]=time not set (penalty start)

[1][4]=time not set (next penalty monitor)

Table 3-2 Indexes and Descriptions (continued)

Index Value Description

3-41Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getBreachedSubscriberNames

Description

The getSubscriberQuotaProfileId method returns the quota profile ID for the specified subscriber.

Parameters

The only parameter of the getSubscriberQuotaProfileId method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

Quota profile ID.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberQuotaProfileId method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_SUBSCRIBER_NOT_ASSIGNED_PROFILE

getBreachedSubscriberNamesThe following sections provide information about the getBreachedSubscriberNames operation:

• Syntax, page 3-42

• Description, page 3-42

• Parameters, page 3-43

• Return Value, page 3-43

• RPC Exception Error Codes, page 3-43

Syntax

The getBreachedSubscriberNames syntax is as follows:

public String[] getBreachedSubscriberNames(String lastBulkEnd,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getBreachedSubscriberNames method retrieves the breached subscriber names.

3-42Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getPenaltySubscriberNames

Parameters

The parameters of the getBreachedSubscriberNames method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• numOfSubscribers—The limit on the number of subscribers that will be returned. If this value is higher than the Cisco Service Control Subscriber Manager limit (1000), the operation uses the Cisco Service Control Subscriber Manager limit.

Return Value

An array of alphabetically ordered subscriber names that belong to a breached state. This method returns all the subscribers found in the Cisco Service Control Subscriber Manager database starting with the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Cisco Service Control Subscriber Manager limit (1000).

RPC Exception Error Codes

The getBreachedSubscriberNames method might return the ERROR_CODE _DATABASE_EXCEPTION error code.

getPenaltySubscriberNamesThe following sections provide information about the getPenaltySubscriberNames operation:

• Syntax, page 3-43

• Description, page 3-43

• Parameters, page 3-43

• Return Value, page 3-44

• RPC Exception Error Codes, page 3-44

Syntax

The getPenaltySubscriberNames syntax is as follows:

public String[] getPenaltySubscriberNames(String lastBulkEnd,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getPenaltySubscriberNames method retrieves the subscriber names in a penalty state.

Parameters

The parameters of the getPenaltySubscriberNames method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

3-43Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API getPenaltySubscriberNames

• numOfSubscribers—The limit on the number of subscribers that will be returned. If this value is higher than the Cisco Service Control Subscriber Manager limit (1000), the operation uses the Cisco Service Control Subscriber Manager limit.

Return Value

An array of alphabetically ordered subscriber names that belong to a penalty state. This method returns all the subscribers found in the Cisco Service Control Subscriber Manager database starting with the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Cisco Service Control Subscriber Manager limit (1000).

RPC Exception Error Codes

The getPenaltySubscriberNames method might return the ERROR_CODE _DATABASE_EXCEPTION error code.

3-44Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API Blocking API Code Examples

Blocking API Code ExamplesThis section includes the following code examples:

• Getting Number of Subscribers, page 3-45

• Adding a Subscriber, Printing Information, and Removing a Subscriber, page 3-46

• Getting Subscriber Quota Information, page 3-47

Getting Number of Subscribers The following example prints to stdout the total number of subscribers in the Cisco Service Control Subscriber Manager 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(); } }}

3-45Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API Adding a Subscriber, Printing Information, and Removing a Subscriber

Adding a Subscriber, Printing Information, and Removing a Subscriber The following program adds a subscriber to the subscriber database. It then gets its information and prints it to stdout. Finally, the program 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); } }}

3-46Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API Getting Subscriber Quota Information

Getting Subscriber Quota InformationThe following example gets subscriber quota information, sets subscriber quota, and lists subscribers in the breached state:

package blocking;

import com.pcube.management.api.QuotaManagerApi;public class PrintQuotaInfo {

/** * @param args * @throws Exception */

public static void main(String[] args) throws Exception {QuotaManagerApi qmapi = new QuotaManagerApi();checkArguments(args);String smIP=args[0];//initiation

try{

qmapi .setReplyTimeout(300000); //set timeout for 5 minutesqmapi .connect(smIP); // connect to the SM

//operations//getSubscriberQuotaInformationObject []subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]);

for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //getSubscriberQuotaProfileId int profileID = qmapi.getSubscriberQuotaProfileId(args[1]);

System.out.println(profileID); //addSubscriberQuota qmapi.addSubscriberQuota(args[1], 1,300); subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]); for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //setSubscriberQuota qmapi.setSubscriberQuota(args[1], 1,300); subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]); for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //getBreachedSubscriberNames String []breachSubsNames=qmapi.getBreachedSubscriberNames(null, 10); for(int i=0;i<breachSubsNames.length;i++){ System.out.println(breachSubsNames[i]); }

}finally{//finaliztionqmapi.disconnect();

}}static void checkArguments(String[] args) throws Exception{

if (args.length != 2) {System.err.println("usage: java PrintQuotaInfo <SM-address> <subscriber-name> ");System.exit(1);}

}}

3-47Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 3 Blocking API Getting Subscriber Quota Information

3-48Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Cisco Service ControOL-26795-02

C H A P T E R 4

Nonblocking API

Revised: December 21, 2012, OL-26795-02

IntroductionThis chapter introduces features unique to the Nonblocking API. It presents all Nonblocking API methods and provides code examples for each method.

This chapter consists of the following sections:

• Reliability Support, page 4-2

• Autoreconnect Support, page 4-3

• Multithreading Support, page 4-3

• ResultHandler Interface, page 4-4

• Nonblocking API Construction, page 4-6

• Nonblocking API Initialization, page 4-8

• Nonblocking API Methods, page 4-9

• Nonblocking API Code Examples, page 4-12

4-1l Subscriber Manager Java API Programmer Guide

Chapter 4 Nonblocking API Reliability Support

Reliability SupportThe Nonblocking API can work in two different modes—reliable and nonreliable. When the mode is not specified, the default is reliable mode.

• Reliable Mode, page 4-2

• Nonreliable Mode, page 4-2

Reliable ModeIn reliable mode, the API ensures that no requests to the Cisco Service Control Subscriber Manager are lost. The API maintains an internal storage for all API requests that are sent to the Cisco Service Control Subscriber Manager. After a reply from the Cisco Service Control Subscriber Manager is received, the request is considered committed and the API can remove the request from its internal storage. If the connection between the API and the Cisco Service Control Subscriber Manager fails, the API accumulates all requests in its internal storage until the connection to the Cisco Service Control Subscriber Manager is established. On reconnection, the API resends all noncommitted and committed requests to the Cisco Service Control Subscriber Manager, so that no requests are lost.

Note In reliable mode, the order of resending requests is guaranteed. The API resends the requests in the order in which they were called.

Nonreliable ModeIn nonreliable mode, the API does not ensure that requests sent to the Cisco Service Control Subscriber Manager are executed. In addition, all requests that are sent by the API when the connection to the Cisco Service Control Subscriber Manager is down are lost unless an external reliability mechanism is implemented.

4-2Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Autoreconnect Support

Autoreconnect SupportThe Nonblocking API supports autoreconnection to the Cisco Service Control Subscriber Manager to address connection failures. When this option is activated, the API can determine when the connection to the Cisco Service Control Subscriber Manager is lost. When the connection is lost, the API activates a reconnection task that tries to reconnect to the Cisco Service Control Subscriber Manager until it is successful.

Note The autoreconnect support option can be activated in both reliability modes.

Multithreading SupportThe Nonblocking API supports an unlimited number of threads calling its methods simultaneously.

Note In a multithreaded scenario for the Nonblocking API, the order of invocation is guaranteed. The API performs operations in the same order in which they were called.

4-3Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API ResultHandler Interface

ResultHandler InterfaceThe Nonblocking API enables you to set a result handler. A result handler is an interface with two methods, handleSuccess and handleError, as represented in the following code:

public interface ResultHandler { /** * handle a successful result */ public void handleSuccess(long handle, Object result);

/** * handle a failure result */ public void handleError(long handle, Object result);}

You should implement this interface if you want to be informed about the success or error results of operations performed through the API.

Note This is the only interface for retrieving results. Results cannot be returned immediately after the API method has returned to the caller.

Note To receive operation results, set the result handler of the API before calling API methods for which you want to receive results. Set the result handler after the API is connected (as in the “ResultHandler Interface Example” section on page 4-4).

Both handleSuccess and handleError methods accept two parameters:

• Handle—Each API operation return-value is a handle of type long. This handle enables correlation between operation calls and their results. When a handle operation is called with a handle of value X, the result will match the operation that returned the same handle value (X) to the caller.

• Result—Actual result of the operation. Some operations may return a result of NULL.

ResultHandler Interface ExampleThe following example is a simple implementation of a result handler that prints a message to stdout (when the result is successful) or to stderr (when the result is a failure). This main method initiates the API and assigns a result handler.

For correct operation of the result handler, follow the code sequence presented in this example.

4-4Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API ResultHandler Interface Example

Note This example does not demonstrate the use of callback handles.

import com.pcube.management.framework.rpc.ResultHandler;import com.pcube.management.api.SMNonBlockingApi;

public class ResultHandlerExample implements ResultHandler{

public void handleSuccess(long handle, Object result) { System.out.println("success: handle="+handle+", result="+result); }

public void handleError(long handle, Object result) { System.err.println("error: handle="+handle+", result="+result); }

public static void main (String args[]) throws Exception{ if (args.length != 1) { System.err.println("usage: ResultHandlerExample <sm-ip>"); System.exit(1); }

//note the order of operations! SMNonBlockingApi nbapi = new SMNonBlockingApi(); nbapi.connect(args[0]); nbapi.setResultHandler(new ResultHandlerExample()); nbapi.login(...); }}

4-5Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Nonblocking API Construction

Nonblocking API ConstructionIn addition to the constructors described in the “API Construction” section on page 2-3, the Nonblocking API provides constructors that enable you to set the reconnect period and the reliability mode.

Nonblocking API SyntaxThe syntax for the additional Nonblocking API constructors is as follows:

public SMNonBlockingApi(long autoReconnectInterval)public SMNonBlockingApi(boolean reliable, long autoReconnectInterval)public SMNonBlockingApi(String legName, long autoReconnectInterval)public SMNonBlockingApi(String legName, boolean reliable, long autoReconnectInterval)

Nonblocking API ArgumentsThe following list describes the constructor arguments for the additional Nonblocking API constructors:

• autoReconnectInterval—Defines the interval (in milliseconds) between attempts to reconnect, as follows:

– If the value is 0 or less, the reconnection task is not activated (no autoreconnect is attempted).

– If the value is greater than 0 and if there is a connection failure, the reconnection task is activated every autoReconnectInterval milliseconds.

Default value is –1 (no autoreconnect is attempted).

Note To enable the autoreconnect support, the connect method of the API must be activated at least once. For more information, see the “Nonblocking API Code Examples” section on page 4-12.

• reliable—An argument that defines whether the API should work in reliable mode, as follows:

– TRUE—The API works in reliable mode.

– FALSE—The API works in nonreliable mode.

Default value is TRUE (the API works in reliable mode).

• legName—The name of the LEG, as described in the “API Construction” section on page 2-3.

Nonblocking API ExamplesThe following example constructs a reliable API with an autoreconnection interval of 10 seconds:

SMNonBlockingAPI nbapi = SMNonBlockingAPI(10000); nbapi.connect(<SM IP address>);

4-6Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Nonblocking API Examples

The following example constructs a reliable API without autoreconnection support:

// API construction SMNonBlockingAPI nbapi = SMNonBlockingAPI(); // Connect to the API nbapi.connect(<SM IP address>);

The following example constructs a nonreliable API with autoreconnection support:

// API construction SMNonBlockingAPI nbapi = SMNonBlockingAPI(false,10000); // Initial connection - to enable the reconnect task nbapi.connect(<SM IP address>);

4-7Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Nonblocking API Initialization

Nonblocking API InitializationThe Nonblocking API enables you to initialize certain internal properties to customize the API. This initialization is performed by using the API init method.

Note For the settings to take effect, the init method must be called before the connect method.

You can set the following properties:

• Output queue size—The internal buffer size that limits the maximum number of requests that can be accumulated by the API until they are sent to the Cisco Service Control Subscriber Manager. The default is 1024.

• Operation timeout—The desired timeout (in milliseconds) on a nonresponding proprietary remote procedure call (PRPC) protocol connection. The default is 45 seconds.

Nonblocking API Initialization SyntaxThe syntax for the Nonblocking API init method is as follows:

public void init(Properties properties)

Nonblocking API Initialization ParametersThe Nonblocking API init method has the following parameters:

• properties (java.util.Properties)—Enables setting the following properties described previously:

– To set the output queue size, use prpc.client.output.machinemode.recordnum.

– To set the operation timeout, use prpc.client.operation.timeout.

Nonblocking API Initialization ExampleThe following Nonblocking API code illustrates how to customize properties during initialization. Note that the init method is called before the connect method.

// API construction SMNonBlockingAPI nbapi = SMNonBlockingAPI(10000); // API initialization java.util.Properties p = new java.util.Properties(); p.setProperty("prpc.client.output.machinemode.recordnum", 2048); p.setProperty("prpc.client.operation.timeout", 60000);// 1 minute nbapi.init(p); // initial connect to the API to enable the reconnect task nbapi.connect(<SM API address>);

4-8Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Nonblocking API Methods

Nonblocking API MethodsThis section describes the methods of the Nonblocking API.

All methods return a handle of type long that can be used to correlate operation calls and their results. See the “ResultHandler Interface” section on page 4-4.

The operation results passed to the result handler are similar to the return values described in the same method in the Chapter 3, “Blocking API”, except for the following:

• Basic types are converted to their Java class representation. For example, int is translated to java.lang.Integer.

• Return values of Void are translated to NULL.

Note An error is passed to the result handler only if the matching operation in the Blocking API generates an exception with the same arguments that correspond to the state of the Cisco Service Control Subscriber Manager database at the time of the call.

All methods will generate java.lang.IllegalStateException if called before a connection with the Cisco Service Control Subscriber Manager is established.

This section describes the following methods:

• login, page 4-9

• logoutByName, page 4-10

• logoutByNameFromDomain, page 4-10

• logoutByMapping, page 4-10

• loginCable, page 4-10

• logoutCable, page 4-11

loginThis section provides the syntax for the login operation.

Syntax

The login syntax is as follows:

public long login(String subscriberName, String[] mappings, short[] mappingTypes, String[] propertyKeys, String[] propertyValues, String domain, boolean isMappingAdditive, int autoLogoutTime)

The operation functionality is the same as the matching Blocking API operation. See the “login” section on page 3-5 for more information.

4-9Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API logoutByName

logoutByNameThis section provides the syntax for the logoutByName operation.

Syntax

The logoutByName syntax is as follows:

public long logoutByName(String subscriberName, String[] mappings, short[] mappingTypes)

The operation functionality is the same as the matching Blocking API operation. See the “logoutByName” section on page 3-8 for more information.

logoutByNameFromDomainThis section provides the syntax for the logoutByNameFromDomain operation.

Syntax

The logoutByNameFromDomain syntax is as follows:

public long logoutByNameFromDomain(String subscriberName, String[] mappings, short[] mappingTypes, String domain)

The operation functionality is the same as the matching Blocking API operation. See the “logoutByNameFromDomain” section on page 3-10 for more information.

logoutByMappingThis section provides the syntax for logoutByMapping operation.

Syntax

The logoutByMapping syntax is as follows:

public long logoutByMapping(String mapping, short mappingType, String domain)

The operation functionality is the same as the matching Blocking API operation. See the “logoutByMapping” section on page 3-11 for more information.

loginCableThis section provides the syntax for the loginCable operation.

4-10Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API logoutCable

Syntax

The loginCable syntax is as follows:

public long loginCable(String CPE, String CM, String IP, int lease, String domain, String[] propertyKeys, String[] propertyValues)

The operation functionality is the same as the matching Blocking API operation. See the “loginCable” section on page 3-13 for more information.

logoutCableThis section provides the syntax for the logoutCable operation.

Syntax

The logoutCable syntax is as follows:

public long logoutCable(String CPE, String CM, String IP, String domain)

The operation functionality is the same as the matching Blocking API operation. See the “logoutCable” section on page 3-16 for more information.

4-11Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Nonblocking API Code Examples

Nonblocking API Code ExamplesThis section presents example code for logging in and logging out subscribers.

Login and LogoutThe following example logs in a predefined number of subscribers to the Cisco Service Control Subscriber Manager and then logs them out. Note the implementation of a disconnect listener and a result handler.

package nonblocking;

import com.pcube.management.framework.rpc.DisconnectListener;import com.pcube.management.framework.rpc.ResultHandler;import com.pcube.management.api.SMNonBlockingApi;import com.pcube.management.api.SMApiConstants;

class LoginLogoutDisconnectListener implements DisconnectListener { public void connectionIsDown() { System.err.println("disconnect listener:: connection is down"); }}

class LoginLogoutResultHandler implements ResultHandler { int count = 0; //prints a success result every 100 results public synchronized void handleSuccess(long handle, Object result) { Object tmp = null; if (++count%100 == 0) { tmp = result instanceof Object[] ? ((Object[])result)[0] : result; System.out.println("\tresult "+count+":\t"+tmp); } }

//prints every error that occurs public synchronized void handleError(long handle, Object result) { System.err.println("\terror: "+count+":\t"+ result); ++count; } //waits for result number 'last result' to arrive public synchronized void waitForLastResult(int lastResult) { while (count<lastResult) { try { wait(100); } catch (InterruptedException ie) { ie.printStackTrace(); } } }}

public class LoginLogout { public static void main (String args[]) throws Exception{ //check arguments checkArguments(args); int numSubscribersToLogin = Integer.parseInt(args[2]);

//instantiation

4-12Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Login and Logout

SMNonBlockingApi nbapi = new SMNonBlockingApi(); try { //initation nbapi.setDisconnectListener( new LoginLogoutDisconnectListener()); nbapi.connect(args[0]); LoginLogoutResultHandler resultHandler = new LoginLogoutResultHandler(); nbapi.setResultHandler(resultHandler); //login System.out.println("login of "+numSubscribersToLogin +" subscribers"); for (int i=0; i<numSubscribersToLogin; i++) { nbapi.login("subscriber"+i, //subscriber name getMappings(i), //a single ip mapping new short[]{ SMApiConstants.MAPPING_TYPE_IP }, null, //no properties null, args[1], //domain false, //mappings are not additive -1); //disable autologout } resultHandler.waitForLastResult(numSubscribersToLogin); //logout System.out.println("logout of "+numSubscribersToLogin +" subscribers"); for (int i=0; i<numSubscribersToLogin; i++) { nbapi.logoutByMapping(getMappings(i)[0], SMApiConstants.MAPPING_TYPE_IP, args[1]); } resultHandler.waitForLastResult(numSubscribersToLogin*2); } finally { nbapi.disconnect(); } } static void checkArguments(String[] args) throws Exception{ if (args.length != 3) { System.err.println("usage: java LoginLogout "+ "<SM-address> <domain> <num-susbcribers>"); System.exit(1); } } //'automatic' mapping generator private static String[] getMappings(int i) { return new String[]{ "10." +((int)i/65536)%256 + "." + ((int)(i/256))%256 + "." + (i%256)}; }}

The following example logs in a predefined number of IPv6 subscribers to the Cisco Service Control Subscriber Manager and then logs them out. Note the implementation of a disconnect listener and a result handler.

package nonblocking;

import com.pcube.management.framework.rpc.DisconnectListener;import com.pcube.management.framework.rpc.ResultHandler;import com.pcube.management.api.SMNonBlockingApi;import com.pcube.management.api.SMApiConstants;class LoginLogoutDisconnectListener implements DisconnectListener {

public void connectionIsDown() {System.err.println("disconnect listener:: connection is down");

}

4-13Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Login and Logout

}class LoginLogoutResultHandler implements ResultHandler {

int count = 0;//prints a success result every 100 resultspublic synchronized void handleSuccess(long handle, Object result) {

Object tmp = null;if (++count%100 == 0) {

tmp = result instanceof Object[] ? ((Object[])result)[0] : result;System.out.println("\tresult "+count+":\t"+tmp);

}}//prints every error that occurspublic synchronized void handleError(long handle, Object result) {

System.err.println("\terror: "+count+":\t"+ result);++count;

}//waits for result number 'last result' to arrivepublic synchronized void waitForLastResult(int lastResult) {

while (count<lastResult) {try {

wait(100);} catch (InterruptedException ie) {

ie.printStackTrace();}

}}

}public class LoginLogout {

public static void main (String args[]) throws Exception{//check argumentscheckArguments(args);int numSubscribersToLogin = Integer.parseInt(args[2]);//instantiationSMNonBlockingApi nbapi = new SMNonBlockingApi();try {

//initationnbapi.setDisconnectListener(

new LoginLogoutDisconnectListener());nbapi.connect(args[0]);LoginLogoutResultHandler resultHandler =

new LoginLogoutResultHandler();nbapi.setResultHandler(resultHandler);//loginSystem.out.println("login of "+numSubscribersToLogin +" subscribers");int subsCount = 0;

outer:for(int j=0x0;j<=0xf;j++){

for(int i=0x0000; i<=0xffff;i++){

nbapi.login("sub"+subsCount,new String[]{"2001:200:"+Integer.toHexString(j)+":"+Integer.toHexString(i)+"::/64"}, new short[]{SMApiConstants.MAPPING_TYPE_IPV6}, new String[]{"upVlinkId"},new String[]{ "85"}, "subscribers", true, -1);

subsCount++;if(subsCount == numSubscribersToLogin)

break outer;}

}

resultHandler.waitForLastResult(numSubscribersToLogin*2);//logout

4-14Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Login and Logout

subsCount = 0;System.out.println("logout of "+numSubscribersToLogin +" subscribers");outer:for(int j=0x0;j<=0xf;j++){

for(int i=0x0000; i<=0xffff;i++){

nbapi.logoutByMapping("2001:200:"+Integer.toHexString(j)+":"+Integer.toHexString(i)+"::/64",

SMApiConstants.MAPPING_TYPE_IPV6,args[1]);

subsCount++;if(subsCount == numSubscribersToLogin)

break outer;

}}resultHandler.waitForLastResult(numSubscribersToLogin*2);

} finally {nbapi.disconnect();

}}static void checkArguments(String[] args) throws Exception{

if (args.length != 3) {System.err.println("usage: java LoginLogout "+

"<SM-address> <domain> <num-susbcribers>");System.exit(1);

}}//'automatic' mapping generatorprivate static String[] getMappings(int i) {

return new String[]{ "10." +((int)i/65536)%256 + "." +((int)(i/256))%256 + "." + (i%256)};

}}

4-15Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Chapter 4 Nonblocking API Login and Logout

4-16Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Cisco Service Control SubsOL-26795-02

A

P P E N D I X A List of Error Codes

Revised: December 21, 2012, OL-26795-02

IntroductionThis appendix provides a list of error codes that are used in the Java API.

List of Error CodesError codes interpret the actual error for which RpcErrorException was returned. Use the getErrorCode method to extract the error code.

The error code enumeration is given in the com.pcube.management.api.SMApiConstants interface. Table A-1 gives a list of the error codes and their descriptions.

Table A-1 List of Error Codes

Error Code Description

ERROR_CODE_ARRAY_ACCESS Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_ATTRIBUTE_NOT_FOUND Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_BAD_SUBSCRIBER_MAPPING A mapping was formatted badly or assigned to the subscriber illegally.

ERROR_CODE_CLASS_CAST Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_CLASS_NOT_FOUND Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_CLIENT_INTERNAL_ERROR Internal error.

ERROR_CODE_CLIENT_OUT_OF_THREADS Internal error.

ERROR_CODE_DATABASE_EXCEPTION Internal Cisco Service Control Subscriber Manager error—database error occurred during the operation.

A-1criber Manager Java API Programmer Guide

Appendix A List of Error Codes List of Error Codes

ERROR_CODE_DOMAIN_NOT_FOUND The domain provided to the operation does not exist in the Cisco Service Control Subscriber Manager domain repository.

ERROR_CODE_ILLEGAL_ARGUMENT One of the arguments provided to the method is illegal.

ERROR_CODE_ILLEGAL_STATE Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME The subscriber name provided has more than 40 characters or has illegal characters.

ERROR_CODE_NOT_A_SUSBCRIBER_DOMAIN The domain provided to the operation exists in the Cisco Service Control Subscriber Manager domain repository but is not a subscriber domain.

ERROR_CODE_NULL_POINTER Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_NUMBER_FORMAT A VLAN mapping string provided to the API does not represent a decimal number.

ERROR_CODE_OBJECT_NOT_FOUND Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_OPERATION_NOT_FOUND Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_OUT_OF_MEMORY Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_RUNTIME Internal Cisco Service Control Subscriber Manager error.

ERROR_CODE_SE_ERROR Internal Cisco Service Control Subscriber Manager error. The Cisco Service Control Subscriber Manager could not perform the operation on the Cisco SCE device.

ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST The subscriber on which the operation is performed does not exist in the Cisco Service Control Subscriber Manager database.

ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION The subscriber exists in the Cisco Service Control Subscriber Manager database but is associated with a domain other than the one specified by the operation.

ERROR_CODE_SUBSCRIBER_MAPPING_CONGESTION The mappings provided for the subscriber by the operation already belong to another subscriber.

ERROR_CODE_SUSBSCRIBER_ALREADY_EXISTS The subscriber on which the operation was performed already exists in the Cisco Service Control Subscriber Manager database.

ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER No quota information for the subscriber exists in the Cisco Service Control Subscriber Manager database.

Table A-1 List of Error Codes (continued)

Error Code Description

A-2Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Appendix A List of Error Codes List of Error Codes

ERROR_CODE_INVALID_BUCKETID Invalid bucket ID.

ERROR_CODE_INVALID_BUCKETSIZE Invalid bucket size.

ERROR_REPLENISH_FAILED Quota replenish failed for the subscriber.

ERROR_CODE_SUBSCRIBER_NOT_ASSIGNED_PROFILE Subscriber is not assigned to any profile.

ERROR_CODE_UNKNOWN Internal Cisco Service Control Subscriber Manager or API error.

Table A-1 List of Error Codes (continued)

Error Code Description

A-3Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Appendix A List of Error Codes List of Error Codes

A-4Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02