diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ConflictResolutionPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ConflictResolutionPolicy.java index d068c8d799d8..108fc2814d44 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ConflictResolutionPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ConflictResolutionPolicy.java @@ -5,7 +5,6 @@ import com.azure.cosmos.implementation.Constants; -import com.azure.cosmos.implementation.DocumentCollection; import com.azure.cosmos.implementation.JsonSerializable; import com.azure.cosmos.implementation.Resource; import com.azure.cosmos.implementation.StoredProcedure; @@ -15,49 +14,52 @@ /** * 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 + * in case writes from different regions result in conflicts on items in the container in the Azure Cosmos DB * service. + * + * Refer to: https://docs.microsoft.com/en-us/azure/cosmos-db/conflict-resolution-policies + * *

- * A collection with custom conflict resolution with no user-registered stored procedure. + * A container with custom conflict resolution with no user-registered stored procedure. *

{@code
- * DocumentCollection collectionSpec = new DocumentCollection();
- * collectionSpec.getId("Multi-master collection");
  *
- * ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy();
- * collectionSpec.getConflictResolutionPolicy(policy);
+ * CosmosContainerProperties containerProperties =
+ *      new CosmosContainerProperties("Multi-master container", "Multi-master container partition key");
+ * containerProperties.setConflictResolutionPolicy(ConflictResolutionPolicy.createCustomPolicy());
  *
- * DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
- *         .toBlocking().single().getResource();
+ * CosmosAsyncDatabase database = client.createDatabase(databaseSettings).block().getDatabase();
+ * CosmosAsyncContainer container = database.createContainer(containerProperties).block().getContainer();
  *
  * }
  * 
*

- * A collection with custom conflict resolution with a user-registered stored procedure. + * A container with custom conflict resolution with a user-registered stored procedure. *

{@code
- * DocumentCollection collectionSpec = new DocumentCollection();
- * collectionSpec.getId("Multi-master collection");
+ *
+ * CosmosContainerProperties containerProperties =
+ *      new CosmosContainerProperties("Multi-master container", "Multi-master container partition key");
  *
  * ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy(conflictResolutionSprocName);
- * collectionSpec.getConflictResolutionPolicy(policy);
+ * containerProperties.setConflictResolutionPolicy(policy);
  *
- * DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
- *         .toBlocking().single().getResource();
+ * CosmosAsyncDatabase database = client.createDatabase(databaseSettings).block().getDatabase();
+ * CosmosAsyncContainer container = database.createContainer(containerProperties).block().getContainer();
  *
  * }
  * 
*

- * 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. + * 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. *

{@code
- * DocumentCollection collectionSpec = new DocumentCollection();
- * collectionSpec.getId("Multi-master collection");
  *
- * ConflictResolutionPolicy policy = ConflictResolutionPolicy.createLastWriterWinsPolicy
- * ("/path/for/conflict/resolution");
- * collectionSpec.getConflictResolutionPolicy(policy);
+ * CosmosContainerProperties containerProperties =
+ *      new CosmosContainerProperties("Multi-master container", "Multi-master container partition key");
+ *
+ * ConflictResolutionPolicy policy = ConflictResolutionPolicy.createLastWriterWinsPolicy("/path/for/conflict/resolution");
+ * containerProperties.setConflictResolutionPolicy(policy);
  *
- * DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
- *         .toBlocking().single().getResource();
+ * CosmosAsyncDatabase database = client.createDatabase(databaseSettings).block().getDatabase();
+ * CosmosAsyncContainer container = database.createContainer(containerProperties).block().getContainer();
  *
  * }
  * 
@@ -69,7 +71,7 @@ public final class ConflictResolutionPolicy { /** * Creates a LAST_WRITER_WINS {@link 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 + * In case of a conflict occurring on an item, the item with the higher integer value in the default path * {@link Resource#getTimestamp()} ()}, i.e., "/_ts" will be used. * {@link Resource#getTimestamp()}, i.e., "/_ts" will be used. * @@ -84,12 +86,12 @@ public static ConflictResolutionPolicy createLastWriterWinsPolicy() { /** * Creates a LAST_WRITER_WINS {@link 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 + * 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. * * @param 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". + * That path is a rooted path of the property in the item, such as "/name/first". * @return ConflictResolutionPolicy. */ public static ConflictResolutionPolicy createLastWriterWinsPolicy(String conflictResolutionPath) { @@ -105,7 +107,7 @@ public static ConflictResolutionPolicy createLastWriterWinsPolicy(String conflic * Creates a CUSTOM {@link ConflictResolutionPolicy} which uses the specified stored procedure * to perform conflict resolution *

- * This stored procedure may be created after the {@link DocumentCollection} is created and can be changed as + * This stored procedure may be created after the {@link CosmosContainerProperties} is created and can be changed as * required. * *