Add one or more replicas (distribution locations) to an existing global table using the Tablestore Java SDK.
Notes
After the bind operation succeeds, the system asynchronously binds new replicas and synchronizes data. You can call `DescribeGlobalTable` to view the current status of the global table. When the returned status is `active`, the new global table replica is successfully bound.
Prerequisites
Method
public BindGlobalTableResponse bindGlobalTable(BindGlobalTableRequest request) throws TableStoreException, ClientException
Example
private static void bindGlobalTableExample(SyncClient client) {
// Construct the request
BindGlobalTableRequest request = new BindGlobalTableRequest(
// Global table ID
"gt-ee1b54db-f5d9-43f3-ad36-ec44********",
// Global table name
"my-global-table"
);
// Construct the Placement list (at least one replica configuration)
List<GlobalTableTypes.Placement> placements = new ArrayList<>();
// Example: Add a replica in the China (Hangzhou) region
GlobalTableTypes.Placement hangzhouReplica = new GlobalTableTypes.Placement(
// Region ID of the replica
"cn-hangzhou",
// Instance name of the replica
"instance-replica-hz",
// In active-passive mode, the replica table is not writable (default value is false)
// In multi-active mode, the replica table can be set to read/write (true) or read-only (false)
false
);
// Example: Add a replica in the China (Shanghai) region
GlobalTableTypes.Placement shanghaiReplica = new GlobalTableTypes.Placement(
// Region ID of the replica
"cn-shanghai",
// Instance name of the replica
"instance-replica-sh",
// In active-passive mode, the replica table is not writable (default value is false)
// In multi-active mode, the replica table can be set to read/write (true) or read-only (false)
true
);
placements.add(hangzhouReplica);
placements.add(shanghaiReplica);
request.setPlacements(placements);
// Send the request
BindGlobalTableResponse response = client.bindGlobalTable(request);
System.out.println("Bind succeeded. Request ID: " + response.getRequestId());
}