Remove replicas from a global table
The Tablestore SDK for Java can remove one or more physical table replicas from a global table without deleting the replica tables or their data.
Prerequisites
Install version 5.17.7 or later of the Tablestore SDK for Java and initialize a client.
Feature description
Call unbindGlobalTable to remove one or more physical table replicas from a global table. The operation removes only the association between each physical table and the global table. It does not delete the physical tables or their data. To delete a physical table, call deleteTable after the removal is complete.
public UnbindGlobalTableResponse unbindGlobalTable(UnbindGlobalTableRequest request) throws TableStoreException, ClientException
unbindGlobalTable is asynchronous. A successful response indicates only that the task has started, and the returned status is RE_CONF. Query the global table information and wait until status becomes ACTIVE to confirm that the replica is removed.
The following example removes a replica in the China (Beijing) region from a global table.
String globalTableId = "gt-01234567-89ab-cdef-0123-456789abcdef";
String globalTableName = "example_table";
UnbindGlobalTableRequest request = new UnbindGlobalTableRequest(
globalTableId, globalTableName);
request.addRemoval(new GlobalTableTypes.Removal(
"cn-beijing", "example-replica-instance"));
UnbindGlobalTableResponse response = client.unbindGlobalTable(request);
System.out.println("Global table ID: " + response.getGlobalTableId());
System.out.println("Global table status: " + response.getStatus());
Parameters
UnbindGlobalTableRequest contains the following parameters.
|
Name |
Type |
Description |
|
globalTableId (required) |
String |
The global table ID. If you did not record the ID, locate the global table by a physical table. For more information, see Query global table information. |
|
globalTableName (required) |
String |
The global table name, which must match the base table name. |
|
removals (required) |
|
The list of replicas to remove. Each element identifies one replica by its region and instance. |
Replica placement
Each element in removals[] is a Removal object that contains the following parameters.
|
Name |
Type |
Description |
|
regionId (required) |
String |
The ID of the region that contains the replica to remove. Example: |
|
instanceName (required) |
String |
The name of the instance that contains the replica to remove. |
Response
UnbindGlobalTableResponse contains the following fields that are specific to the removal operation.
|
Field |
Type |
Description |
|
globalTableId |
String |
Obtain the global table ID by calling |
|
status |
GlobalTableStatus |
Obtain the current status by calling |