Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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 @@ -167,11 +167,11 @@ DocumentCollection getCollectionDefinitionWithRangeRangeIndex() {
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<>();
Index stringIndex = Index.Range(DataType.STRING);
Index stringIndex = Index.range(DataType.STRING);
BridgeInternal.setProperty(stringIndex, "precision", -1);
indexes.add(stringIndex);

Index numberIndex = Index.Range(DataType.NUMBER);
Index numberIndex = Index.range(DataType.NUMBER);
BridgeInternal.setProperty(numberIndex, "getPrecision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ DocumentCollection getCollectionDefinitionWithRangeRangeIndex() {
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<>();
Index stringIndex = Index.Range(DataType.STRING);
Index stringIndex = Index.range(DataType.STRING);
BridgeInternal.setProperty(stringIndex, "precision", -1);
indexes.add(stringIndex);

Index numberIndex = Index.Range(DataType.NUMBER);
Index numberIndex = Index.range(DataType.NUMBER);
BridgeInternal.setProperty(numberIndex, "precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.cosmos.CosmosAsyncDatabase;
import com.azure.cosmos.CosmosAsyncItem;
import com.azure.cosmos.CosmosAsyncItemResponse;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.cosmos.CosmosClientException;
import com.azure.cosmos.CosmosContainerProperties;
import com.azure.cosmos.FeedOptions;
Expand All @@ -30,7 +31,7 @@ public static void main(String[] args) {

private void start() {
// Get client
client = CosmosAsyncClient.builder()
client = CosmosAsyncClient.cosmosClientBuilder()
.setEndpoint(AccountSettings.HOST)
.setKey(AccountSettings.MASTER_KEY)
.buildAsyncClient();
Expand All @@ -53,12 +54,12 @@ private void start() {
//Wait for completion
try {
itemResponseMono.doOnError(throwable -> log("CREATE item 1", throwable))
.mergeWith(itemResponseMono1)
.doOnError(throwable -> log("CREATE item 2 ", throwable))
.doOnComplete(() -> log("Items created"))
.publishOn(Schedulers.elastic())
.blockLast();
} catch (RuntimeException e) {
.mergeWith(itemResponseMono1)
.doOnError(throwable -> log("CREATE item 2 ", throwable))
.doOnComplete(() -> log("Items created"))
.publishOn(Schedulers.elastic())
.blockLast();
}catch (RuntimeException e){
log("Couldn't create items due to above exceptions");
}

Expand All @@ -74,16 +75,16 @@ private void start() {
}

private void createAndReplaceItem() {
TestObject replaceObject = new TestObject("item_new_id_3", "test3", "test description3", "JP");
TestObject replaceObject = new TestObject("item_new_id_3", "test3", "test description3", "JP");
CosmosAsyncItem cosmosItem = null;
//CREATE item sync
try {
cosmosItem = container.createItem(replaceObject)
.doOnError(throwable -> log("CREATE 3", throwable))
.publishOn(Schedulers.elastic())
.block()
.getItem();
} catch (RuntimeException e) {
.doOnError(throwable -> log("CREATE 3", throwable))
.publishOn(Schedulers.elastic())
.block()
.getItem();
}catch (RuntimeException e){
log("Couldn't create items due to above exceptions");
}
if (cosmosItem != null) {
Expand All @@ -96,12 +97,12 @@ private void createAndReplaceItem() {

private void createDbAndContainerBlocking() {
client.createDatabaseIfNotExists(DATABASE_NAME)
.doOnSuccess(cosmosDatabaseResponse -> log("Database: " + cosmosDatabaseResponse.getDatabase().getId()))
.flatMap(dbResponse -> dbResponse.getDatabase().createContainerIfNotExists(new CosmosContainerProperties(CONTAINER_NAME, "/country")))
.doOnSuccess(cosmosContainerResponse -> log("Container: " + cosmosContainerResponse.getContainer().getId()))
.doOnError(throwable -> log(throwable.getMessage()))
.publishOn(Schedulers.elastic())
.block();
.doOnSuccess(cosmosDatabaseResponse -> log("Database: " + cosmosDatabaseResponse.getDatabase().getId()))
.flatMap(dbResponse -> dbResponse.getDatabase().createContainerIfNotExists(new CosmosContainerProperties(CONTAINER_NAME, "/country")))
.doOnSuccess(cosmosContainerResponse -> log("Container: " + cosmosContainerResponse.getContainer().getId()))
.doOnError(throwable -> log(throwable.getMessage()))
.publishOn(Schedulers.elastic())
.block();
}

private void queryItems() {
Expand All @@ -112,19 +113,16 @@ private void queryItems() {
options.setMaxDegreeOfParallelism(2);
Flux<FeedResponse<TestObject>> queryFlux = container.queryItems(query, options, TestObject.class);

queryFlux.publishOn(Schedulers.elastic()).subscribe(cosmosItemFeedResponse -> {
},
throwable -> {
},
() -> {
});
queryFlux.publishOn(Schedulers.elastic()).subscribe(cosmosItemFeedResponse -> {},
throwable -> {},
() -> {});

queryFlux.publishOn(Schedulers.elastic())
.toIterable()
.forEach(cosmosItemFeedResponse ->
{
log(cosmosItemFeedResponse.getResults());
});
.toIterable()
.forEach(cosmosItemFeedResponse ->
{
log(cosmosItemFeedResponse.getResults());
});

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.azure.cosmos.CosmosAsyncContainer;
import com.azure.cosmos.CosmosAsyncContainerResponse;
import com.azure.cosmos.CosmosAsyncDatabase;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.cosmos.CosmosClientException;
import com.azure.cosmos.CosmosContainerProperties;
import com.azure.cosmos.CosmosContainerRequestOptions;
Expand Down Expand Up @@ -83,7 +84,7 @@ public static void main (String[]args) {
}

public static ChangeFeedProcessor getChangeFeedProcessor(String hostName, CosmosAsyncContainer feedContainer, CosmosAsyncContainer leaseContainer) {
return ChangeFeedProcessor.Builder()
return ChangeFeedProcessor.changeFeedProcessorBuilder()
.setHostName(hostName)
.setFeedContainer(feedContainer)
.setLeaseContainer(leaseContainer)
Expand All @@ -101,7 +102,7 @@ public static ChangeFeedProcessor getChangeFeedProcessor(String hostName, Cosmos

public static CosmosAsyncClient getCosmosClient() {

return CosmosAsyncClient.builder()
return new CosmosClientBuilder()
.setEndpoint(SampleConfigurations.HOST)
.setKey(SampleConfigurations.MASTER_KEY)
.setConnectionPolicy(ConnectionPolicy.getDefaultPolicy())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.azure.cosmos.CosmosAsyncClient;
import com.azure.cosmos.CosmosAsyncContainer;
import com.azure.cosmos.CosmosClientBuilder;
import reactor.core.publisher.Mono;

import java.io.IOException;
Expand All @@ -14,9 +15,9 @@ public static void main(String[] args) {
}

void runDemo() {
// Create a new CosmosAsyncClient via the builder
// Create a new CosmosAsyncClient via the CosmosClientBuilder
// It only requires endpoint and key, but other useful settings are available
CosmosAsyncClient client = CosmosAsyncClient.builder()
CosmosAsyncClient client = new CosmosClientBuilder()
.setEndpoint("<YOUR ENDPOINT HERE>")
.setKey("<YOUR KEY HERE>")
.buildAsyncClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,11 @@ private DocumentCollection getMultiPartitionCollectionDefinition() {
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<>();
Index stringIndex = Index.Range(DataType.STRING);
Index stringIndex = Index.range(DataType.STRING);
BridgeInternal.setProperty(stringIndex, "getPrecision", -1);
indexes.add(stringIndex);

Index numberIndex = Index.Range(DataType.NUMBER);
Index numberIndex = Index.range(DataType.NUMBER);
BridgeInternal.setProperty(numberIndex, "getPrecision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void createDocumentWithProgrammableDocumentDefinition() throws Exception
.getResource();

RequestOptions options = new RequestOptions();
options.setPartitionKey(PartitionKey.None);
options.setPartitionKey(PartitionKey.NONE);
// READ the created document
Flux<ResourceResponse<Document>> readDocumentObservable = client
.readDocument(getDocumentLink(createdDocument), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ private DocumentCollection getMultiPartitionCollectionDefinition() {
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<>();
Index stringIndex = Index.Range(DataType.STRING);
Index stringIndex = Index.range(DataType.STRING);
BridgeInternal.setProperty(stringIndex, "precision", -1);
indexes.add(stringIndex);

Index numberIndex = Index.Range(DataType.NUMBER);
Index numberIndex = Index.range(DataType.NUMBER);
BridgeInternal.setProperty(numberIndex, "precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ private static DocumentCollection getMultiPartitionCollectionDefinition() {
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
List<Index> indexes = new ArrayList<Index>();
Index stringIndex = Index.Range(DataType.STRING);
Index stringIndex = Index.range(DataType.STRING);
BridgeInternal.setProperty(stringIndex, "precision", -1);
indexes.add(stringIndex);

Index numberIndex = Index.Range(DataType.NUMBER);
Index numberIndex = Index.range(DataType.NUMBER);
BridgeInternal.setProperty(numberIndex, "precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void readDocumentThroughTokenResolver() throws Exception {
.build();
RequestOptions requestOptions = new RequestOptions();
requestOptions.setProperties(properties);
requestOptions.setPartitionKey(PartitionKey.None);
requestOptions.setPartitionKey(PartitionKey.NONE);
Flux<ResourceResponse<Document>> readDocumentObservable = asyncClientWithTokenResolver
.readDocument(documentLink, requestOptions);
readDocumentObservable.collectList().block().forEach(capturedResponse::add);
Expand Down Expand Up @@ -192,7 +192,7 @@ public void deleteDocumentThroughTokenResolver() throws Exception {

RequestOptions requestOptions = new RequestOptions();
requestOptions.setProperties(properties);
requestOptions.setPartitionKey(PartitionKey.None);
requestOptions.setPartitionKey(PartitionKey.NONE);
Flux<ResourceResponse<Document>> readDocumentObservable = asyncClientWithTokenResolver
.deleteDocument(documentLink, requestOptions);
readDocumentObservable.collectList().block().forEach(capturedResponse::add);
Expand Down
2 changes: 2 additions & 0 deletions sdk/cosmos/azure-cosmos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ Licensed under the MIT License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
<excludes>**/implementation/**,**/BridgeInternal.java,**/CosmosBridgeInternal.java</excludes>
Comment thread
mbhaskar marked this conversation as resolved.
Outdated
<failsOnError>false</failsOnError>
<failOnViolation>false</failOnViolation>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public BadRequestException() {
this(RMResources.BadRequest);
}

public BadRequestException(CosmosError cosmosError, long lsn, String partitionKeyRangeId, Map<String, String> responseHeaders) {
public BadRequestException(CosmosError cosmosError, long lsn, String partitionKeyRangeId,
Map<String, String> responseHeaders) {
super(HttpConstants.StatusCodes.BADREQUEST, cosmosError, responseHeaders);
BridgeInternal.setLSN(this, lsn);
BridgeInternal.setPartitionKeyRangeId(this, partitionKeyRangeId);
Expand All @@ -49,13 +50,13 @@ public BadRequestException(String message, HttpHeaders headers, URI requestUri)
}

BadRequestException(String message,
Exception innerException,
HttpHeaders headers,
String requestUrlString) {
Exception innerException,
HttpHeaders headers,
String requestUrlString) {
super(String.format("%s: %s", RMResources.BadRequest, message),
innerException,
HttpUtils.asMap(headers),
HttpConstants.StatusCodes.BADREQUEST,
requestUrlString);
innerException,
HttpUtils.asMap(headers),
HttpConstants.StatusCodes.BADREQUEST,
requestUrlString);
}
}
Loading