public final class ConflictResolutionPolicy extends Object
A container with custom conflict resolution with no user-registered stored procedure.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties("Multi-master container", "Multi-master container partition key");
containerProperties.setConflictResolutionPolicy(ConflictResolutionPolicy.createCustomPolicy());
CosmosAsyncDatabase database = client.createDatabase(databaseProperties).block().getDatabase();
CosmosAsyncContainer container = database.createContainer(containerProperties).block().getContainer();
A container with custom conflict resolution with a user-registered stored procedure.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties("Multi-master container", "Multi-master container partition key");
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy(conflictResolutionSprocName);
containerProperties.setConflictResolutionPolicy(policy);
CosmosAsyncDatabase database = client.createDatabase(databaseProperties).block().getDatabase();
CosmosAsyncContainer container = database.createContainer(containerProperties).block().getContainer();
A container with last writer wins conflict resolution, based on a path in the conflicting items. A container with custom conflict resolution with a user-registered stored procedure.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties("Multi-master container", "Multi-master container partition key");
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createLastWriterWinsPolicy("/path/for/conflict/resolution");
containerProperties.setConflictResolutionPolicy(policy);
CosmosAsyncDatabase database = client.createDatabase(databaseProperties).block().getDatabase();
CosmosAsyncContainer container = database.createContainer(containerProperties).block().getContainer();
Modifier and Type | Method and Description |
---|---|
static ConflictResolutionPolicy |
createCustomPolicy()
Creates a CUSTOM
ConflictResolutionPolicy without any StoredProcedure . |
static ConflictResolutionPolicy |
createCustomPolicy(String conflictResolutionStoredProcFullPath)
Creates a CUSTOM
ConflictResolutionPolicy which uses the specified stored procedure
to perform conflict resolution |
static ConflictResolutionPolicy |
createCustomPolicy(String dbName,
String containerName,
String sprocName)
Creates a CUSTOM
ConflictResolutionPolicy which uses the specified stored procedure
to perform conflict resolution |
static ConflictResolutionPolicy |
createLastWriterWinsPolicy()
Creates a LAST_WRITER_WINS
ConflictResolutionPolicy with "/_ts" as the resolution path. |
static ConflictResolutionPolicy |
createLastWriterWinsPolicy(String conflictResolutionPath)
Creates a LAST_WRITER_WINS
ConflictResolutionPolicy with path as the resolution path. |
String |
getConflictResolutionPath()
Gets the path which is present in each item in the Azure Cosmos DB service for last writer wins
conflict-resolution.
|
String |
getConflictResolutionProcedure()
Gets the
StoredProcedure which is used for conflict resolution in the Azure Cosmos DB service. |
ConflictResolutionMode |
getMode()
Gets the
ConflictResolutionMode in the Azure Cosmos DB service. |
public static ConflictResolutionPolicy createLastWriterWinsPolicy()
ConflictResolutionPolicy
with "/_ts" as the resolution path.
In case of a conflict occurring on an item, the item with the higher integer value in the default path
Resource.getTimestamp()
()}, i.e., "/_ts" will be used.
Resource.getTimestamp()
, i.e., "/_ts" will be used.
public static ConflictResolutionPolicy createLastWriterWinsPolicy(String conflictResolutionPath)
ConflictResolutionPolicy
with path as the resolution path.
The specified path must be present in each item and must be an integer value. In case of a conflict occurring on an item, the item with the higher integer value in the specified path will be picked.
conflictResolutionPath
- The path to check values for last-writer wins conflict resolution.
That path is a rooted path of the property in the item, such as "/name/first".public static ConflictResolutionPolicy createCustomPolicy(String conflictResolutionStoredProcFullPath)
ConflictResolutionPolicy
which uses the specified stored procedure
to perform conflict resolution
This stored procedure may be created after the CosmosContainerProperties
is created and can be changed as
required.
ConflictResolutionPolicy.createCustomPolicy(String, String, String)
Resource.getId()
conflictResolutionStoredProcFullPath
- stored procedure full path to perform conflict resolution.public static ConflictResolutionPolicy createCustomPolicy(String dbName, String containerName, String sprocName)
ConflictResolutionPolicy
which uses the specified stored procedure
to perform conflict resolution
This stored procedure may be created after the CosmosContainerProperties
is created and can be changed as
required.
Resource.getId()
dbName
- database name.containerName
- container name.sprocName
- stored procedure name to perform conflict resolution.public static ConflictResolutionPolicy createCustomPolicy()
ConflictResolutionPolicy
without any StoredProcedure
. User manually
should resolve conflicts.
The conflicts will be registered in the conflicts feed and the user should manually resolve them.
public ConflictResolutionMode getMode()
ConflictResolutionMode
in the Azure Cosmos DB service.
By default it is ConflictResolutionMode.LAST_WRITER_WINS
.public String getConflictResolutionPath()
Resource.getTimestamp()
()} path will be used.
This value should only be set when using ConflictResolutionMode.LAST_WRITER_WINS
public String getConflictResolutionProcedure()
StoredProcedure
which is used for conflict resolution in the Azure Cosmos DB service.
This stored procedure may be created after the CosmosContainerProperties
is created and can be changed as
required.
ConflictResolutionMode.CUSTOM
Resource.getId()
()}Copyright © 2021 Microsoft Corporation. All rights reserved.