Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Commit 2ae5719

Browse files
committed
minor cleanup, reformattig, pretty printing etc
1 parent f528d53 commit 2ae5719

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

Diff for: azure-cosmosdb-get-started/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<plugin>
2121
<groupId>org.codehaus.mojo</groupId>
2222
<artifactId>exec-maven-plugin</artifactId>
23-
<version>1.2.1</version>
23+
<version>1.6.0</version>
2424
<configuration>
2525
<mainClass>com.microsoft.azure.cosmosdb.sample.Main</mainClass>
2626
</configuration>

Diff for: azure-cosmosdb-get-started/src/main/java/com/microsoft/azure/cosmosdb/sample/Families.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Families {
2626

2727
public static Family getAndersenFamilyDocument() {
2828
Family andersenFamily = new Family();
29-
andersenFamily.setId("Andersen" + System.currentTimeMillis());
29+
andersenFamily.setId("Andersen-" + System.currentTimeMillis());
3030
andersenFamily.setLastName("Andersen");
3131

3232
Parent parent1 = new Parent();
@@ -61,7 +61,7 @@ public static Family getAndersenFamilyDocument() {
6161

6262
public static Family getWakefieldFamilyDocument() {
6363
Family wakefieldFamily = new Family();
64-
wakefieldFamily.setId("Wakefield" + System.currentTimeMillis());
64+
wakefieldFamily.setId("Wakefield-" + System.currentTimeMillis());
6565
wakefieldFamily.setLastName("Wakefield");
6666

6767
Parent parent1 = new Parent();
@@ -108,7 +108,7 @@ public static Family getWakefieldFamilyDocument() {
108108

109109
public static Family getJohnsonFamilyDocument() {
110110
Family andersenFamily = new Family();
111-
andersenFamily.setId("Johnson" + System.currentTimeMillis());
111+
andersenFamily.setId("Johnson-" + System.currentTimeMillis());
112112
andersenFamily.setLastName("Johnson");
113113

114114
Parent parent1 = new Parent();
@@ -122,7 +122,7 @@ public static Family getJohnsonFamilyDocument() {
122122

123123
public static Family getSmithFamilyDocument() {
124124
Family andersenFamily = new Family();
125-
andersenFamily.setId("Smith" + System.currentTimeMillis());
125+
andersenFamily.setId("Smith-" + System.currentTimeMillis());
126126
andersenFamily.setLastName("Smith");
127127

128128
Parent parent1 = new Parent();

Diff for: azure-cosmosdb-get-started/src/main/java/com/microsoft/azure/cosmosdb/sample/Main.java

+13-7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.concurrent.ExecutorService;
4949
import java.util.concurrent.Executors;
5050
import java.util.concurrent.TimeUnit;
51+
import java.util.stream.Collectors;
5152

5253
public class Main {
5354
private final ExecutorService executorService;
@@ -96,13 +97,14 @@ public static void main(String[] args) {
9697

9798
try {
9899
p.getStartedDemo();
99-
System.out.println(String.format("Demo complete, please hold while resources are deleted"));
100+
System.out.println(String.format("Demo complete, please hold while resources are released"));
100101
} catch (Exception e) {
101102
System.err.println(String.format("DocumentDB GetStarted failed with %s", e));
102103
} finally {
103104
System.out.println("close the client");
104105
p.close();
105106
}
107+
System.exit(0);
106108
}
107109

108110
private void getStartedDemo() throws Exception {
@@ -112,7 +114,7 @@ private void getStartedDemo() throws Exception {
112114
.withServiceEndpoint(AccountSettings.HOST)
113115
.withMasterKeyOrResourceToken(AccountSettings.MASTER_KEY)
114116
.withConnectionPolicy(ConnectionPolicy.GetDefault())
115-
.withConsistencyLevel(ConsistencyLevel.Session)
117+
.withConsistencyLevel(ConsistencyLevel.Eventual)
116118
.build();
117119

118120
createDatabaseIfNotExists();
@@ -307,25 +309,29 @@ private void heavyWork() {
307309
private void executeSimpleQueryAsyncAndRegisterListenerForResult(CountDownLatch completionLatch) {
308310
// Set some common query options
309311
FeedOptions queryOptions = new FeedOptions();
310-
queryOptions.setMaxItemCount(100);
312+
queryOptions.setMaxItemCount(10);
311313
queryOptions.setEnableCrossPartitionQuery(true);
312314

313315
String collectionLink = String.format("/dbs/%s/colls/%s", databaseName, collectionName);
314316
Observable<FeedResponse<Document>> queryObservable =
315317
client.queryDocuments(collectionLink,
316-
"SELECT * FROM Family WHERE Family.lastName = 'Andersen'", queryOptions);
318+
"SELECT * FROM Family WHERE Family.lastName != 'Andersen'", queryOptions);
317319

318320
queryObservable
319321
.observeOn(scheduler)
320322
.subscribe(
321-
queryResultPage -> {
323+
page -> {
322324
// we want to make sure heavyWork() doesn't block any of netty IO threads
323325
// so we use observeOn(scheduler) to switch from the netty thread to user's thread.
324326
heavyWork();
325327

326328
System.out.println("Got a page of query result with " +
327-
queryResultPage.getResults().size() + " document(s)"
328-
+ " and request charge of " + queryResultPage.getRequestCharge());
329+
page.getResults().size() + " document(s)"
330+
+ " and request charge of " + page.getRequestCharge());
331+
332+
333+
System.out.println("Document Ids " + page.getResults().stream().map(d -> d.getId())
334+
.collect(Collectors.toList()));
329335
},
330336
// terminal error signal
331337
e -> {

0 commit comments

Comments
 (0)