ConflictResolutionPolicy Class
- java.
lang. Object - JsonSerializable
- com.
microsoft. azure. cosmosdb. ConflictResolutionPolicy
- com.
public class ConflictResolutionPolicy extends JsonSerializable
Represents the conflict resolution policy configuration for specifying how to resolve conflicts in case writes from different regions result in conflicts on documents in the collection in the Azure Cosmos DB service.
A collection with custom conflict resolution with no user-registered stored procedure.
DocumentCollection collectionSpec = new DocumentCollection();
collectionSpec.setId("Multi-master collection");
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy();
collectionSpec.setConflictResolutionPolicy(policy);
DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
.toBlocking().single().getResource();
A collection with custom conflict resolution with a user-registered stored procedure.
DocumentCollection collectionSpec = new DocumentCollection();
collectionSpec.setId("Multi-master collection");
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy(conflictResolutionSprocName);
collectionSpec.setConflictResolutionPolicy(policy);
DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
.toBlocking().single().getResource();
A collection with last writer wins conflict resolution, based on a path in the conflicting documents. A collection with custom conflict resolution with a user-registered stored procedure.
DocumentCollection collectionSpec = new DocumentCollection();
collectionSpec.setId("Multi-master collection");
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createLastWriterWinsPolicy("/path/for/conflict/resolution");
collectionSpec.setConflictResolutionPolicy(policy);
DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
.toBlocking().single().getResource();
Constructor Summary
Constructor | Description | |
---|---|---|
ConflictResolutionPolicy(String jsonString) |
Method Summary
Modifier and Type | Method and Description |
---|---|
Conflict |
createCustomPolicy()
Creates a Custom 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. |
Conflict |
createCustomPolicy(String conflictResolutionSprocName)
Creates a Custom ConflictResolutionPolicy which uses the specified stored procedure to perform conflict resolution This stored procedure may be created after the DocumentCollection is created and can be changed as required.
|
Conflict |
createLastWriterWinsPolicy()
Creates a LastWriterWins ConflictResolutionPolicy with "/_ts" as the resolution path. In case of a conflict occurring on a document, the document with the higher integer value in the default path getTimestamp(), i.e., "/_ts" will be used. |
Conflict |
createLastWriterWinsPolicy(String conflictResolutionPath)
Creates a LastWriterWins ConflictResolutionPolicy with path as the resolution path. The specified path must be present in each document and must be an integer value. In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked. |
Conflict |
getConflictResolutionMode()
Gets the ConflictResolutionMode in the Azure Cosmos DB service. By default it is LastWriterWins. |
String |
getConflictResolutionPath()
Gets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution. This path must be present in each document and must be an integer value. In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked. If the path is unspecified, by default the getTimestamp() path will be used. This value should only be set when using LastWriterWins |
String |
getConflictResolutionProcedure()
Gets the StoredProcedure which is used for conflict resolution in the Azure Cosmos DB service. This stored procedure may be created after the DocumentCollection is created and can be changed as required.
|
Inherited Members
Constructor Details
ConflictResolutionPolicy
public ConflictResolutionPolicy(String jsonString)
Parameters:
Method Details
createCustomPolicy
public static ConflictResolutionPolicy createCustomPolicy()
Creates a Custom 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.
Returns:
createCustomPolicy
public static ConflictResolutionPolicy createCustomPolicy(String conflictResolutionSprocName)
Creates a Custom ConflictResolutionPolicy which uses the specified stored procedure to perform conflict resolution
This stored procedure may be created after the DocumentCollection is created and can be changed as required.
<li>
<p>In case the stored procedure fails or throws an exception, the conflict resolution will default to registering conflicts in the conflicts feed </p>
</li>
<li>
<p>The user can provide the stored procedure </p>
</li>
Parameters:
Returns:
createLastWriterWinsPolicy
public static ConflictResolutionPolicy createLastWriterWinsPolicy()
Creates a LastWriterWins ConflictResolutionPolicy with "/_ts" as the resolution path.
In case of a conflict occurring on a document, the document with the higher integer value in the default path getTimestamp(), i.e., "/_ts" will be used.
Returns:
createLastWriterWinsPolicy
public static ConflictResolutionPolicy createLastWriterWinsPolicy(String conflictResolutionPath)
Creates a LastWriterWins ConflictResolutionPolicy with path as the resolution path.
The specified path must be present in each document and must be an integer value. In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked.
Parameters:
Returns:
getConflictResolutionMode
public ConflictResolutionMode getConflictResolutionMode()
Gets the ConflictResolutionMode in the Azure Cosmos DB service. By default it is LastWriterWins.
Returns:
getConflictResolutionPath
public String getConflictResolutionPath()
Gets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution. This path must be present in each document and must be an integer value. In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked. If the path is unspecified, by default the getTimestamp() path will be used.
This value should only be set when using LastWriterWins
Returns:
getConflictResolutionProcedure
public String getConflictResolutionProcedure()
Gets the StoredProcedure which is used for conflict resolution in the Azure Cosmos DB service. This stored procedure may be created after the DocumentCollection is created and can be changed as required.
<li>
<p>This value should only be set when using <xref uid="com.microsoft.azure.cosmosdb.ConflictResolutionMode.Custom" data-throw-if-not-resolved="false" data-raw-source="ConflictResolutionMode#Custom"></xref></p>
</li>
<li>
<p>In case the stored procedure fails or throws an exception, the conflict resolution will default to registering conflicts in the conflicts feed </p>
</li>
<li>
<p>The user can provide the stored procedure </p>
</li>
Returns:
Applies to
Azure SDK for Java