Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Container throughput default value from SDK #13125

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
public final class Constants {

public static final String DEFAULT_COLLECTION_NAME = "";
public static final String DEFAULT_REQUEST_UNIT = "4000";
public static final boolean DEFAULT_INDEXINGPOLICY_AUTOMATIC = true;
public static final IndexingMode DEFAULT_INDEXINGPOLICY_MODE = IndexingMode.CONSISTENT;
public static final String DEFAULT_REPOSITORY_IMPLEMENT_POSTFIX = "Impl";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.azure.data.cosmos.CosmosClient;
import com.azure.data.cosmos.CosmosContainerProperties;
import com.azure.data.cosmos.CosmosContainerResponse;
import com.azure.data.cosmos.CosmosDatabase;
import com.azure.data.cosmos.PartitionKey;
import com.azure.spring.data.cosmos.common.CosmosdbUtils;
import com.azure.spring.data.cosmos.common.Memoizer;
Expand Down Expand Up @@ -402,9 +403,17 @@ public CosmosContainerProperties createContainerIfNotExists(CosmosEntityInformat
+ information.getPartitionKeyFieldName());
cosmosContainerProperties.defaultTimeToLive(information.getTimeToLive());
cosmosContainerProperties.indexingPolicy(information.getIndexingPolicy());
return cosmosDatabaseResponse
.database()
.createContainerIfNotExists(cosmosContainerProperties, information.getRequestUnit())

CosmosDatabase database = cosmosDatabaseResponse.database();
Mono<CosmosContainerResponse> mono = null;

if (information.getRequestUnit() == null) {
mono = database.createContainerIfNotExists(cosmosContainerProperties);
} else {
mono = database.createContainerIfNotExists(cosmosContainerProperties, information.getRequestUnit());
}

return mono
.onErrorResume(throwable ->
CosmosDBExceptionUtils.exceptionHandler("Failed to create container", throwable))
.doOnNext(cosmosContainerResponse ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.azure.data.cosmos.CosmosClient;
import com.azure.data.cosmos.CosmosContainerProperties;
import com.azure.data.cosmos.CosmosContainerResponse;
import com.azure.data.cosmos.CosmosDatabase;
import com.azure.data.cosmos.PartitionKey;
import com.azure.spring.data.cosmos.common.CosmosdbUtils;
import com.azure.spring.data.cosmos.common.Memoizer;
Expand Down Expand Up @@ -120,9 +121,17 @@ public Mono<CosmosContainerResponse> createContainerIfNotExists(CosmosEntityInfo
"/" + information.getPartitionKeyFieldName());
cosmosContainerProperties.defaultTimeToLive(information.getTimeToLive());
cosmosContainerProperties.indexingPolicy(information.getIndexingPolicy());
return cosmosDatabaseResponse
.database()
.createContainerIfNotExists(cosmosContainerProperties, information.getRequestUnit())

CosmosDatabase database = cosmosDatabaseResponse.database();
Mono<CosmosContainerResponse> mono = null;

if (information.getRequestUnit() == null) {
mono = database.createContainerIfNotExists(cosmosContainerProperties);
} else {
mono = database.createContainerIfNotExists(cosmosContainerProperties, information.getRequestUnit());
}

return mono
.map(cosmosContainerResponse -> {
CosmosdbUtils.fillAndProcessResponseDiagnostics(responseDiagnosticsProcessor,
cosmosContainerResponse, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

/**
* To set request unit
* @return default as 4000
* @return default as ""
*/
String ru() default Constants.DEFAULT_REQUEST_UNIT;
String ru() default "";

/**
* To set the ttl of container level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private Field getPartitionKeyField(Class<?> domainType) {
}

private Integer getRequestUnit(Class<?> domainType) {
Integer ru = Integer.parseInt(Constants.DEFAULT_REQUEST_UNIT);
Integer ru = null;
final Document annotation = domainType.getAnnotation(Document.class);

if (annotation != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public final class TestConstants {

public static final int DEFAULT_TIME_TO_LIVE = -1;
public static final String DEFAULT_COLLECTION_NAME = "Person";
public static final int DEFAULT_REQUEST_UNIT = 4000;
public static final boolean DEFAULT_INDEXINGPOLICY_AUTOMATIC = true;
public static final IndexingMode DEFAULT_INDEXINGPOLICY_MODE = IndexingMode.CONSISTENT;
public static final String[] DEFAULT_EXCLUDEDPATHS = {};
Expand All @@ -31,7 +30,6 @@ public final class TestConstants {
};

public static final String ROLE_COLLECTION_NAME = "RoleCollectionName";
public static final int REQUEST_UNIT = 4000;
public static final int TIME_TO_LIVE = 5;
public static final boolean INDEXINGPOLICY_AUTOMATIC = false;
public static final IndexingMode INDEXINGPOLICY_MODE = IndexingMode.LAZY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public void testDefaultIndexingPolicyAnnotation() {
// ContainerName, RequestUnit, Automatic and IndexingMode
Assert.isTrue(personInfo.getContainerName().equals(NoDBAnnotationPerson.class.getSimpleName()),
"should be default collection name");
Assert.isTrue(personInfo.getRequestUnit() == TestConstants.DEFAULT_REQUEST_UNIT,
"should be default request unit");
Assert.isTrue(policy.automatic() == TestConstants.DEFAULT_INDEXINGPOLICY_AUTOMATIC,
"should be default indexing policy automatic");
Assert.isTrue(policy.indexingMode() == TestConstants.DEFAULT_INDEXINGPOLICY_MODE,
Expand Down Expand Up @@ -69,8 +67,6 @@ public void testIndexingPolicyAnnotation() {

Assert.isTrue(roleInfo.getContainerName().equals(TestConstants.ROLE_COLLECTION_NAME),
"should be Role(class) collection name");
Assert.isTrue(roleInfo.getRequestUnit() == TestConstants.REQUEST_UNIT,
"should be Role(class) request unit");
Assert.isTrue(policy.automatic() == TestConstants.INDEXINGPOLICY_AUTOMATIC,
"should be Role(class) indexing policy automatic");
Assert.isTrue(policy.indexingMode() == TestConstants.INDEXINGPOLICY_MODE,
Expand Down