Peer Connection
Acquire Endpoint
When confirming the Endpoint configured when you use the SDK, you can first read the section on VPC Service Domain Name in the Developer Guide to understand the Endpoint concept. Baidu AI Cloud currently opens the multi-region (Region) support. Please refer to the part of network product VPC in Region Selection Introduction. The peer connection services are a part of VPC services, and use the VPC service domain name.
Get the Key
To use Baidu Cloud products, you need to have a Baidu Cloud account and a valid AK (Access Key ID) and SK (Secret Access Key) for signature verification. You can obtain and understand your AK/SK information through the following steps:
1.[Register Baidu Cloud Account](https://login.bce.baidu.com/reg.html? tpl=bceplat&from=portal) 2.[Create AK/SK](https://console.bce.baidu.com/iam/? _=1513940574695#/iam/accesslist)
PeerConnClient
The PeerConnClient encapsulates the API of peer connection services, and simplifies the interaction between developers and peer connection services. The users can call the methods in PeerConnClient to configure the peer connection.
New PeerConnClient
When creating PeerConnClient, you need to first use Endpoint, AK and SK to configure the BceClientConfiguration type config instance, and then use the config instance to configure the PeerConnClient. The specific configuration method is as follows:
static final String HOST = "";
static final String AK = "";
static final String SK = "";
PeerConnClientConfiguration config = new PeerConnClientConfiguration();
config.setCredentials(new DefaultBceCredentials(AK, SK));
config.setEndpoint(HOST);
PeerConnClient peerConnClient = new PeerConnClient(config);
Create a Peer Connection
When the peer connection is created, attention should be paid to:
- For the peer connection of the same account, the system will trigger the opposite terminal for automatic acceptance.
- For the cross-account peer connection, the peer connection is available only after being accepted by the acceptor.
- For the peer connections with the same local region and opposite terminal region, the billing parameter only supports the postpaid (the billing parameter should be transmitted, but the bill is 0).
- Only one peer connection exists between any two VPCs.
- The VPCs of the initiator and the acceptor cannot be the same.
- If the local vpc and opposite terminal vpc are both relay vpcs, the peer connection cannot be established.
The createPeerConn function can be used to create the peer connection in the specified VPC, and is defined as below:
public CreatePeerConnResponse createPeerConn(CreatePeerConnRequest request)
For the definitions of CreatePeerConnResponse and CreatePeerConnRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
bandwidthInMbps | int | Yes | the maximum bandwidth of peer connection, in mbps. |
localVpcId | String | Yes | Local VPC ID |
peerVpcId | String | Yes | Opposite terminal VPC ID |
peerRegion | String | Yes | Opposite terminal region |
description | String | No | Description |
localIfName | String | No | Local interface name |
peerAccountId | String | No | Opposite terminal account ID |
peerIfName | String | No | Opposite terminal interface name |
billing | Customized Billing type | Yes | The billing mode supports the purchase by postpayment and monthly repayment. Refer to Billing Description for details. |
For the customized Billing type definition, refer to Billing.java. The region parameter is as follows:
Name | Value |
---|---|
Beijing | bj |
Guangzhou | gz |
Suzhou | su |
Shanghai | fsh |
Hong Kong | hkg |
Baoding | bd |
Du Xiaoman Finance Special Zone | hb-fsg |
Wuhan | fwh |
Singapore | sin |
Du Xiaoman Finance Special Zone II | bjfsg |
Query the Peer Connection List
The listPeerConn function can be used to query the peer connection list, and is defined as below:
public ListPeerConnResponse listPeerConn(ListPeerConnRequest request)
For the definitions of ListPeerConnResponse and ListPeerConnRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
vpcId | String | Yes | ID of peer connection VPC |
marker | String | No | Starting location of query for batch acquisition of lists |
maxKeys | int | No | Maximum number contained in each page, generally not exceeding 1000. The default value is 1000. |
Query the Peer Connection Details
The getPeerConn function can be used to query the peer connection details, and is defined as below:
public GetPeerConnResponse getPeerConn(GetPeerConnRequest request)
For the definitions of GetPeerConnResponse and GetPeerConnRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
peerConnId | String | Yes | peer connection ID |
Update the Local Iterface Name and Comments of peer Connection
The modifyPeerConn function can be used to update the peer connection, and is defined as below:
public void modifyPeerConn(ModifyPeerConnRequest request)
For the definition of ModifyPeerConnRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
peerConnId | String | Yes | peer connection ID |
localIfId | String | Yes | Local interface ID |
description | String | No | Description |
localIfName | String | No | Local interface name |
Process the Peer Connection Application
- When the connection request timeout initiated by the initiator is 7 days, the status of the peer connection of the initiator after time-out is "Consultation Failed".
- After the acceptor denies, the status of the peer connection of the initiator is "Consultation Failed".
The accept function can be used to accept the peer connection, and is defined as below:
public void accept(PeerConnIdRequest request)
The reject function can be used to reject the peer connection, and is defined as below:
public void reject(PeerConnIdRequest request)
For the definition of PeerConnIdRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
peerConnId | String | Yes | peer connection ID |
Release the peer Connection
The release function can be used to release the peer connection, and is defined as below:
public void release(PeerConnIdRequest request)
For the definition of PeerConnIdRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
peerConnId | String | Yes | peer connection ID |
Upgrade and Degrade of peer Connection Bandwidth
The modifyBandwith function can be used to release the peer connection, and is defined as below:
public void modifyBandwith(ModifyBandwidthRequest request)
For the definition of ModifyBandwidthRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
peerConnId | String | Yes | peer connection ID |
bandwidthInMbps | int | Yes | the maximum bandwidth of peer connection, in mbps. |
Peer Connection Renewal
- The postpaid peer connection cannot be renewed.
- The cross-account renewal can only be operated by the initiator.
The purchaseReserved function can be used to release the peer connection, and is defined as below:
public void purchaseReserved(PurchaseReservedPeerConnRequest request)
For the definition of PurchaseReservedPeerConnRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
peerConnId | String | Yes | peer connection ID |
billing | Customized Billing type | Yes | For the billion mode, refer to Billing Description for details. |
For the customized Billing type definition, refer to Billing.java.
Open the Synchronous DNS of peer Connection
- The DNS can be enabled only when the status of peer connection is "available".
- The synchronization of DNS cannot be enabled when the DNS status of peer connection is "Synchronizing" or "Synchronization Closed".
The openSyncDns function can be used to release the peer connection, and is defined as below:
public void openSyncDns(SyncDnsRequest request)
For the definition of SyncDnsRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
peerConnId | String | Yes | peer connection ID |
role | String | Yes | "initiator" and "acceptor" |
Close the Synchronous DNS of peer Connection
- The DNS can be closed only when the status of peer connection is "Available".
- The synchronization of DNS cannot be closed when the DNS status of peer connection is "Synchronizing" or "Synchronization Closed".
The close_peerconn_dns_syn function can be used to release the peer connection, and is defined as below:
public void closeSyncDns(SyncDnsRequest request)
For the definition of SyncDnsRequest, refer to peerconn/model/ The parameters are described as follows:
Parameter name | Type | Required or not | Description |
---|---|---|---|
peerConnId | String | Yes | peer connection ID |
role | String | Yes | "initiator" and "acceptor" |