Todos os produtos
Search
Central de documentação

Tablestore:Atualizar configurações de tabela global

Última atualização: Jun 30, 2026

Atualize as configurações das tabelas físicas em uma tabela global, como permissões de gravação e definições de alternância entre primária e secundária, com o Tablestore Java SDK.

Notas de uso

Múltiplas réplicas graváveis no modo ativo-passivo causam conflitos de dados. Altere essa configuração apenas durante uma alternância ativo-passivo.

Cenários de atualização

  • Modo ativo-passivo: Durante uma alternância ativo-passivo, configure uma réplica em uma região como gravável ou defina-a como elegível para primária.

  • Modo multiativo: Configure uma réplica em uma região como somente leitura ou gravável.

Pré-requisitos

Inicializar um cliente.

Método

public UpdateGlobalTableResponse updateGlobalTable(UpdateGlobalTableRequest request) throws TableStoreException, ClientException

Parâmetros de UpdateGlobalTableRequest

  • globalTableId (Obrigatório) String: ID da tabela global.

    Nota

    Sem o ID da tabela global, chame a operação DescribeTable para consultar os detalhes de uma réplica de tabela. Se a réplica fizer parte de uma tabela global, a resposta da operação DescribeTable incluirá esse ID.

  • globalTableName (Obrigatório) String: Nome da tabela global. Deve corresponder ao nome da tabela base.

  • phyTable (Obrigatório) GlobalTableTypes.UpdatePhyTable: Informações da tabela física a atualizar. Inclui os seguintes parâmetros:

    Importante

    Para atualizar a configuração, modifique pelo menos uma das propriedades writable ou primaryEligible.

    Nome

    Tipo

    Descrição

    regionId (Obrigatório)

    String

    ID da região onde se localiza a tabela física a modificar.

    instanceName (Obrigatório)

    String

    Nome da instância onde se localiza a tabela física a modificar.

    tableName (Obrigatório)

    String

    Nome da tabela física a modificar.

    writable (Opcional)

    Boolean

    Defina se a configuração permite gravação.

    primaryEligible (Opcional)

    Boolean

    Especifica se a configuração está definida como elegível para primária durante o failover no modo ativo-passivo.

    No modo ativo-passivo, as operações de gravação ficam desabilitadas por padrão para todas as tabelas não primárias. Durante uma alternância ativo-passivo, marque a tabela secundária como elegível para primária.

Exemplo

private static void updateGlobalTableExample(SyncClient client) {
    // Construct the configuration of the physical table to update.
    GlobalTableTypes.UpdatePhyTable phyTable = new GlobalTableTypes.UpdatePhyTable(
                // 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",  
                // The name of the replica table.
                "i-dest-test"
    );
    
    // In active-passive mode during a switchover, modify writable and primaryEligible as needed.
    // In multi-active mode when changing replica readability, modify only writable.
    phyTable.setWritable(true);          // Set this replica to be writable.
    phyTable.setPrimaryEligible(true);   // Allow this replica to be eligible to become the primary table (for active-passive switchover).

    // Construct the request.
    UpdateGlobalTableRequest request = new UpdateGlobalTableRequest(
                // The ID of the global table.
                "gt-ee1b54db-f5d9-43f3-ad36-ec44********",
                // The name of the global table.
                "t-gt-test-1",  
                phyTable
    );
    // Send the request.
    UpdateGlobalTableResponse response = client.updateGlobalTable(request);
    System.out.println("Update succeeded. Request ID: " + response.getRequestId());
}