Common BLB Instance
Provide conventional load balancing feature components featuring light weight, simple configuration, and low price to meet the general needs of users for load balancing.
For the meaning of each parameter, please see the official blb documentation Common blb Interface under the api reference
Create Blb Instance
Description:
- Create a LoadBalancer and return the assigned service address and instance ID.
- The payment method is postpaid.
- Real-name authentication is required. If you fail to pass the real-name authentication, you can go to the real-name authentication in the Console at the official website of Baidu AI Cloud .
You can create a BLB instance using the following code:
public CreateBlbResponse createBlb(String name, String desc, String vpcId, String subnetId) {
return createBlb(new CreateBlbRequest().withName(name).withDesc(desc).withVpcId(vpcId).withSubnetId(subnetId));
}
The example is as follows:
blbClient.createBlb("blb_bj","","vpc-jupcnrwxqgvf","sbn-p64udgxpymae")
Modify the blb Instance
Description:
- Update the specified single LoadBalancer configuration information, including the name and description of the LoadBalancer instance.
You can modify the information of the specified blb using the following code:
public void modifyBlbAttributes(String blbId, String name, String desc) {
modifyBlbAttributes(new ModifyBlbAttributesRequest(blbId, name, desc));
}
The example is as follows:
blbClient.modifyBlbAttributes("lb-2f30bc8a","blb_bj","");
Query a List of blb Instance
Description:
- Query all LoadBalancer information under the user account
- Support query by id, name, and address of LoadBalancer. The matching rule supports partial inclusion (regular is not supported)
- Support query by bccId (currently support only single bccId query, and only precise query). The query result is a load balancing instance containing the backend server.
- The returned result is the intersection of multiple query conditions
- If the BLB instance has access to the public network, the return result will carry the public network IP
- The result supports marker paging. The default paging size is 1,000, and can be specified by the maxKeys parameter
You can query the list of BLB instances using the following code, and filtering by the following parameters is supported:
public ListBlbResponse listBlbs(String address, String name, String blbId, String bccId) {
return listBlbs(new ListBlbRequest().withAddress(address).withName(name).withBlbId(blbId).withBccId(bccId));
}
The example is as follows:
blbClient.listBlbs("","","lb-a62da492","");
Delete blb Instance
Description:
- Release the specified LoadBalancer which cannot be retrieved
You can delete the specified blb using the following code:
public void deleteBlb(String blbId) {
deleteBlb(new DeleteBlbRequest(blbId));
}
The example is as follows:
blbClient.deleteBlb("lb-a62da492");
Create a Listener Instance
Description:
- Under the specified LoadBalancer, create a listener based on a certain protocol to listen to a frontend port and forward all requests for that protocol sent to this port to the backend port monitored by the backend server.
You can create a BLB listener instance using the following code:
public void createListener(BlbListenerRequest blbListenerRequest) {
...
}
The example is as follows:
BlbListenerRequest blbListenerRequest = new BlbListenerRequest();
blbListenerRequest.setType("HTTP");
blbListenerRequest.setBlbId("lb-2f30bc8a");
blbListenerRequest.setListenerPort(80);
blbListenerRequest.setBackendPort(80);
blbListenerRequest.setScheduler("RoundRobin");
blbClient.createListener(blbListenerRequest);
Modify Listener Instance
Description:
- Update listener parameters of a protocol under the specified LoadBalancer. All the domains specified in the request parameters will be updated, the unspecified domains remain unchanged, and the listener is specified through the port.
You can modify the BLB listener instance using the following code:
public void modifyListenerAttributes(BlbListenerRequest modifyListenerAttributesRequest) {
...
}
The example is as follows:
BlbListenerRequest blbListenerRequest = new BlbListenerRequest();
blbListenerRequest.setType("HTTP");
blbListenerRequest.setBlbId("lb-2f30bc8a");
blbListenerRequest.setListenerPort(80);
blbListenerRequest.setBackendPort(80);
blbListenerRequest.setScheduler("LeastConnection");
blbClient.modifyListenerAttributes(blbListenerRequest);
Query the List of HttpListener Instance
Description:
- Query information about all HTTP listeners under the specified LoadBalancer
You can query the list of httpListener instances using the following code
public ListListenerResponse<HttpListener> listHttpListener(String blbId) {
return listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.HTTP_LISTENER));
}
The example is as follows:
blbClient.listHttpListener("lb-a62da492");
Query the List of HttpsListener Instance
Description:
- Query information about all HTTPS listeners under the specified LoadBalancer
You can query the list of httpsListener instances using the following code
public ListListenerResponse<HttpsListener> listHttpsListener(String blbId) {
return listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.HTTPS_LISTENER));
}
The example is as follows:
blbClient.listHttpsListener("lb-a62da492");
Query the List of TcpListener Instance
Description:
- Query information about all TCP listeners under the specified LoadBalancer
You can query the list of tcpListener instances using the following code
public ListListenerResponse<TcpListener> listTcpListener(String blbId) {
return listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.TCP_LISTENER));
}
The example is as follows:
blbClient.listTcpListener("lb-a62da492");
Query the List of UdpListener Instance
Description:
- Query information about all UDP listeners under the specified LoadBalancer
You can query the list of udpListener instances using the following code
public ListListenerResponse<UdpListener> listUdpListener(String blbId) {
return listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.UDP_LISTENER));
}
The example is as follows:
blbClient.listUdpListener("lb-a62da492");
Delete Listener Instance
Description:
- Releases the listener under the specified LoadBalancer. The listener is specified by the listening port.
- Support batch release
You can delete the BLB listener instance using the following code:
public void deleteListener(String blbId, List<Integer> portList) {
deleteListener(new DeleteListenerRequest(blbId, portList));
}
The example is as follows:
blbClient.deleteListener("lb-2f30bc8a", Arrays.asList(80));
Add Backend Server
Description:
- Add backend server for specified LoadBalancer (batch add is supported)
You can add a blb backend server using the following code:
public void addBackendServers(String blbId, List<BackendServer> backendServerList) {
addBackendServers(new AddBackendServersRequest(blbId, backendServerList));
}
The example is as follows:
List<BackendServer> backendServerList = new ArrayList<BackendServer>();
BackendServer backendServer = new BackendServer();
backendServer.setInstanceId("i-jVRZWSXN");
backendServerList.add(backendServer);
blbClient.addBackendServers("lb-93421df2", backendServerList);
Modify Backend Server
Description:
- Update the weight of the backend server under the specified LoadBalancer (batch modification is supported).
You can modify the blb backend server using the following code:
public void modifyBackendServerAttributes(String blbId, List<BackendServer> backendServerList) {
modifyBackendServerAttributes(new ModifyBSAttributesRequest(blbId, backendServerList));
}
The example is as follows:
List<BackendServer> backendServerList = new ArrayList<BackendServer>();
BackendServer backendServer = new BackendServer();
backendServer.setInstanceId("i-jVRZWSXN");
backendServer.setWeight(70);
backendServerList.add(backendServer);
blbClient.modifyBackendServerAttributes("lb-93421df2", backendServerList);
Query Backend Server
Description:
- Query the list of backend servers under the specified LoadBalancer
You can query the blb backend server using the following code:
public ListBackendServerResponse listBackendServers(String blbId) {
return listBackendServers(new ListBackendServerRequest(blbId));
}
The example is as follows:
blbClient.listBackendServers("lb-93421df2");
Query Backend Server Status
Description:
- Query the status of the backend server under the specified LoadBalancer
You can query the blb backend server status using the following code:
public ListBackendServerStatusResponse listBackendServerStatus(String blbId, int listenerPort) {
return listBackendServerStatus(new ListBackendServerStatusRequest(blbId, listenerPort));
}
The example is as follows:
blbClient.listBackendServerStatus("lb-93421df2", 80);
Delete Backend Server
Description:
- Release the backend server specified by its identifier under the specified LoadBalancer
- Support batch release
You can delete the blb backend server using the following code:
public void deleteBackendServers(String blbId, List<String> backendServerList) {
deleteBackendServers(new DeleteBSRequest(blbId, backendServerList));
}
The example is as follows:
blbClient.deleteBackendServers("lb-93421df2", Arrays.asList("i-jVRZWSXN"));