From 5432be8b34e86383228b0156edef840e809f0769 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 22 Sep 2023 13:55:09 -0400 Subject: [PATCH 01/19] DOCSP-32942: Deprecated Methods --- source/whats-new.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/whats-new.txt b/source/whats-new.txt index 9e85138e2..d8effce56 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -74,6 +74,18 @@ What's New in 4.11 .. New features of the 4.11 driver release include: +- The following network address-related methods are deprecated and will be removed + in v5.0: + + - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ + methods ``getSocketAddress()`` and ``getSocketAddresses()``. + Instead of ``getSocketAddress()``, use the ``getAddress()`` method from the + ``InetSocketAddress`` class. Instead of ``getSocketAddresses()``, use the + ``getAllByName()`` method from the ``InetAddress`` class. + - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ + method ``getUnixSocketAddress()``. Instead, call ``of()`` on a ``UnixDomainSocketAddress`` + instance and pass a path name as an argument. + .. _version-4.10: What's New in 4.10 From 9a3532730a62aa403cbade9a9044d743e8565b00 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 22 Sep 2023 16:41:26 -0400 Subject: [PATCH 02/19] review feedback --- source/whats-new.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index d8effce56..8bce9c816 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -83,8 +83,9 @@ What's New in 4.11 ``InetSocketAddress`` class. Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method from the ``InetAddress`` class. - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ - method ``getUnixSocketAddress()``. Instead, call ``of()`` on a ``UnixDomainSocketAddress`` - instance and pass a path name as an argument. + method ``getUnixSocketAddress()``. Instead of ``getUnixSocketAddress()``, call + ``of()`` on a ``UnixDomainSocketAddress`` instance and pass a path name as an + argument. .. _version-4.10: From f4e1889a9d00aa59f54838ce509910b80d173e97 Mon Sep 17 00:00:00 2001 From: Chris Cho Date: Mon, 25 Sep 2023 11:29:13 -0400 Subject: [PATCH 03/19] DOCSP-33241: fix extended JSON example id field (#447) * DOCSP-33241: fix extended JSON example id field --- .../document-data-format-extended-json.txt | 114 ++++++++++-------- 1 file changed, 61 insertions(+), 53 deletions(-) diff --git a/source/fundamentals/data-formats/document-data-format-extended-json.txt b/source/fundamentals/data-formats/document-data-format-extended-json.txt index b38920f19..6b991f896 100644 --- a/source/fundamentals/data-formats/document-data-format-extended-json.txt +++ b/source/fundamentals/data-formats/document-data-format-extended-json.txt @@ -128,7 +128,7 @@ corresponds to the format of the example you want to see: .. code-block:: json { - "_id:": ObjectId("573a1391f29313caabcd9637"), + "_id": ObjectId("573a1391f29313caabcd9637"), "createdAt": ISODate("2020-09-30T18:22:51.648Z"), "numViews": NumberLong("36520312") } @@ -139,7 +139,7 @@ corresponds to the format of the example you want to see: .. code-block:: json { - "_id:": { "$oid": "573a1391f29313caabcd9637" }, + "_id": { "$oid": "573a1391f29313caabcd9637" }, "createdAt": { "$date": 1601499609 }, "numViews": { "$numberLong": "36520312" } } @@ -161,20 +161,22 @@ The following example shows how you can use the ``Document`` class to read an example Extended JSON string into a ``Document`` object using the ``parse()`` method: -.. code-block:: java +.. io-code-block:: - String ejsonStr = "{ \"_id\": { \"$oid\": \"507f1f77bcf86cd799439011\"}," + - "\"myNumber\": {\"$numberLong\": \"4794261\" }}}"; + .. input:: + :language: java - Document doc = Document.parse(ejsonStr); - System.out.println(doc); + String ejsonStr = "{ \"_id\": { \"$oid\": \"507f1f77bcf86cd799439011\"}," + + "\"myNumber\": {\"$numberLong\": \"4794261\" }}}"; -The output of the preceding code should look something like this: + Document doc = Document.parse(ejsonStr); + System.out.println(doc); -.. code-block:: none - :copyable: False + .. output:: + :language: none + :visible: false - Document{{_id=507f1f77bcf86cd799439011, myNumber=4794261}} + Document{{_id=507f1f77bcf86cd799439011, myNumber=4794261}} For more information, see our Fundamentals page on :doc:`Documents `. @@ -191,34 +193,36 @@ The driver's document classes also use this class to parse Extended JSON. The following code example shows how you can use the ``JsonReader`` class to convert an Extended JSON string into Java objects: -.. code-block:: java +.. io-code-block:: - String ejsonStr = "{ \"_id\": { \"$oid\": \"507f1f77bcf86cd799439011\"}," + - "\"myNumber\": {\"$numberLong\": \"4794261\" }}}"; + .. input:: + :language: java - JsonReader jsonReader = new JsonReader(ejsonStr); + String ejsonStr = "{ \"_id\": { \"$oid\": \"507f1f77bcf86cd799439011\"}," + + "\"myNumber\": {\"$numberLong\": \"4794261\" }}}"; - jsonReader.readStartDocument(); + JsonReader jsonReader = new JsonReader(ejsonStr); - jsonReader.readName("_id"); - ObjectId id = jsonReader.readObjectId(); - jsonReader.readName("myNumber"); - Long myNumber = jsonReader.readInt64(); + jsonReader.readStartDocument(); - jsonReader.readEndDocument(); + jsonReader.readName("_id"); + ObjectId id = jsonReader.readObjectId(); + jsonReader.readName("myNumber"); + Long myNumber = jsonReader.readInt64(); - System.out.println(id + " is type: " + id.getClass().getName()); - System.out.println(myNumber + " is type: " + myNumber.getClass().getName()); + jsonReader.readEndDocument(); - jsonReader.close(); + System.out.println(id + " is type: " + id.getClass().getName()); + System.out.println(myNumber + " is type: " + myNumber.getClass().getName()); -The output of this code example should look something like this: + jsonReader.close(); -.. code-block:: none - :copyable: False + .. output:: + :language: none + :visible: false - 507f1f77bcf86cd799439011 is type: org.bson.types.ObjectId - 4794261 is type: java.lang.Long + 507f1f77bcf86cd799439011 is type: org.bson.types.ObjectId + 4794261 is type: java.lang.Long For more information, see the `JsonReader @@ -236,20 +240,22 @@ instance of ``JsonWriterSettings`` to specify the Extended JSON format. In this example, we output the Extended JSON in the Relaxed mode format. -.. code-block:: java +.. io-code-block:: - Document myDoc = new Document(); - myDoc.append("_id", new ObjectId("507f1f77bcf86cd799439012")).append("myNumber", 11223344); + .. input:: + :language: java - JsonWriterSettings settings = JsonWriterSettings.builder().outputMode(JsonMode.RELAXED).build(); - System.out.println(doc.toJson(settings)); + Document myDoc = new Document(); + myDoc.append("_id", new ObjectId("507f1f77bcf86cd799439012")).append("myNumber", 11223344); -The output of this code example should look something like this: + JsonWriterSettings settings = JsonWriterSettings.builder().outputMode(JsonMode.RELAXED).build(); + System.out.println(doc.toJson(settings)); -.. code-block:: none - :copyable: false + .. output:: + :language: none + :visible: false - {"_id": {"$oid": "507f1f77bcf86cd799439012"}, "myNumber": 11223344} + {"_id": {"$oid": "507f1f77bcf86cd799439012"}, "myNumber": 11223344} Using the BSON Library ~~~~~~~~~~~~~~~~~~~~~~ @@ -266,24 +272,26 @@ The following code example shows how you can use ``JsonWriter`` to create an Extended JSON string and output it to ``System.out``. We specify the format by passing the ``outputMode()`` builder method the ``JsonMode.EXTENDED`` constant: -.. code-block:: java +.. io-code-block:: - JsonWriterSettings settings = JsonWriterSettings.builder().outputMode(JsonMode.EXTENDED).build(); + .. input:: + :language: java - try (JsonWriter jsonWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(System.out)), settings)) { - jsonWriter.writeStartDocument(); - jsonWriter.writeObjectId("_id", new ObjectId("507f1f77bcf86cd799439012")); - jsonWriter.writeInt64("myNumber", 11223344); - jsonWriter.writeEndDocument(); - jsonWriter.flush(); - } + JsonWriterSettings settings = JsonWriterSettings.builder().outputMode(JsonMode.EXTENDED).build(); -The output of this code example should look something like this: + try (JsonWriter jsonWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(System.out)), settings)) { + jsonWriter.writeStartDocument(); + jsonWriter.writeObjectId("_id", new ObjectId("507f1f77bcf86cd799439012")); + jsonWriter.writeInt64("myNumber", 11223344); + jsonWriter.writeEndDocument(); + jsonWriter.flush(); + } -.. code-block:: none - :copyable: false + .. output:: + :language: none + :visible: false - {"_id": {"$oid": "507f1f77bcf86cd799439012"}, "myNumber": {"$numberLong": "11223344"}} + {"_id": {"$oid": "507f1f77bcf86cd799439012"}, "myNumber": {"$numberLong": "11223344"}} For more information about the methods and classes mentioned in this section, see the following API Documentation: @@ -321,14 +329,14 @@ expressions, to simplify the Relaxed mode JSON output. System.out.println(doc.toJson(settings))); -The output of this code should look something like this: +The output of this code resembles the following text: .. code-block:: json :copyable: false {"_id": "507f1f77bcf86cd799439012", "createdAt": "2020-09-30T21:00:09Z", "myNumber": 4794261} -Without specifying the converters, the Relaxed mode JSON output should look something like this: +Without specifying the converters, the Relaxed mode JSON output resembles the following text: .. code-block:: json :copyable: false From 3d0675cce0ac6b254500c8ba9b47d476847dfe70 Mon Sep 17 00:00:00 2001 From: Chris Cho Date: Mon, 25 Sep 2023 14:00:16 -0400 Subject: [PATCH 04/19] DOCSP-31694: SOCKS5 proxy support (#439) * DOCSP-31694: SOCKS5 proxy support --- config/redirects | 1 + source/fundamentals/connection.txt | 4 +- .../connection/connection-options.txt | 35 +++-- source/fundamentals/connection/jndi.txt | 12 +- source/fundamentals/connection/socks.txt | 136 ++++++++++++++++++ 5 files changed, 163 insertions(+), 25 deletions(-) create mode 100644 source/fundamentals/connection/socks.txt diff --git a/config/redirects b/config/redirects index 18ccb714a..a3893739e 100644 --- a/config/redirects +++ b/config/redirects @@ -9,3 +9,4 @@ raw: ${prefix}/master -> ${base}/upcoming/ [*-v4.6]: ${prefix}/${version}/fundamentals/crud/read-operations/change-streams/ -> ${base}/${version}/fundamentals/crud/read-operations/retrieve/ [*-master]: ${prefix}/${version}/fundamentals/csfle/ -> ${base}/${version}/fundamentals/encrypt-fields/ [*-master]: ${prefix}/${version}/fundamentals/crud/write-operations/change-a-document/ -> ${base}/${version}/fundamentals/crud/write-operations/modify/ +[*-v4.10]: ${prefix}/${version}/fundamentals/connection/socks/ -> ${base}/${version}/ diff --git a/source/fundamentals/connection.txt b/source/fundamentals/connection.txt index a041f4f56..6f398ba7d 100644 --- a/source/fundamentals/connection.txt +++ b/source/fundamentals/connection.txt @@ -11,6 +11,7 @@ Connection Guide /fundamentals/connection/mongoclientsettings /fundamentals/connection/network-compression /fundamentals/connection/tls + /fundamentals/connection/socks /fundamentals/connection/jndi Connect to MongoDB Atlas from AWS Lambda @@ -32,7 +33,8 @@ sections: - :ref:`Specify Connection Behavior with the MongoClient Class ` - :ref:`Enable Network Compression ` - :ref:`Enable TLS/SSL on a Connection ` -- :ref:`Connect to MongoDB Using a JNDI Datasource ` +- :ref:`Connect to MongoDB by Using a SOCKS5 Proxy ` +- :ref:`Connect to MongoDB by Using a JNDI Datasource ` - :atlas:`Connect to MongoDB Atlas from AWS Lambda ` For information about authenticating with a MongoDB instance, diff --git a/source/fundamentals/connection/connection-options.txt b/source/fundamentals/connection/connection-options.txt index e487c9ba3..e8758a661 100644 --- a/source/fundamentals/connection/connection-options.txt +++ b/source/fundamentals/connection/connection-options.txt @@ -72,21 +72,21 @@ parameters of the connection URI to specify the behavior of the client. * - **ssl** - boolean - - Specifies that all communication with MongoDB instances should + - Specifies that all communication with MongoDB instances must use TLS/SSL. Superseded by the **tls** option. | **Default**: ``false`` * - **tls** - boolean - - Specifies that all communication with MongoDB instances should + - Specifies that all communication with MongoDB instances must use TLS. Supersedes the **ssl** option. | **Default**: ``false`` * - **tlsInsecure** - boolean - - Specifies that the driver should allow invalid hostnames for TLS + - Specifies that the driver must allow invalid hostnames for TLS connections. Has the same effect as setting **tlsAllowInvalidHostnames** to ``true``. To configure TLS security constraints in other ways, use a @@ -96,7 +96,7 @@ parameters of the connection URI to specify the behavior of the client. * - **tlsAllowInvalidHostnames** - boolean - - Specifies that the driver should allow invalid hostnames in the + - Specifies that the driver must allow invalid hostnames in the certificate for TLS connections. Supersedes **sslInvalidHostNameAllowed**. @@ -186,14 +186,14 @@ parameters of the connection URI to specify the behavior of the client. is greater. For more information, see the server documentation for the :manual:`maxStalenessSeconds option `. Not providing a parameter or explicitly specifying ``-1`` indicates - that there should be no staleness check for secondaries. + that there must be no staleness check for secondaries. | **Default**: ``-1`` * - **authMechanism** - string - Specifies the :doc:`authentication mechanism - ` that the driver should use if a credential + ` that the driver uses if a credential was supplied. | **Default**: By default, the client picks the most secure @@ -204,9 +204,8 @@ parameters of the connection URI to specify the behavior of the client. * - **authSource** - string - - Specifies the database that the supplied credentials should be - validated against. - + - Specifies the database in which the supplied credentials are validated. + | **Default**: ``admin`` * - **authMechanismProperties** @@ -239,7 +238,7 @@ parameters of the connection URI to specify the behavior of the client. * - **zlibCompressionLevel** - integer - Specifies the degree of compression that `Zlib `__ - should use to decrease the size of requests to the connected MongoDB + uses to decrease the size of requests to the connected MongoDB instance. The level can range from ``-1`` to ``9``, with lower values compressing faster (but resulting in larger requests) and larger values compressing slower (but resulting in smaller requests). @@ -249,7 +248,7 @@ parameters of the connection URI to specify the behavior of the client. * - **retryWrites** - boolean - Specifies that the driver must retry supported write operations - if they fail due to a network error. + if they are unable to complete due to a network error. | **Default**: ``true`` @@ -257,7 +256,7 @@ parameters of the connection URI to specify the behavior of the client. * - **retryReads** - boolean - Specifies that the driver must retry supported read operations - if they fail due to a network error. + if they are unable to complete due to a network error. | **Default**: ``true`` @@ -280,23 +279,23 @@ parameters of the connection URI to specify the behavior of the client. - integer - Specifies the maximum number of connections a pool may be establishing concurrently. - + | **Default**: ``2`` * - **srvServiceName** - string - Specifies the service name of the `SRV resource records `__ - the driver retrieves to construct your + the driver retrieves to construct your :manual:`seed list `. - You must use the + You must use the :manual:`DNS Seed List Connection Format ` in your :ref:`connection URI ` - to use this option. - + to use this option. + | **Default**: ``mongodb`` For a complete list of options, see the `ConnectionString <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ConnectionString.html>`__ -API reference page. +API documentation. diff --git a/source/fundamentals/connection/jndi.txt b/source/fundamentals/connection/jndi.txt index 43d53f142..8f1d9d5af 100644 --- a/source/fundamentals/connection/jndi.txt +++ b/source/fundamentals/connection/jndi.txt @@ -1,8 +1,8 @@ .. _jndi: -========================================== -Connect to MongoDB Using a JNDI Datasource -========================================== +============================================= +Connect to MongoDB by Using a JNDI Datasource +============================================= .. contents:: On this page :local: @@ -15,7 +15,7 @@ Overview -------- In this guide, you can learn how to connect the MongoDB Java driver -to your MongoDB instance using a Java Naming and Directory Interface +to your MongoDB instance by using a Java Naming and Directory Interface (JNDI) Datasource. MongoClientFactory includes a `JNDI @@ -61,7 +61,7 @@ JNDI Datasource. Replace the placeholder connection value in the ``property`` tag with a value that points to your MongoDB installation. - This makes a MongoClient instance accessible via the JNDI name + This makes a MongoClient instance discoverable through the JNDI name ``MyMongoClient`` in the ``java:global`` context. .. tab:: Tomcat @@ -106,7 +106,7 @@ JNDI Datasource. - This makes a ``MongoClient`` instance accessible via the JNDI name + This makes a ``MongoClient`` instance discoverable through the JNDI name ``mongodb/MyMongoClient`` in the ``java:comp/env`` context. .. seealso:: diff --git a/source/fundamentals/connection/socks.txt b/source/fundamentals/connection/socks.txt new file mode 100644 index 000000000..c5d0d900c --- /dev/null +++ b/source/fundamentals/connection/socks.txt @@ -0,0 +1,136 @@ +.. _java-connect-socks: + +========================================== +Connect to MongoDB by Using a SOCKS5 Proxy +========================================== + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +Overview +-------- + +In this guide, you can learn how to connect to MongoDB by using a SOCKS5 proxy. +SOCKS5 is a standardized protocol for communicating with network services +through a proxy server. + +.. tip:: + + To learn more about the SOCKS5 protocol, see the Wikipedia entry on + :wikipedia:`SOCKS `. + +.. _socks-proxy-settings: + +SOCKS5 Proxy Settings +--------------------- + +The proxy settings specify the SOCKS5 proxy server address and your +authentication credentials. You can specify your settings in an instance of +``MongoClientSettings`` or in your connection string. + +.. important:: + + The driver ignores the proxy settings if you specify a custom + ``StreamFactoryFactory``, which by default creates instances of + ``SocketStreamFactory``. + +The following table describes the SOCKS5 client options: + +.. list-table:: + :header-rows: 1 + :widths: 15 20 65 + + * - Name + - Accepted Values + - Description + + * - **proxyHost** + - String + - Specifies the SOCKS5 proxy IPv4 address, IPv6 address, or hostname. + You must provide this value to connect to a SOCKS5 proxy. + + * - **proxyPort** + - non-negative Integer + - Specifies the TCP port number of the SOCKS5 proxy server. This option + defaults to ``1080`` when you set ``proxyHost``. + + * - **proxyUsername** + - String + - Specifies the username for authentication to the SOCKS5 proxy server. + The driver ignores ``null`` and empty string values for this setting. + The driver requires that you pass values for both ``proxyUsername`` + and ``proxyPassword`` or that you omit both values. + + * - **proxyPassword** + - String + - Specifies the password for authentication to the SOCKS5 proxy server. + The driver ignores ``null`` and empty string values for this setting. + The driver requires that you pass values for both ``proxyUsername`` + and ``proxyPassword`` or that you omit both values. + + +Examples +-------- + +The following examples show how to instantiate a ``MongoClient`` that connects +to MongoDB by using a SOCKS5 proxy. The proxy settings can be specified in a +``MongoClientSettings`` instance or a connection string. These examples use +the placeholder values described in the :ref:`socks-proxy-settings` section. +Replace the placeholders with your proxy settings. + +Specify Proxy Settings in the MongoClientSettings +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following code example shows how to specify your SOCKS5 proxy settings by +using the ``MongoClientSettings`` builder: + +.. code-block:: java + :emphasize-lines: 5-12 + + MongoClient mongoClient = MongoClients.create( + MongoClientSettings.builder() + .applyConnectionString( + new ConnectionString("mongodb+srv://myDatabaseUser:myPassword@example.org/")) + .applyToSocketSettings(builder -> + builder.applyToProxySettings(proxyBuilder -> + proxyBuilder + .host("") + .port() + .username("") + .password("") + ) + ).build()); + +Specify Proxy Settings in the Connection String +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following code example shows how to specify your SOCKS5 proxy settings in +your connection string: + +.. code-block:: java + :emphasize-lines: 2-5 + + String connectionString = "mongodb+srv://myDatabaseUser:myPassword@example.org/" + + "?proxyHost=" + + "&proxyPort=" + + "&proxyUsername=" + + "&proxyPassword="; + + MongoClient mongoClient = MongoClients.create(connectionString); + +API Documentation +~~~~~~~~~~~~~~~~~ + +To learn more about the methods and types discussed in this guide, see the +following API documentation: + +- `MongoClientSettings.Builder <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html>`__ +- `SocketSettings.Builder <{+api+}/apidocs/mongodb-driver-core/com/mongodb/connection/SocketSettings.Builder.html>`__ +- `MongoClients.create() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoClients.html#create(com.mongodb.MongoClientSettings)>`__ + +.. TODO + - provide the link for the proxysettings builder once the API docs are generated: + - `ProxySettings.Builder <{+api+}/apidocs/mongodb-driver-core/com/mongodb/connection/ProxySettings.Builder.html>`__ From a3e5a70fe765a37cbd1f0d39cdddb87761c968c4 Mon Sep 17 00:00:00 2001 From: Chris Cho Date: Tue, 26 Sep 2023 11:02:12 -0400 Subject: [PATCH 05/19] DOCSP-33300: Fix aggregation operator links to the manual (#448) --- source/fundamentals/aggregation-expression-operations.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/fundamentals/aggregation-expression-operations.txt b/source/fundamentals/aggregation-expression-operations.txt index f762d0e6f..4e4f06950 100644 --- a/source/fundamentals/aggregation-expression-operations.txt +++ b/source/fundamentals/aggregation-expression-operations.txt @@ -311,13 +311,13 @@ using the methods described in this section. - :manual:`$filter ` * - `first() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/mql/MqlArray.html#first()>`__ - - :manual:`$first ` + - :manual:`$first ` * - `joinStrings() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/mql/MqlArray.html#joinStrings(java.util.function.Function)>`__ - :manual:`$concat ` * - `last() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/mql/MqlArray.html#last()>`__ - - :manual:`$last ` + - :manual:`$last ` * - `map() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/mql/MqlArray.html#map(java.util.function.Function)>`__ - :manual:`$map ` From 2b26b204a51ba57b52b1b12ba4f052e04fa1bafa Mon Sep 17 00:00:00 2001 From: kyuan-mongodb <78768401+kyuan-mongodb@users.noreply.github.com> Date: Tue, 26 Sep 2023 13:51:51 -0400 Subject: [PATCH 06/19] DOCSP-32300 Adds compatibility info to landing page (#449) --- source/includes/fact-environments.rst | 7 +++++++ source/index.txt | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 source/includes/fact-environments.rst diff --git a/source/includes/fact-environments.rst b/source/includes/fact-environments.rst new file mode 100644 index 000000000..0cae4338e --- /dev/null +++ b/source/includes/fact-environments.rst @@ -0,0 +1,7 @@ +- `MongoDB Atlas + `__: The fully + managed service for MongoDB deployments in the cloud +- :ref:`MongoDB Enterprise `: The + subscription-based, self-managed version of MongoDB +- :ref:`MongoDB Community `: The + source-available, free-to-use, and self-managed version of MongoDB diff --git a/source/index.txt b/source/index.txt index 5665ef15c..e195d642d 100644 --- a/source/index.txt +++ b/source/index.txt @@ -46,6 +46,13 @@ If your Java application requires asynchronous stream processing, use the :driver:`Reactive Streams Driver ` which uses Reactive Streams to make non-blocking calls to MongoDB. +Compatibility +------------- + +You can use the {+driver-short+} to connect to deployments hosted in the +following environments: + +.. include:: /includes/fact-environments.rst Quick Start ----------- From 1769d63d889f83bc7acb90d7f4dd0add34be7b6a Mon Sep 17 00:00:00 2001 From: Jordan Smith <45415425+jordan-smith721@users.noreply.github.com> Date: Thu, 28 Sep 2023 10:52:47 -0700 Subject: [PATCH 07/19] DOCSP-31907 Split Event (#457) --- .../crud/read-operations/change-streams.txt | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/source/fundamentals/crud/read-operations/change-streams.txt b/source/fundamentals/crud/read-operations/change-streams.txt index 8c714419d..7f455de99 100644 --- a/source/fundamentals/crud/read-operations/change-streams.txt +++ b/source/fundamentals/crud/read-operations/change-streams.txt @@ -137,6 +137,53 @@ An update operation on the collection produces the following output: ... } +Split Large Change Stream Events +-------------------------------- + +Starting in MongoDB 7.0, you can use the ``$changeStreamSplitLargeEvent`` +aggregation stage to split events that exceed 16 MB into smaller fragments. +The $changeStreamSplitLargeEvent stage returns the fragments sequentially. You can +access the fragments by using a change stream cursor. Each fragment +includes a ``SplitEvent`` object containing the following fields: + +.. list-table:: + :header-rows: 1 + :widths: 35 65 + + * - Field + - Description + + * - ``fragment`` + - The index of the fragment, starting at ``1`` + + * - ``of`` + - The total number of fragments that compose the split event + +The following example modifies your change stream by using the +``$changeStreamSplitLargeEvent`` aggregation stage to split large events: + +.. code-block:: java + + ChangeStreamIterable changeStream = collection.watch( + Arrays.asList(Document.parse("{ $changeStreamSplitLargeEvent: {} }"))); + +.. note:: + + You can have only one ``$changeStreamSplitLargeEvent`` stage in your + aggregation pipeline, and it must be the last stage in the pipeline. + +You can call the ``getSplitEvent()`` method on your change stream cursor to access +the ``SplitEvent`` as shown in the following example: + +.. code-block:: java + + MongoChangeStreamCursor> cursor = changeStream.cursor(); + SplitEvent event = cursor.tryNext().getSplitEvent(); + +For more information on the ``$changeStreamSplitLargeEvent`` aggregation stage, +see the :manual:`$changeStreamSplitLargeEvent +` server documentation. + .. _java-change-stream-configure-pre-post: Include Pre-images and Post-images @@ -287,4 +334,4 @@ output: } For a list of options, see the `FullDocument <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/changestream/FullDocument.html>`__ -API documentation. +API documentation. \ No newline at end of file From 82fd2e001ee5a2b865bec4e10817350844befda8 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 29 Sep 2023 11:46:07 -0400 Subject: [PATCH 08/19] tech review feedback --- source/whats-new.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 8bce9c816..7c39a0cd7 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -79,12 +79,12 @@ What's New in 4.11 - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ methods ``getSocketAddress()`` and ``getSocketAddresses()``. - Instead of ``getSocketAddress()``, use the ``getAddress()`` method from the - ``InetSocketAddress`` class. Instead of ``getSocketAddresses()``, use the + Instead of ``getSocketAddress()``, use the ``getByName()`` method from the + ``InetAddress`` class. Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method from the ``InetAddress`` class. - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ - method ``getUnixSocketAddress()``. Instead of ``getUnixSocketAddress()``, call - ``of()`` on a ``UnixDomainSocketAddress`` instance and pass a path name as an + method ``getUnixSocketAddress()``. Instead of ``getUnixSocketAddress()``, use + the ``UnixDomainSocketAddress`` constuctor and pass a ``String`` path name as an argument. .. _version-4.10: From 67386093a3a47265a10383a2a22d989621427da6 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 29 Sep 2023 11:57:38 -0400 Subject: [PATCH 09/19] format --- source/whats-new.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 7c39a0cd7..ca1d99868 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -79,13 +79,18 @@ What's New in 4.11 - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ methods ``getSocketAddress()`` and ``getSocketAddresses()``. + Instead of ``getSocketAddress()``, use the ``getByName()`` method from the - ``InetAddress`` class. Instead of ``getSocketAddresses()``, use the - ``getAllByName()`` method from the ``InetAddress`` class. + ``InetAddress`` class. + + Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method from + the ``InetAddress`` class. + - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ - method ``getUnixSocketAddress()``. Instead of ``getUnixSocketAddress()``, use - the ``UnixDomainSocketAddress`` constuctor and pass a ``String`` path name as an - argument. + method ``getUnixSocketAddress()``. + + Instead of ``getUnixSocketAddress()``, use the ``UnixSocketAddress`` constructor + and pass a ``String`` path name as an argument. .. _version-4.10: From a788a164392df702f9a9fdf916f719557c6ab0f4 Mon Sep 17 00:00:00 2001 From: norareidy Date: Mon, 2 Oct 2023 17:59:54 -0400 Subject: [PATCH 10/19] CC feedback --- source/whats-new.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index ca1d99868..2ddcdae74 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -80,17 +80,21 @@ What's New in 4.11 - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ methods ``getSocketAddress()`` and ``getSocketAddresses()``. - Instead of ``getSocketAddress()``, use the ``getByName()`` method from the - ``InetAddress`` class. + Instead of ``getSocketAddress()``, use the ``getByName()`` method. + ``getByName()`` is an instance method of the ``InetAddress`` class in the + ``java.net`` package. - Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method from - the ``InetAddress`` class. + Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method. + ``getAllByName()`` is an instance method of the ``InetAddress`` class in + the ``java.net`` package. - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ method ``getUnixSocketAddress()``. - Instead of ``getUnixSocketAddress()``, use the ``UnixSocketAddress`` constructor - and pass a ``String`` path name as an argument. + Instead of ``getUnixSocketAddress()``, use the constructor for the ``UnixSocketAddress`` + class in the ``jnr.unixsocket`` package. Pass the file-system path name of the + UNIX socket file, as a ``String``, to the ``UnixSocketAddress`` constructor. By default, + MongoDB creates a UNIX socket file located at ``"/tmp/mongodb-27017.sock"``. .. _version-4.10: From 1fada497a70fd3aa5be5d42c1486543cae001d0f Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 3 Oct 2023 12:05:45 -0400 Subject: [PATCH 11/19] CC feedback pt 2 --- source/whats-new.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 2ddcdae74..efb4d9aeb 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -80,21 +80,21 @@ What's New in 4.11 - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ methods ``getSocketAddress()`` and ``getSocketAddresses()``. - Instead of ``getSocketAddress()``, use the ``getByName()`` method. - ``getByName()`` is an instance method of the ``InetAddress`` class in the - ``java.net`` package. + Instead of ``getSocketAddress()``, use the ``getByName()`` instance + method of ``java.net.InetAddress``. - Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method. - ``getAllByName()`` is an instance method of the ``InetAddress`` class in - the ``java.net`` package. + Instead of ``getSocketAddresses()``, use the ``getAllByName()`` instance + method of ``java.net.InetAddress``. - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ method ``getUnixSocketAddress()``. - Instead of ``getUnixSocketAddress()``, use the constructor for the ``UnixSocketAddress`` - class in the ``jnr.unixsocket`` package. Pass the file-system path name of the - UNIX socket file, as a ``String``, to the ``UnixSocketAddress`` constructor. By default, - MongoDB creates a UNIX socket file located at ``"/tmp/mongodb-27017.sock"``. + Instead of ``getUnixSocketAddress()``, construct an instance of + ``jnr.unixsocket.UnixSocketAddress``. Pass the full path of the UNIX + socket file to the constructor. By default, MongoDB creates a UNIX + socket file located at ``"/tmp/mongodb-27017.sock"``. To learn more + about the ``UnixSocketAddress``, see the `UnixSocketAddress API documentation + `__. .. _version-4.10: From 6cf312f5459ffa18a06336f529c34e04e0d3429a Mon Sep 17 00:00:00 2001 From: Jordan Smith <45415425+jordan-smith721@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:39:10 -0700 Subject: [PATCH 12/19] DOCSP-31907 - Add paragraph from server docs (#460) --- source/fundamentals/crud/read-operations/change-streams.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/fundamentals/crud/read-operations/change-streams.txt b/source/fundamentals/crud/read-operations/change-streams.txt index 7f455de99..f6220b937 100644 --- a/source/fundamentals/crud/read-operations/change-streams.txt +++ b/source/fundamentals/crud/read-operations/change-streams.txt @@ -142,6 +142,11 @@ Split Large Change Stream Events Starting in MongoDB 7.0, you can use the ``$changeStreamSplitLargeEvent`` aggregation stage to split events that exceed 16 MB into smaller fragments. + +Use ``$changeStreamSplitLargeEvent`` only when strictly necessary. For +example, use ``$changeStreamSplitLargeEvent`` if your application requires full +document pre- or post-images, and generates events that exceed 16 MB. + The $changeStreamSplitLargeEvent stage returns the fragments sequentially. You can access the fragments by using a change stream cursor. Each fragment includes a ``SplitEvent`` object containing the following fields: From 7063d3c56c5a7c2c277bdb77e2e8a6c3b2b4f41a Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 22 Sep 2023 13:55:09 -0400 Subject: [PATCH 13/19] DOCSP-32942: Deprecated Methods --- source/whats-new.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/whats-new.txt b/source/whats-new.txt index 9e85138e2..d8effce56 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -74,6 +74,18 @@ What's New in 4.11 .. New features of the 4.11 driver release include: +- The following network address-related methods are deprecated and will be removed + in v5.0: + + - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ + methods ``getSocketAddress()`` and ``getSocketAddresses()``. + Instead of ``getSocketAddress()``, use the ``getAddress()`` method from the + ``InetSocketAddress`` class. Instead of ``getSocketAddresses()``, use the + ``getAllByName()`` method from the ``InetAddress`` class. + - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ + method ``getUnixSocketAddress()``. Instead, call ``of()`` on a ``UnixDomainSocketAddress`` + instance and pass a path name as an argument. + .. _version-4.10: What's New in 4.10 From 014079188a3f0871324aacc91ba2bf77b4e773fa Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 22 Sep 2023 16:41:26 -0400 Subject: [PATCH 14/19] review feedback --- source/whats-new.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index d8effce56..8bce9c816 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -83,8 +83,9 @@ What's New in 4.11 ``InetSocketAddress`` class. Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method from the ``InetAddress`` class. - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ - method ``getUnixSocketAddress()``. Instead, call ``of()`` on a ``UnixDomainSocketAddress`` - instance and pass a path name as an argument. + method ``getUnixSocketAddress()``. Instead of ``getUnixSocketAddress()``, call + ``of()`` on a ``UnixDomainSocketAddress`` instance and pass a path name as an + argument. .. _version-4.10: From 5f50716deee19745998182698347d7be8f3eaea6 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 29 Sep 2023 11:46:07 -0400 Subject: [PATCH 15/19] tech review feedback --- source/whats-new.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 8bce9c816..7c39a0cd7 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -79,12 +79,12 @@ What's New in 4.11 - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ methods ``getSocketAddress()`` and ``getSocketAddresses()``. - Instead of ``getSocketAddress()``, use the ``getAddress()`` method from the - ``InetSocketAddress`` class. Instead of ``getSocketAddresses()``, use the + Instead of ``getSocketAddress()``, use the ``getByName()`` method from the + ``InetAddress`` class. Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method from the ``InetAddress`` class. - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ - method ``getUnixSocketAddress()``. Instead of ``getUnixSocketAddress()``, call - ``of()`` on a ``UnixDomainSocketAddress`` instance and pass a path name as an + method ``getUnixSocketAddress()``. Instead of ``getUnixSocketAddress()``, use + the ``UnixDomainSocketAddress`` constuctor and pass a ``String`` path name as an argument. .. _version-4.10: From bf3e9da8d2ba600e6bbbf15da59849216754add4 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 29 Sep 2023 11:57:38 -0400 Subject: [PATCH 16/19] format --- source/whats-new.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 7c39a0cd7..ca1d99868 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -79,13 +79,18 @@ What's New in 4.11 - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ methods ``getSocketAddress()`` and ``getSocketAddresses()``. + Instead of ``getSocketAddress()``, use the ``getByName()`` method from the - ``InetAddress`` class. Instead of ``getSocketAddresses()``, use the - ``getAllByName()`` method from the ``InetAddress`` class. + ``InetAddress`` class. + + Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method from + the ``InetAddress`` class. + - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ - method ``getUnixSocketAddress()``. Instead of ``getUnixSocketAddress()``, use - the ``UnixDomainSocketAddress`` constuctor and pass a ``String`` path name as an - argument. + method ``getUnixSocketAddress()``. + + Instead of ``getUnixSocketAddress()``, use the ``UnixSocketAddress`` constructor + and pass a ``String`` path name as an argument. .. _version-4.10: From 0dc558a90db2008da2d850b8226bb00b952c9dba Mon Sep 17 00:00:00 2001 From: norareidy Date: Mon, 2 Oct 2023 17:59:54 -0400 Subject: [PATCH 17/19] CC feedback --- source/whats-new.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index ca1d99868..2ddcdae74 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -80,17 +80,21 @@ What's New in 4.11 - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ methods ``getSocketAddress()`` and ``getSocketAddresses()``. - Instead of ``getSocketAddress()``, use the ``getByName()`` method from the - ``InetAddress`` class. + Instead of ``getSocketAddress()``, use the ``getByName()`` method. + ``getByName()`` is an instance method of the ``InetAddress`` class in the + ``java.net`` package. - Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method from - the ``InetAddress`` class. + Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method. + ``getAllByName()`` is an instance method of the ``InetAddress`` class in + the ``java.net`` package. - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ method ``getUnixSocketAddress()``. - Instead of ``getUnixSocketAddress()``, use the ``UnixSocketAddress`` constructor - and pass a ``String`` path name as an argument. + Instead of ``getUnixSocketAddress()``, use the constructor for the ``UnixSocketAddress`` + class in the ``jnr.unixsocket`` package. Pass the file-system path name of the + UNIX socket file, as a ``String``, to the ``UnixSocketAddress`` constructor. By default, + MongoDB creates a UNIX socket file located at ``"/tmp/mongodb-27017.sock"``. .. _version-4.10: From 780d71770ccbe62ab16ab27ec913e3d4de1aec05 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 3 Oct 2023 12:05:45 -0400 Subject: [PATCH 18/19] CC feedback pt 2 --- source/whats-new.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/whats-new.txt b/source/whats-new.txt index 2ddcdae74..efb4d9aeb 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -80,21 +80,21 @@ What's New in 4.11 - The `ServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/ServerAddress.html>`__ methods ``getSocketAddress()`` and ``getSocketAddresses()``. - Instead of ``getSocketAddress()``, use the ``getByName()`` method. - ``getByName()`` is an instance method of the ``InetAddress`` class in the - ``java.net`` package. + Instead of ``getSocketAddress()``, use the ``getByName()`` instance + method of ``java.net.InetAddress``. - Instead of ``getSocketAddresses()``, use the ``getAllByName()`` method. - ``getAllByName()`` is an instance method of the ``InetAddress`` class in - the ``java.net`` package. + Instead of ``getSocketAddresses()``, use the ``getAllByName()`` instance + method of ``java.net.InetAddress``. - The `UnixServerAddress <{+api+}/apidocs/mongodb-driver-core/com/mongodb/UnixServerAddress.html>`__ method ``getUnixSocketAddress()``. - Instead of ``getUnixSocketAddress()``, use the constructor for the ``UnixSocketAddress`` - class in the ``jnr.unixsocket`` package. Pass the file-system path name of the - UNIX socket file, as a ``String``, to the ``UnixSocketAddress`` constructor. By default, - MongoDB creates a UNIX socket file located at ``"/tmp/mongodb-27017.sock"``. + Instead of ``getUnixSocketAddress()``, construct an instance of + ``jnr.unixsocket.UnixSocketAddress``. Pass the full path of the UNIX + socket file to the constructor. By default, MongoDB creates a UNIX + socket file located at ``"/tmp/mongodb-27017.sock"``. To learn more + about the ``UnixSocketAddress``, see the `UnixSocketAddress API documentation + `__. .. _version-4.10: From 6144da15f14c9be43ef6517ee7d3d660c02e9d0c Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 4 Oct 2023 11:16:55 -0400 Subject: [PATCH 19/19] build