public class ConflictResolutionPolicy extends JsonSerializable
DocumentCollection collectionSpec = new DocumentCollection();
collectionSpec.id("Multi-master collection");
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy();
collectionSpec.conflictResolutionPolicy(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.id("Multi-master collection");
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy(conflictResolutionSprocName);
collectionSpec.conflictResolutionPolicy(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.id("Multi-master collection");
ConflictResolutionPolicy policy = ConflictResolutionPolicy.createLastWriterWinsPolicy("/path/for/conflict/resolution");
collectionSpec.conflictResolutionPolicy(policy);
DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
.toBlocking().single().getResource();
Constructor and Description |
---|
ConflictResolutionPolicy(String jsonString) |
Modifier and Type | Method and Description |
---|---|
String |
conflictResolutionPath()
Gets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution.
|
String |
conflictResolutionProcedure()
Gets the
StoredProcedure which is used for conflict resolution in the Azure Cosmos DB service. |
static ConflictResolutionPolicy |
createCustomPolicy()
Creates a CUSTOM
ConflictResolutionPolicy without any StoredProcedure . |
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. |
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. |
ConflictResolutionMode |
mode()
Gets the
ConflictResolutionMode in the Azure Cosmos DB service. |
get, getBoolean, getCollection, getDouble, getInt, getList, getLogger, getLong, getMap, getObject, getObjectByPath, getString, has, toJson, toJson, toObject, toString
public ConflictResolutionPolicy(String jsonString)
public static ConflictResolutionPolicy createLastWriterWinsPolicy()
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
Resource.timestamp()
, 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 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.conflictResolutionPath
- The path to check values for last-writer wins conflict resolution.
That path is a rooted path of the property in the document, such as "/name/first".public static ConflictResolutionPolicy createCustomPolicy(String conflictResolutionSprocName)
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.
Resource.id()
conflictResolutionSprocName
- stored procedure 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 mode()
ConflictResolutionMode
in the Azure Cosmos DB service.
By default it is ConflictResolutionMode.LAST_WRITER_WINS
.public String conflictResolutionPath()
Resource.timestamp()
path will be used.
This value should only be set when using ConflictResolutionMode.LAST_WRITER_WINS
public String conflictResolutionProcedure()
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.
ConflictResolutionMode.CUSTOM
Resource.id()
Copyright © 2019. All rights reserved.