This topic describes how to use the Java software development kit (SDK) to remove one or more distribution locations from a global table.
Notes
The detach operation only removes the association between the replica table and the global table. The replica table and its data are retained. You can call the DeleteTable operation to delete the replica table separately.
This operation only initiates a detach request. The detach procedure takes some time to complete. To confirm that the procedure is complete, you can call the Query global table information operation to check the status of the global table. The detach is successful when the status of the global table changes to `active`.
Prerequisite
Method description
public UnbindGlobalTableResponse unbindGlobalTable(UnbindGlobalTableRequest request) throws TableStoreException, ClientExceptionExample
private static void unbindGlobalTableExample(SyncClient client) {
// Construct the request.
UnbindGlobalTableRequest request = new UnbindGlobalTableRequest(
// The global table ID.
"gt-ee1b54db-f5d9-43f3-ad36-ec44********",
// The global table name.
"my-global-table"
);
// Build the list of replicas to remove (Removals).
List<GlobalTableTypes.Removal> removals = new ArrayList<>();
// Example: Plan to remove the replica in the China (Hangzhou) region.
GlobalTableTypes.Removal hangzhouRemoval = new GlobalTableTypes.Removal(
// The ID of the region where the replica is located.
"cn-hangzhou",
// The name of the instance to which the replica belongs.
"instance-replica-hz"
);
// Example: Plan to remove the replica in the China (Shanghai) region.
GlobalTableTypes.Removal shanghaiRemoval = new GlobalTableTypes.Removal(
// The ID of the region where the replica is located.
"cn-shanghai",
// The name of the instance to which the replica belongs.
"instance-replica-sh"
);
removals.add(hangzhouRemoval);
removals.add(shanghaiRemoval);
request.setRemovals(removals);
// Initiate the request.
UnbindGlobalTableResponse response = client.unbindGlobalTable(request);
System.out.println("Unbind start. Request ID: " + response.getRequestId());
}