Modifying Global Active Tables Using APIs

In a Global Active table, the schema of the table cannot be changed.

You cannot add new fields or remove existing fields from a Global Active table. Changing the read capacity limit or write capacity limit in a Global Active table applies the changes only to the region where the change is initiated. However, changing the storage capacity or changing the default table level TTL value applies the changes to all the replica regions of the table.

Modifying a Global Active table

Users can use the existing table request (TableRequest()) to update the following in a Global Active table:

  • read-units: Change the value of read-units of a regional table replica
  • write-units: Change the value of write-units of a regional table replica
  • capacity-mode: Change the capacity mode(from on-demand to provisioned or vice-versa) of a regional table replica.
  • table size: change the storage capacity of the table in all the regional replicas.
Changing the table limits( read-units, write-units, and storage capacity) of a regional table replica. The storage capacity is changed in all the regional replicas.
TableLimits limits = new TableLimits(40, 10, 5);
TableRequest treq = new TableRequest().setTableName( "<table_name>" ).setTableLimits(limits);
TableResult tres = handle.tableRequest(treq);
/* wait for completion of the operation */
tres.waitForCompletion(handle, 60000, 1000);
Changing the capacity mode of a regional table replica from provisioned to on-demand capacity:
// Call the constructor to only set storage limit (for on-demand)
TableLimits limits = new TableLimits(10);
TableRequest treq = new TableRequest().setTableName("<table_name>").setTableLimits(limits);
TableResult tres = serviceHandle.tableRequest(treq);
tres.waitForCompletion(serviceHandle, 50000,3000);
You can also add a regional replica of an existing Global Active table using AddReplicaRequest() .
/* add replica ca-toronto-1 */
System.output.println("Adding replica: " + region);
AddReplicaRequest addRepReq = new AddReplicaRequest()
                              .setTableName(tableName)
                              .setReplicaName(region);
res = handle.addReplica(addRepReq);
res.waitForCompletion(handle, 90000, 1000);
System.output.println("Added replica: " + region);
System.output.println("Table:\n" + JsonUtils.prettyPrint(res));
You can drop a regional replica from an existing Global Active table using DropReplicaRequest(). When all regional replicas are dropped, the Global Active table becomes a singleton table.
/* drop replica ca-montreal-1 */
System.output.println("\nDropping replica: " + region);
DropReplicaRequest dropRepReq = new DropReplicaRequest()
                               .setTableName(tableName)
                               .setReplicaName(region);
res = handle.dropReplica(dropRepReq);
res.waitForCompletion(handle, 60000, 500);
System.output.println("Dropped replica: " + region);

Note:

See Dropping replicas of parent-child tables to understand the dependency when dropping a replica of a parent table.