Introduction to SDK APIs
SDK defines multiple types of class objects. This section describes the API definitions of these class objects.
- SubscribeContext
Table 1 SubscribeContext Function Name
Description
setDomainName(String domainName)
Specifies the username.
The IAM username for creating required subscription tasks.
setUserId(String userId)
Specifies the user ID.
You can obtain the user ID from My Credential on the management console.
setPassword(String password)
Specifies the user password.
The password corresponding to the IAM user or member account.
setIp(String ip)
Specifies the IP address of the subscription instance.
Set this parameter to the IP address located on the Basic Information page of the target subscription task.
- ClusterClient
Table 2 ClusterClient Function Name
Description
void addClusterListener(ClusterListener var1)
Adds downstream listeners. A listener can subscribe to incremental data only after being added to ClusterClient.
The ClusterListener arg0 parameter is an object of the ClusterListener arg0 class.
void start()
Starts the SDK client to subscribe to incremental data.
void stop()
Stop subscribing to incremental data.
- ClusterListener
Table 3 ClusterListener Function Name
Description
void notify(List<ClusterMessage> var1)
Defines the consumption of incremental data. When receiving data, the SDK informs ClusterListner of consuming data using notify. For example, the consumption mode in SDK Template indicates the subscription data displayed on the screen.
The input parameter type of this function is List <ClusterMessage> in which ClusterMessage is the structure object of the subscription data storage. For details, see Table 4.
- ClusterMessage
Each ClusterMessage stores the data records of an RDS transaction, and each record is stored using Record.
- Record
Record indicates each record in the RDS binlog file, such as begin, commit, and update.
Table 5 Record Function Name
Description
String getAttribute(final String key)
Obtains the main attribute values in Record. If the input parameter is an attribute name, the value of this attribute is returned.
Table 6 lists the attribute names and values that can be obtained by invoking this function.
Type getOpt()
Obtains the statement type of a record, including insert, delete, update, replace, ddl, begin, commit, and heartbeat.
String getCheckpoint()
Obtains the checkpoint of the change record in the binlog. The returned value is in the following format: binlog_offset@binlog_fid.
binlog_offset indicates the offset of the change record in the binlog file, and binlog_fid indicates the numeric suffix of the binlog file. For example, if the binlog file name is mysql-bin.00092, the value of binlog_fid is 92.
int getFieldCount()
Obtains the number of Fields in the change record.
List <Field> getFieldList()
The data type of the returned value of this function is List <Field>.
List <Field> contains the definitions of all fields of the change record and the image values before and after the change. For details about the definition of Field, see Table 7.
Table 6 Attribute information key
Description
record_id
Specifies the record ID. The ID number does not ascend during the subscription process.
instance
Specifies the DB instance connection address of the record. The format is ip:port.
source_type
Specifies the DB engine type of the record. The current DB engine is MySQL.
source_category
Specifies the record type. The current value is full_recorded.
timestamp
Specifies the time when the record is written to the binlog. It is also the time when the SQL statement is executed in RDS.
checkpoint
Specifies the binlog file checkpoint of the record. The format is :file_offset@file_name. The parameter file_name, indicate the numeric suffix of the binlog file.
record_type
Specifies the operation type of the record. The values include: insert, update, delete, replace, ddl, begin, commit, and heartbeat.
db
Specifies the database name updated in the record.
table_name
Specifies the table name updated in the record.
record_recording
Specifies the record code.
seqno
Specifies the data point. It is used to specify a data point of a DRS task.
fragno
Specifies a reserved field. In the earlier version, this field is used to determine whether a transaction shard is used. In this version, this field is meaningless.
isLastFrag
Specifies a reserved field. In the earlier version, this field is used to determine whether the record is the last record of a transaction. In this version, this field is meaningless.
- Field
The Field class defines the attributes of each field, such as the code, type, field name, field value, and whether the field is a primary key. Table 7 describes the API of each Field class.
Table 7 Field Function Name
Description
String getEncoding()
Obtains the encoding format of the field value.
String getFieldname()
Obtains the name of this field.
Type getType()
Obtains the data type of the field. For details, see the field type definition.
ByteString getValue()
Obtains the value of this field. The returned type is ByteString. If the value is null, NULL is returned.
Boolean isPrimary()
Checks whether the field is the primary key column of the table. If yes, True is returned. Otherwise, False is returned.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot