Removes one or more distribution locations from a global table using the Java SDK.
Usage notes
Detaching a distribution location only removes the association between the replica table and the global table. The replica table and its data are retained. To delete the replica table, call the DeleteTable operation separately.
This operation initiates a detach request asynchronously. To confirm the detach is complete, call the Query global table information operation and check the global table status. The detach is complete when the status changes to
active.
Prerequisites
Before you begin, ensure that you have initialized a client.
Method description
public UnbindGlobalTableResponse unbindGlobalTable(UnbindGlobalTableRequest request) throws TableStoreException, ClientException
Example
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<>();
// Remove the replica in the China (Hangzhou) region.
GlobalTableTypes.Removal hangzhouRemoval = new GlobalTableTypes.Removal(
// The region ID where the replica is located.
"cn-hangzhou",
// The instance name to which the replica belongs.
"instance-replica-hz"
);
// Remove the replica in the China (Shanghai) region.
GlobalTableTypes.Removal shanghaiRemoval = new GlobalTableTypes.Removal(
// The region ID where the replica is located.
"cn-shanghai",
// The instance name 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());
}