Skip to content

Commit e115a5c

Browse files
authored
Standardization (#66)
1 parent f4114ba commit e115a5c

File tree

76 files changed

+4894
-1747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+4894
-1747
lines changed

snooty.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ intersphinx = [ "https://www.mongodb.com/docs/manual/objects.inv",
88
sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"
99

1010
toc_landing_pages = [
11-
"/tutorials/connect/",
12-
"/tutorials/write-ops/",
11+
"/connect/",
12+
"/read-data-from-mongo/",
13+
"/write-data-to-mongo/",
14+
"/getting-started/",
15+
"/secure-your-data/"
1316
]
1417

1518
[constants]
@@ -20,3 +23,8 @@ full-version = "{+version+}.3"
2023
api = "https://mongodb.github.io/mongo-java-driver/{+version+}/apidocs"
2124
rs-docs = "https://www.reactive-streams.org/reactive-streams-1.0.4-javadoc/org/reactivestreams"
2225
driver-source-gh = "https://github.com/mongodb/mongo-java-driver"
26+
java-rs = "Java Reactive Streams"
27+
string-data-type = "``String``"
28+
bool = "``boolean``"
29+
pr = "Project Reactor"
30+
mdb-server = "MongoDB Server"

source/tutorials/aggregation.txt renamed to source/aggregation.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _javars-aggregation:
1+
.. _java-rs-aggregation:
22

33
=====================
44
Aggregation Framework

source/compatibility.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. _java-rs-compatibility:
2+
3+
=============
4+
Compatibility
5+
=============
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
.. facet::
14+
:name: genre
15+
:values: reference
16+
17+
.. meta::
18+
:keywords: backwards compatibility, versions, upgrade
19+
20+
MongoDB Compatibility
21+
----------------------
22+
23+
The following compatibility table specifies the recommended version or versions
24+
of the {+driver-short+} for use with a specific version of MongoDB.
25+
26+
The first column lists the driver version.
27+
28+
.. sharedinclude:: dbx/lifecycle-schedule-callout.rst
29+
30+
.. sharedinclude:: dbx/compatibility-table-legend.rst
31+
32+
.. include:: /includes/mongodb-compatibility-table-java-rs.rst
33+
34+
Language Compatibility
35+
----------------------
36+
37+
The following compatibility table specifies the recommended version or versions
38+
of the {+driver-short+} for use with a specific version of Java. Starting with
39+
Java 11, the table explicitly lists only Long-Term-Support (LTS) Java versions.
40+
41+
The first column lists the driver version.
42+
43+
.. include:: /includes/language-compatibility-table-java-rs.rst
44+
45+
For more information on how to read the compatibility tables, see our guide on
46+
:driver:`MongoDB Compatibility Tables </about-compatibility/>`.
47+
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
.. _java-rs-connection-targets:
2+
3+
==========================
4+
Choose a Connection Target
5+
==========================
6+
7+
.. facet::
8+
:name: genre
9+
:values: reference
10+
11+
.. meta::
12+
:keywords: connection string, URI, server, settings, client
13+
14+
.. contents:: On this page
15+
:local:
16+
:backlinks: none
17+
:depth: 2
18+
:class: singlecol
19+
20+
Overview
21+
--------
22+
23+
In this guide, you can learn how to use a connection string and a ``MongoClient`` object
24+
to connect to different types of MongoDB deployments.
25+
26+
Atlas
27+
-----
28+
29+
To connect to a MongoDB deployment on Atlas, include the following elements
30+
in your connection string:
31+
32+
- URL of your Atlas cluster
33+
- MongoDB username
34+
- MongoDB password
35+
36+
Then, pass your connection string to the ``create()`` method constructing a ``MongoClient`` object.
37+
38+
.. tip::
39+
40+
Follow the :atlas:`Atlas driver connection guide </driver-connection>`
41+
to retrieve your connection string.
42+
43+
When you connect to Atlas, we recommend using the Stable API client option to avoid
44+
breaking changes when Atlas upgrades to a new version of MongoDB Server.
45+
To learn more about the Stable API feature, see :manual:`Stable API
46+
</reference/stable-api>` in the MongoDB Server manual.
47+
48+
The following code shows how to use the {+driver-short+} to connect to an Atlas cluster. The
49+
code uses the ``serverApi`` option to specify a Stable API version.
50+
51+
.. include:: /includes/connect/connect-reactor.rst
52+
53+
.. literalinclude:: /includes/connect/atlas-connection.java
54+
:language: java
55+
56+
Local Deployments
57+
-----------------
58+
59+
To connect to a local MongoDB deployment, use ``localhost`` as the hostname. By
60+
default, the ``mongod`` process runs on port 27017, though you can customize this for
61+
your deployment.
62+
63+
The following code shows how to use the {+driver-short+} to connect to a local MongoDB
64+
deployment:
65+
66+
.. literalinclude:: /includes/connect/choose-connect-target.java
67+
:start-after: start-connect-local
68+
:end-before: end-connect-local
69+
:language: java
70+
:copyable:
71+
72+
Replica Sets
73+
------------
74+
75+
To connect to a replica set, specify the hostnames (or IP addresses) and
76+
port numbers of the replica-set members in your connection string.
77+
78+
If you aren't able to provide a full list of hosts in the replica set, you can
79+
specify one or more of the hosts in the replica set and instruct the {+driver-short+} to
80+
perform automatic discovery to find the others. To instruct the driver to perform
81+
automatic discovery, perform one of the following actions:
82+
83+
- Specify the name of the replica set as the value of the ``replicaSet`` parameter.
84+
- Specify ``false`` as the value of the ``directConnection`` parameter.
85+
- Specify more than one host in the replica set.
86+
87+
In the following example, the driver uses a sample connection URI to connect to the
88+
MongoDB replica set ``sampleRS``, which is running on port ``27017`` of three different
89+
hosts, including ``host1``:
90+
91+
.. literalinclude:: /includes/connect/choose-connect-target.java
92+
:start-after: start-connect-replica
93+
:end-before: end-connect-replica
94+
:language: java
95+
:copyable:
96+
97+
.. note:: create() is Non-Blocking
98+
99+
The ``create()`` method constructing a ``MongoClient`` is *non-blocking*.
100+
When you connect to a replica set, the method returns immediately while the
101+
client uses background threads to connect to the replica set.
102+
103+
If you create a ``MongoClient`` and immediately print the string representation
104+
of its ``nodes`` attribute, the list might be empty while the client connects to
105+
the replica-set members.
106+
107+
Initialization
108+
~~~~~~~~~~~~~~
109+
110+
To initialize a replica set, you must connect directly to a single member. To do so,
111+
set the ``directConnection`` connection
112+
option to ``True``. You can do this in the following ways:
113+
114+
- Passing an argument to the ``create()`` method constructing a ``MongoClient``
115+
- Setting the parameter in your connection string.
116+
117+
.. tabs::
118+
119+
.. tab:: MongoClient
120+
:tabid: mongoclient
121+
122+
.. literalinclude:: /includes/connect/choose-connect-target.java
123+
:start-after: start-arg-constructor
124+
:end-before: end-arg-constructor
125+
:language: java
126+
:copyable:
127+
:emphasize-lines: 7
128+
129+
.. tab:: Connection String
130+
:tabid: connectionstring
131+
132+
.. literalinclude:: /includes/connect/choose-connect-target.java
133+
:start-after: start-parameter-string
134+
:end-before: end-parameter-string
135+
:language: java
136+
:copyable:
137+
:emphasize-lines: 6
138+
139+
API Documentation
140+
-----------------
141+
142+
To learn more about creating a ``MongoClient`` instance in the {+driver-short+},
143+
see the following API documentation:
144+
145+
- `MongoClient <{+api+}/mongodb-driver-reactivestreams/com/mongodb/reactivestreams/client/MongoClients.html>`__

0 commit comments

Comments
 (0)