Skip to content

Commit 4d549da

Browse files
kay-kimjyemin
authored andcommitted
JAVA-2399 Update Docs: Monitoring + Check of Other Pages
1 parent eb99606 commit 4d549da

File tree

14 files changed

+93
-33
lines changed

14 files changed

+93
-33
lines changed

docs/reference/content/driver-async/tutorials/authentication.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,15 @@ String user; // The x.509 certificate derived user name, e.g. "CN=user,OU=Or
156156
MongoCredential credential = MongoCredential.createMongoX509Credential(user);
157157
ClusterSettings clusterSettings = ClusterSettings.builder()
158158
.hosts(asList(new ServerAddress("localhost"))).build();
159+
160+
EventLoopGroup eventLoopGroup = new NioEventLoopGroup(); // make sure application shuts this down
161+
159162
MongoClientSettings settings = MongoClientSettings.builder()
160-
.clusterSettings(clusterSettings)
161-
.credentialList(Arrays.asList(credential))
162-
.build();
163+
.clusterSettings(clusterSettings)
164+
.credentialList(Arrays.asList(credential))
165+
.streamFactoryFactory(NettyStreamFactoryFactory.builder().eventLoopGroup(eventLoopGroup).build())
166+
.sslSettings(SslSettings.builder().enabled(true).build())
167+
.build();
163168
MongoClient mongoClient = MongoClients.create(settings);
164169
```
165170

@@ -168,7 +173,7 @@ Or use a `ConnectionString` instance that explicitly specifies the
168173

169174
```java
170175
MongoClient mongoClient = MongoClients.create(new ConnectionString(
171-
"mongodb://subjectName@host1/?authMechanism=MONGODB-X509"));
176+
"mongodb://subjectName@host1/?authMechanism=MONGODB-X509&streamType=netty&ssl=true"));
172177
```
173178

174179
See the MongoDB server
@@ -202,7 +207,7 @@ Or use a `ConnectionString` that explicitly specifies the
202207

203208
```java
204209
MongoClient mongoClient = MongoClients.create(new ConnectionString(
205-
"mongodb://username%40MYREALM.com@host1/?authMechanism=GSSAPI"));
210+
"mongodb://username%40MYREALM.ME@host1/?authMechanism=GSSAPI"));
206211
```
207212

208213
{{% note %}}

docs/reference/content/driver-async/tutorials/connect-to-mongodb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ MongoDB will auto-discover the primary and the secondaries.
113113

114114
```java
115115
MongoClient mongoClient = MongoClients.create(
116-
ConnectionString("mongodb://host1:27017,host2:27017,host3:27017"));
116+
new ConnectionString("mongodb://host1:27017,host2:27017,host3:27017"));
117117
```
118118

119119
- Specify at least one member of the replica set and the replica set name:

docs/reference/content/driver-async/tutorials/geospatial-search.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ To support geospatial queries, MongoDB provides various geospatial indexes as we
1919

2020
- Include the following import statements:
2121

22+
```java
23+
import com.mongodb.Block;
24+
import com.mongodb.async.SingleResultCallback;
25+
import com.mongodb.async.client.MongoClient;
26+
import com.mongodb.async.client.MongoClients;
27+
import com.mongodb.async.client.MongoCollection;
28+
import com.mongodb.async.client.MongoDatabase;
29+
import com.mongodb.client.model.Filters;
30+
import com.mongodb.client.model.Indexes;
31+
import com.mongodb.client.model.geojson.Point;
32+
import com.mongodb.client.model.geojson.Position;
33+
import org.bson.Document;
34+
```
2235

2336

2437
- Include the following callback code which the examples in the tutorials will use:

docs/reference/content/driver-async/tutorials/gridfs.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import static com.mongodb.async.client.gridfs.helpers.AsynchronousChannelHelper.
5959
import com.mongodb.async.SingleResultCallback;
6060

6161
import com.mongodb.Block;
62-
62+
import static com.mongodb.client.model.Filters.eq;
6363
import java.nio.charset.StandardCharsets;
6464
import java.nio.ByteBuffer;
6565
import java.nio.file.Path;
@@ -269,6 +269,8 @@ If you should need to rename a file, then use the [`rename`]({{< apiref "com/mon
269269
The following example renames a file to "mongodbTutorial":
270270

271271
```java
272+
ObjectId fileId; // The id of a file uploaded to GridFS, initialize to valid file id
273+
...
272274
gridFSBucket.rename(fileId, "mongodbTutorial", new SingleResultCallback<Void>() {
273275
@Override
274276
public void onResult(final Void result, final Throwable t) {
@@ -290,6 +292,8 @@ To delete a file from the `GridFSBucket` use the [`delete`]({{< apiref "com/mong
290292
The following example deletes a file from the `GridFSBucket`:
291293

292294
```java
295+
ObjectId fileId; // The id of a file uploaded to GridFS, initialize to valid file id
296+
...
293297
gridFSBucket.delete(fileId, new SingleResultCallback<Void>() {
294298
@Override
295299
public void onResult(final Void result, final Throwable t) {

docs/reference/content/driver-async/tutorials/ssl.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ You can also specify the connection string via the [`ConnectionString`]({{< apir
3939
To specify TLS/SSL with [`MongoClientSettings`]({{< apiref "com/mongodb/async/client/MongoClientSettings.Builder.html#streamFactoryFactory-com.mongodb.connection.StreamFactoryFactory-">}}) , set the ``sslEnabled`` property to ``true``, and the stream factory to [`NettyStreamFactoryFactory`]({{< apiref "com/mongodb/connection/netty/NettyStreamFactoryFactory" >}}), as in
4040

4141
```java
42+
43+
EventLoopGroup eventLoopGroup = new NioEventLoopGroup(); // make sure application shuts this down
44+
45+
4246
MongoClient client = MongoClients.create(MongoClientSettings.builder()
4347
.clusterSettings(ClusterSettings.builder()
4448
.hosts(Arrays.asList(new ServerAddress()))
4549
.build())
4650
.streamFactoryFactory(NettyStreamFactoryFactory.builder()
47-
.build())
51+
.eventLoopGroup(eventLoopGroup).build())
4852
.sslSettings(SslSettings.builder()
4953
.enabled(true)
5054
.build())
@@ -75,6 +79,9 @@ If your application must run on Java 6, or for some other reason you need
7579
to disable host name verification, you must explicitly indicate this using the `invalidHostNameAllowed` property:
7680

7781
```java
82+
83+
EventLoopGroup eventLoopGroup = new NioEventLoopGroup(); // make sure application shuts this down
84+
7885
MongoClient client = MongoClients.create(MongoClientSettings.builder()
7986
.clusterSettings(ClusterSettings.builder()
8087
.hosts(Arrays.asList(new ServerAddress()))
@@ -83,7 +90,8 @@ MongoClient client = MongoClients.create(MongoClientSettings.builder()
8390
.enabled(true)
8491
.invalidHostNameAllowed(true)
8592
.build())
86-
.streamFactoryFactory(NettyStreamFactoryFactory.builder().build())
93+
.streamFactoryFactory(NettyStreamFactoryFactory.builder()
94+
.eventLoopGroup(eventLoopGroup).build())
8795
.build());
8896
```
8997

docs/reference/content/driver/getting-started/quick-start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import com.mongodb.client.MongoDatabase;
3232
import com.mongodb.client.MongoCollection;
3333

3434
import org.bson.Document;
35+
import java.util.Arrays;
36+
import com.mongodb.Block;
3537

3638
import com.mongodb.client.MongoCursor;
3739
import static com.mongodb.client.model.Filters.*;
@@ -356,8 +358,6 @@ The following example increments the value of ``i`` by ``100`` for all documents
356358
UpdateResult updateResult = collection.updateMany(lt("i", 100), inc("i", 100));
357359
System.out.println(updateResult.getModifiedCount());
358360

359-
UpdateResult updateResult = collection.updateMany(lt("i", 100), new Document("$inc", new Document("i", 100))); System.out.println(updateResult.getModifiedCount());
360-
361361
```
362362

363363
## Delete Documents

docs/reference/content/driver/tutorials/aggregation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ The [aggregation pipeline]({{<docsref "/core/aggregation-pipeline">}}) is a fram
2727
import com.mongodb.client.model.Accumulators;
2828
import com.mongodb.client.model.Projections;
2929
import com.mongodb.client.model.Filters;
30+
31+
import org.bson.Document;
3032
```
3133

3234
- Include the following code which the examples in the tutorials will use to print the results of the aggregation:

docs/reference/content/driver/tutorials/authentication.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,18 @@ create a credential of this type use the
137137
String user; // The X.509 certificate derived user name, e.g. "CN=user,OU=OrgUnit,O=myOrg,..."
138138
// ...
139139
MongoCredential credential = MongoCredential.createMongoX509Credential(user);
140+
MongoClientOptions options = MongoClientOptions.builder().sslEnabled(true).build();
141+
140142

141143
MongoClient mongoClient = new MongoClient(new ServerAddress("host1", 27017),
142-
Arrays.asList(credential));
144+
Arrays.asList(credential), options);
143145
```
144146

145147
Or use a connection string that explicitly specifies the
146148
`authMechanism=MONGODB-X509`:
147149

148150
```java
149-
MongoClientURI uri = new MongoClientURI("mongodb://subjectName@host1/?authMechanism=MONGODB-X509");
151+
MongoClientURI uri = new MongoClientURI("mongodb://subjectName@host1/?authMechanism=MONGODB-X509&ssl=true");
150152
MongoClient mongoClient = new MongoClient(uri);
151153
```
152154

@@ -171,7 +173,7 @@ Or use a connection string that explicitly specifies the
171173
`authMechanism=GSSAPI`:
172174

173175
```java
174-
MongoClientURI uri = new MongoClientURI("mongodb://username%40REALM.com@host1/?authMechanism=GSSAPI");
176+
MongoClientURI uri = new MongoClientURI("mongodb://username%40REALM.ME@host1/?authMechanism=GSSAPI");
175177
```
176178
{{%note%}}
177179

docs/reference/content/driver/tutorials/connect-to-mongodb.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ MongoClient constructors, see
3131
import com.mongodb.MongoClient;
3232
import com.mongodb.MongoClientURI;
3333
import com.mongodb.ServerAddress;
34-
import com.mongodb.MongoCredential
34+
import com.mongodb.MongoCredential;
35+
import com.mongodb.MongoClientOptions;
3536

3637
import java.util.Arrays;
3738
```

docs/reference/content/driver/tutorials/geospatial-search.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ To support geospatial queries, MongoDB provides various geospatial indexes as we
1919
- Include the following import statements:
2020

2121
```java
22+
import com.mongodb.Block;
2223
import com.mongodb.MongoClient;
2324
import com.mongodb.client.MongoCollection;
2425
import com.mongodb.client.MongoDatabase;

0 commit comments

Comments
 (0)