mongo 2.8.0 → 2.9.0.rc0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Rakefile +12 -0
- data/lib/mongo.rb +15 -1
- data/lib/mongo/address/ipv6.rb +0 -2
- data/lib/mongo/auth/scram/conversation.rb +0 -3
- data/lib/mongo/bulk_write/result_combiner.rb +12 -2
- data/lib/mongo/client.rb +59 -6
- data/lib/mongo/cluster.rb +19 -8
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +0 -2
- data/lib/mongo/cluster/reapers/socket_reaper.rb +12 -9
- data/lib/mongo/collection.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +5 -1
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +30 -10
- data/lib/mongo/collection/view/iterable.rb +13 -6
- data/lib/mongo/collection/view/map_reduce.rb +12 -10
- data/lib/mongo/collection/view/readable.rb +19 -14
- data/lib/mongo/cursor.rb +12 -8
- data/lib/mongo/database.rb +10 -7
- data/lib/mongo/database/view.rb +18 -11
- data/lib/mongo/error.rb +2 -2
- data/lib/mongo/error/connection_check_out_timeout.rb +49 -0
- data/lib/mongo/error/operation_failure.rb +9 -9
- data/lib/mongo/error/parser.rb +25 -3
- data/lib/mongo/error/pool_closed_error.rb +43 -0
- data/lib/mongo/error/sdam_error_detection.rb +18 -0
- data/lib/mongo/grid/file/chunk.rb +0 -2
- data/lib/mongo/grid/fs_bucket.rb +26 -12
- data/lib/mongo/grid/stream/read.rb +36 -21
- data/lib/mongo/index/view.rb +11 -7
- data/lib/mongo/logger.rb +0 -2
- data/lib/mongo/monitoring.rb +31 -0
- data/lib/mongo/monitoring/cmap_log_subscriber.rb +53 -0
- data/lib/mongo/monitoring/event.rb +1 -0
- data/lib/mongo/monitoring/event/cmap.rb +25 -0
- data/lib/mongo/monitoring/event/cmap/base.rb +28 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +78 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +56 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +63 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/connection_closed.rb +103 -0
- data/lib/mongo/monitoring/event/cmap/connection_created.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/connection_ready.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +57 -0
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +57 -0
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +63 -0
- data/lib/mongo/monitoring/event/command_started.rb +12 -3
- data/lib/mongo/monitoring/publishable.rb +10 -2
- data/lib/mongo/operation.rb +0 -1
- data/lib/mongo/operation/find/legacy/result.rb +1 -0
- data/lib/mongo/operation/list_collections/result.rb +7 -1
- data/lib/mongo/operation/result.rb +10 -1
- data/lib/mongo/operation/shared/executable.rb +15 -0
- data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +29 -0
- data/lib/mongo/operation/shared/specifiable.rb +0 -16
- data/lib/mongo/operation/update/legacy/result.rb +1 -0
- data/lib/mongo/protocol/compressed.rb +0 -2
- data/lib/mongo/protocol/msg.rb +25 -2
- data/lib/mongo/retryable.rb +171 -33
- data/lib/mongo/server.rb +26 -7
- data/lib/mongo/server/app_metadata.rb +0 -2
- data/lib/mongo/server/connectable.rb +8 -2
- data/lib/mongo/server/connection.rb +83 -13
- data/lib/mongo/server/connection_base.rb +1 -1
- data/lib/mongo/server/connection_pool.rb +439 -43
- data/lib/mongo/server/monitor/connection.rb +4 -1
- data/lib/mongo/session.rb +37 -5
- data/lib/mongo/session/session_pool.rb +2 -2
- data/lib/mongo/socket.rb +0 -2
- data/lib/mongo/socket/ssl.rb +0 -2
- data/lib/mongo/uri.rb +127 -66
- data/lib/mongo/uri/srv_protocol.rb +35 -13
- data/lib/mongo/version.rb +1 -1
- data/spec/README.md +190 -63
- data/spec/integration/change_stream_spec.rb +64 -0
- data/spec/integration/command_spec.rb +0 -7
- data/spec/integration/error_detection_spec.rb +39 -0
- data/spec/integration/read_concern.rb +83 -0
- data/spec/integration/retryable_writes_spec.rb +6 -50
- data/spec/integration/sdam_error_handling_spec.rb +60 -7
- data/spec/integration/ssl_uri_options_spec.rb +24 -0
- data/spec/integration/step_down_spec.rb +197 -0
- data/spec/lite_spec_helper.rb +4 -0
- data/spec/mongo/client_construction_spec.rb +42 -17
- data/spec/mongo/client_spec.rb +32 -1
- data/spec/mongo/cluster/socket_reaper_spec.rb +2 -2
- data/spec/mongo/cluster_spec.rb +36 -2
- data/spec/mongo/collection/view/aggregation_spec.rb +2 -0
- data/spec/mongo/collection/view/change_stream_spec.rb +28 -28
- data/spec/mongo/collection/view/readable_spec.rb +1 -1
- data/spec/mongo/collection/view_spec.rb +3 -1
- data/spec/mongo/cursor_spec.rb +5 -5
- data/spec/mongo/error/parser_spec.rb +61 -1
- data/spec/mongo/grid/stream/read_spec.rb +2 -2
- data/spec/mongo/monitoring/event/cmap/connection_check_out_failed_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_started_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_closed_spec.rb +27 -0
- data/spec/mongo/monitoring/event/cmap/connection_created_spec.rb +24 -0
- data/spec/mongo/monitoring/event/cmap/connection_ready_spec.rb +24 -0
- data/spec/mongo/monitoring/event/cmap/pool_cleared_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +26 -0
- data/spec/mongo/operation/delete/bulk_spec.rb +1 -6
- data/spec/mongo/operation/delete/command_spec.rb +1 -1
- data/spec/mongo/operation/delete/op_msg_spec.rb +1 -1
- data/spec/mongo/operation/delete_spec.rb +4 -4
- data/spec/mongo/operation/insert/bulk_spec.rb +1 -1
- data/spec/mongo/operation/insert/command_spec.rb +1 -1
- data/spec/mongo/operation/insert/op_msg_spec.rb +1 -1
- data/spec/mongo/operation/update/bulk_spec.rb +1 -1
- data/spec/mongo/operation/update/command_spec.rb +2 -2
- data/spec/mongo/operation/update/op_msg_spec.rb +2 -2
- data/spec/mongo/protocol/msg_spec.rb +11 -0
- data/spec/mongo/retryable_spec.rb +78 -25
- data/spec/mongo/server/connection_pool_spec.rb +661 -126
- data/spec/mongo/server/connection_spec.rb +55 -7
- data/spec/mongo/server_spec.rb +5 -0
- data/spec/mongo/uri/srv_protocol_spec.rb +135 -2
- data/spec/mongo/uri_option_parsing_spec.rb +511 -0
- data/spec/mongo/uri_spec.rb +42 -6
- data/spec/spec_helper.rb +1 -84
- data/spec/spec_tests/cmap_spec.rb +50 -0
- data/spec/spec_tests/command_monitoring_spec.rb +7 -18
- data/spec/spec_tests/crud_spec.rb +3 -49
- data/spec/spec_tests/data/cmap/connection-must-have-id.yml +21 -0
- data/spec/spec_tests/data/cmap/connection-must-order-ids.yml +21 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-closed.yml +24 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-stale.yml +24 -0
- data/spec/spec_tests/data/cmap/pool-checkin-make-available.yml +21 -0
- data/spec/spec_tests/data/cmap/pool-checkin.yml +18 -0
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +13 -0
- data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +28 -0
- data/spec/spec_tests/data/cmap/pool-checkout-multiple.yml +34 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-idle.yml +31 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-stale.yml +29 -0
- data/spec/spec_tests/data/cmap/pool-close-destroy-conns.yml +26 -0
- data/spec/spec_tests/data/cmap/pool-close.yml +11 -0
- data/spec/spec_tests/data/cmap/pool-create-max-size.yml +56 -0
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-create-with-options.yml +20 -0
- data/spec/spec_tests/data/cmap/pool-create.yml +12 -0
- data/spec/spec_tests/data/cmap/wait-queue-fairness.yml +94 -0
- data/spec/spec_tests/data/cmap/wait-queue-timeout.yml +41 -0
- data/spec/spec_tests/data/retryable_reads/aggregate-serverErrors.yml +157 -0
- data/spec/spec_tests/data/retryable_reads/aggregate.yml +87 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +149 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +61 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +149 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +65 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +153 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +61 -0
- data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/count.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +156 -0
- data/spec/spec_tests/data/retryable_reads/distinct.yml +71 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors.yml +148 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount.yml +62 -0
- data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +160 -0
- data/spec/spec_tests/data/retryable_reads/find.yml +86 -0
- data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +154 -0
- data/spec/spec_tests/data/retryable_reads/findOne.yml +68 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +173 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +174 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollections.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +145 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/mapReduce.yml +60 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite-serverErrors.yml +10 -7
- data/spec/spec_tests/data/retryable_writes/bulkWrite.yml +15 -22
- data/spec/spec_tests/data/retryable_writes/deleteMany.yml +22 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/deleteOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/insertMany-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/insertMany.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +10 -45
- data/spec/spec_tests/data/retryable_writes/insertOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/replaceOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/replaceOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/updateMany.yml +27 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/updateOne.yml +5 -14
- data/spec/spec_tests/data/transactions/abort.yml +7 -2
- data/spec/spec_tests/data/transactions/bulk.yml +7 -2
- data/spec/spec_tests/data/transactions/causal-consistency.yml +11 -4
- data/spec/spec_tests/data/transactions/commit.yml +11 -4
- data/spec/spec_tests/data/transactions/count.yml +64 -0
- data/spec/spec_tests/data/transactions/delete.yml +7 -2
- data/spec/spec_tests/data/transactions/error-labels.yml +8 -2
- data/spec/spec_tests/data/transactions/errors.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndDelete.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndReplace.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +7 -2
- data/spec/spec_tests/data/transactions/insert.yml +9 -2
- data/spec/spec_tests/data/transactions/isolation.yml +7 -2
- data/spec/spec_tests/data/transactions/read-concern.yml +15 -6
- data/spec/spec_tests/data/transactions/read-pref.yml +7 -2
- data/spec/spec_tests/data/transactions/reads.yml +8 -48
- data/spec/spec_tests/data/transactions/retryable-abort.yml +7 -2
- data/spec/spec_tests/data/transactions/retryable-commit.yml +7 -2
- data/spec/spec_tests/data/transactions/retryable-writes.yml +7 -2
- data/spec/spec_tests/data/transactions/run-command.yml +7 -2
- data/spec/spec_tests/data/transactions/transaction-options.yml +7 -2
- data/spec/spec_tests/data/transactions/update.yml +7 -2
- data/spec/spec_tests/data/transactions/write-concern.yml +7 -2
- data/spec/spec_tests/data/transactions_api/callback-aborts.yml +6 -1
- data/spec/spec_tests/data/transactions_api/callback-commits.yml +6 -1
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-retry.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +6 -3
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit.yml +6 -1
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +6 -1
- data/spec/spec_tests/retryable_reads_spec.rb +11 -0
- data/spec/spec_tests/retryable_writes_spec.rb +4 -69
- data/spec/spec_tests/transactions_api_spec.rb +42 -37
- data/spec/spec_tests/transactions_spec.rb +42 -33
- data/spec/support/authorization.rb +12 -0
- data/spec/support/change_streams/operation.rb +1 -1
- data/spec/support/client_registry.rb +20 -0
- data/spec/support/cluster_config.rb +16 -15
- data/spec/support/cluster_tools.rb +346 -0
- data/spec/support/cmap.rb +367 -0
- data/spec/support/cmap/verifier.rb +46 -0
- data/spec/support/command_monitoring.rb +4 -6
- data/spec/support/common_shortcuts.rb +6 -0
- data/spec/support/connection_string.rb +2 -2
- data/spec/support/crud.rb +171 -184
- data/spec/support/crud/operation.rb +43 -0
- data/spec/support/crud/outcome.rb +53 -0
- data/spec/support/crud/read.rb +102 -12
- data/spec/support/crud/requirement.rb +69 -0
- data/spec/support/crud/spec.rb +68 -0
- data/spec/support/crud/test.rb +141 -0
- data/spec/support/crud/verifier.rb +96 -18
- data/spec/support/crud/write.rb +18 -3
- data/spec/support/event_subscriber.rb +15 -0
- data/spec/support/primary_socket.rb +2 -2
- data/spec/support/spec_config.rb +89 -20
- data/spec/support/transactions.rb +2 -306
- data/spec/support/transactions/operation.rb +7 -7
- data/spec/support/transactions/spec.rb +28 -0
- data/spec/support/transactions/test.rb +191 -0
- data/spec/support/utils.rb +123 -0
- metadata +202 -9
- metadata.gz.sig +0 -0
- data/lib/mongo/server/connection_pool/queue.rb +0 -359
- data/spec/mongo/server/connection_pool/queue_spec.rb +0 -353
- data/spec/support/transactions/verifier.rb +0 -97
@@ -0,0 +1,64 @@
|
|
1
|
+
# Copyright (C) 2019 MongoDB, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
class Monitoring
|
17
|
+
module Event
|
18
|
+
module Cmap
|
19
|
+
|
20
|
+
# Event published when a connection is ready to be used for operations.
|
21
|
+
#
|
22
|
+
# @since 2.9.0
|
23
|
+
class ConnectionReady < Base
|
24
|
+
|
25
|
+
# @return [ Mongo::Address ] address The address of the server the connection is connected
|
26
|
+
# to.
|
27
|
+
#
|
28
|
+
# @since 2.9.0
|
29
|
+
attr_reader :address
|
30
|
+
|
31
|
+
# @return [ Integer ] connection_id The ID of the connection.
|
32
|
+
#
|
33
|
+
# @since 2.9.0
|
34
|
+
attr_reader :connection_id
|
35
|
+
|
36
|
+
# Create the event.
|
37
|
+
#
|
38
|
+
# @example Create the event.
|
39
|
+
# ConnectionReady.new(address, id)
|
40
|
+
#
|
41
|
+
# @since 2.9.0
|
42
|
+
# @api private
|
43
|
+
def initialize(address, id)
|
44
|
+
@address = address
|
45
|
+
@connection_id = id
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns a concise yet useful summary of the event.
|
49
|
+
#
|
50
|
+
# @return [ String ] String summary of the event.
|
51
|
+
#
|
52
|
+
# @note This method is experimental and subject to change.
|
53
|
+
#
|
54
|
+
# @since 2.9.0
|
55
|
+
# @api experimental
|
56
|
+
def summary
|
57
|
+
"#<#{self.class.name.sub(/^Mongo::Monitoring::Event::Cmap::/, '')} " +
|
58
|
+
"address=#{address} connection_id=#{connection_id}>"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright (C) 2019 MongoDB, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
class Monitoring
|
17
|
+
module Event
|
18
|
+
module Cmap
|
19
|
+
|
20
|
+
# Event published when a connection pool is cleared.
|
21
|
+
#
|
22
|
+
# @since 2.9.0
|
23
|
+
class PoolCleared < Base
|
24
|
+
|
25
|
+
# @return [ Mongo::Address ] address The address of the server the pool's connections will
|
26
|
+
# connect to.
|
27
|
+
#
|
28
|
+
# @since 2.9.0
|
29
|
+
attr_reader :address
|
30
|
+
|
31
|
+
# Create the event.
|
32
|
+
#
|
33
|
+
# @example Create the event.
|
34
|
+
# PoolCleared.new(address)
|
35
|
+
#
|
36
|
+
# @since 2.9.0
|
37
|
+
# @api private
|
38
|
+
def initialize(address)
|
39
|
+
@address = address
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns a concise yet useful summary of the event.
|
43
|
+
#
|
44
|
+
# @return [ String ] String summary of the event.
|
45
|
+
#
|
46
|
+
# @note This method is experimental and subject to change.
|
47
|
+
#
|
48
|
+
# @since 2.9.0
|
49
|
+
# @api experimental
|
50
|
+
def summary
|
51
|
+
"#<#{self.class.name.sub(/^Mongo::Monitoring::Event::Cmap::/, '')} address=#{address}>"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright (C) 2019 MongoDB, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
class Monitoring
|
17
|
+
module Event
|
18
|
+
module Cmap
|
19
|
+
|
20
|
+
# Event published when a connection pool is closed.
|
21
|
+
#
|
22
|
+
# @since 2.9.0
|
23
|
+
class PoolClosed < Base
|
24
|
+
|
25
|
+
# @return [ Mongo::Address ] address The address of the server the pool's connections will
|
26
|
+
# connect to.
|
27
|
+
#
|
28
|
+
# @since 2.9.0
|
29
|
+
attr_reader :address
|
30
|
+
|
31
|
+
# Create the event.
|
32
|
+
#
|
33
|
+
# @example Create the event.
|
34
|
+
# PoolClosed.new(address)
|
35
|
+
#
|
36
|
+
# @since 2.9.0
|
37
|
+
# @api private
|
38
|
+
def initialize(address)
|
39
|
+
@address = address
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns a concise yet useful summary of the event.
|
43
|
+
#
|
44
|
+
# @return [ String ] String summary of the event.
|
45
|
+
#
|
46
|
+
# @note This method is experimental and subject to change.
|
47
|
+
#
|
48
|
+
# @since 2.9.0
|
49
|
+
# @api experimental
|
50
|
+
def summary
|
51
|
+
"#<#{self.class.name.sub(/^Mongo::Monitoring::Event::Cmap::/, '')} address=#{address}>"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright (C) 2019 MongoDB, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
class Monitoring
|
17
|
+
module Event
|
18
|
+
module Cmap
|
19
|
+
|
20
|
+
# Event published when a connection pool is created.
|
21
|
+
#
|
22
|
+
# @since 2.9.0
|
23
|
+
class PoolCreated < Base
|
24
|
+
|
25
|
+
# @return [ Mongo::Address ] address The address of the server the pool's connections will
|
26
|
+
# connect to.
|
27
|
+
#
|
28
|
+
# @since 2.9.0
|
29
|
+
attr_reader :address
|
30
|
+
|
31
|
+
# @return [ Hash ] options Options specified for pool creation.
|
32
|
+
#
|
33
|
+
# @since 2.9.0
|
34
|
+
attr_reader :options
|
35
|
+
|
36
|
+
# Create the event.
|
37
|
+
#
|
38
|
+
# @example Create the event.
|
39
|
+
# PoolCreated.new(address, options)
|
40
|
+
#
|
41
|
+
# @since 2.9.0
|
42
|
+
# @api private
|
43
|
+
def initialize(address, options)
|
44
|
+
@address = address
|
45
|
+
@options = options.dup.freeze
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns a concise yet useful summary of the event.
|
49
|
+
#
|
50
|
+
# @return [ String ] String summary of the event.
|
51
|
+
#
|
52
|
+
# @note This method is experimental and subject to change.
|
53
|
+
#
|
54
|
+
# @since 2.9.0
|
55
|
+
# @api experimental
|
56
|
+
def summary
|
57
|
+
"#<#{self.class.name.sub(/^Mongo::Monitoring::Event::Cmap::/, '')} address=#{address} options=#{options}>"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -40,6 +40,11 @@ module Mongo
|
|
40
40
|
# @return [ Integer ] request_id The request id.
|
41
41
|
attr_reader :request_id
|
42
42
|
|
43
|
+
# object_id of the socket object used for this command.
|
44
|
+
#
|
45
|
+
# @api private
|
46
|
+
attr_reader :socket_object_id
|
47
|
+
|
43
48
|
# Create the new event.
|
44
49
|
#
|
45
50
|
# @example Create the event.
|
@@ -53,13 +58,16 @@ module Mongo
|
|
53
58
|
#
|
54
59
|
# @since 2.1.0
|
55
60
|
# @api private
|
56
|
-
def initialize(command_name, database_name, address, request_id,
|
61
|
+
def initialize(command_name, database_name, address, request_id,
|
62
|
+
operation_id, command, socket_object_id = nil
|
63
|
+
)
|
57
64
|
@command_name = command_name.to_s
|
58
65
|
@database_name = database_name
|
59
66
|
@address = address
|
60
67
|
@request_id = request_id
|
61
68
|
@operation_id = operation_id
|
62
69
|
@command = redacted(command_name, command)
|
70
|
+
@socket_object_id = socket_object_id
|
63
71
|
end
|
64
72
|
|
65
73
|
# Create the event from a wire protocol message payload.
|
@@ -75,14 +83,15 @@ module Mongo
|
|
75
83
|
#
|
76
84
|
# @since 2.1.0
|
77
85
|
# @api private
|
78
|
-
def self.generate(address, operation_id, payload)
|
86
|
+
def self.generate(address, operation_id, payload, socket_object_id = nil)
|
79
87
|
new(
|
80
88
|
payload[:command_name],
|
81
89
|
payload[:database_name],
|
82
90
|
address,
|
83
91
|
payload[:request_id],
|
84
92
|
operation_id,
|
85
|
-
payload[:command]
|
93
|
+
payload[:command],
|
94
|
+
socket_object_id,
|
86
95
|
)
|
87
96
|
end
|
88
97
|
|
@@ -24,6 +24,7 @@ module Mongo
|
|
24
24
|
# @return [ Monitoring ] monitoring The monitoring.
|
25
25
|
attr_reader :monitoring
|
26
26
|
|
27
|
+
# @deprecated
|
27
28
|
def publish_event(topic, event)
|
28
29
|
monitoring.succeeded(topic, event)
|
29
30
|
end
|
@@ -35,12 +36,19 @@ module Mongo
|
|
35
36
|
monitoring.succeeded(topic, event)
|
36
37
|
end
|
37
38
|
|
39
|
+
def publish_cmap_event(event)
|
40
|
+
return unless monitoring?
|
41
|
+
|
42
|
+
monitoring.published(Monitoring::CONNECTION_POOL, event)
|
43
|
+
end
|
44
|
+
|
38
45
|
private
|
39
46
|
|
40
|
-
def command_started(address, operation_id, payload)
|
47
|
+
def command_started(address, operation_id, payload, socket_object_id = nil)
|
41
48
|
monitoring.started(
|
42
49
|
Monitoring::COMMAND,
|
43
|
-
Event::CommandStarted.generate(address, operation_id, payload
|
50
|
+
Event::CommandStarted.generate(address, operation_id, payload,
|
51
|
+
socket_object_id)
|
44
52
|
)
|
45
53
|
end
|
46
54
|
|
data/lib/mongo/operation.rb
CHANGED
@@ -77,7 +77,13 @@ module Mongo
|
|
77
77
|
if successful?
|
78
78
|
self
|
79
79
|
else
|
80
|
-
raise
|
80
|
+
raise Error::OperationFailure.new(
|
81
|
+
parser.message,
|
82
|
+
self,
|
83
|
+
code: parser.code,
|
84
|
+
code_name: parser.code_name,
|
85
|
+
labels: parser.labels,
|
86
|
+
wtimeout: parser.wtimeout)
|
81
87
|
end
|
82
88
|
end
|
83
89
|
|
@@ -13,6 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require 'mongo/operation/shared/result/aggregatable'
|
16
|
+
require 'mongo/operation/shared/result/use_legacy_error_parser'
|
16
17
|
|
17
18
|
module Mongo
|
18
19
|
module Operation
|
@@ -79,8 +80,9 @@ module Mongo
|
|
79
80
|
# @return [ Array<Protocol::Reply> ] replies The wrapped wire protocol replies.
|
80
81
|
attr_reader :replies
|
81
82
|
|
83
|
+
# @api private
|
82
84
|
def_delegators :parser,
|
83
|
-
:not_master?, :node_recovering?
|
85
|
+
:not_master?, :node_recovering?, :node_shutting_down?
|
84
86
|
|
85
87
|
# Is the result acknowledged?
|
86
88
|
#
|
@@ -330,6 +332,13 @@ module Mongo
|
|
330
332
|
@labels ||= parser.labels
|
331
333
|
end
|
332
334
|
|
335
|
+
# Whether the operation failed with a write concern error.
|
336
|
+
#
|
337
|
+
# @api private
|
338
|
+
def write_concern_error?
|
339
|
+
!!(first_document && first_document['writeConcernError'])
|
340
|
+
end
|
341
|
+
|
333
342
|
private
|
334
343
|
|
335
344
|
def aggregate_returned_count
|
@@ -45,10 +45,25 @@ module Mongo
|
|
45
45
|
|
46
46
|
def process_result(result, server)
|
47
47
|
server.update_cluster_time(result)
|
48
|
+
|
48
49
|
if result.not_master? || result.node_recovering?
|
50
|
+
if result.node_shutting_down?
|
51
|
+
disconnect_pool = true
|
52
|
+
else
|
53
|
+
# Max wire version needs to be checked prior to marking the
|
54
|
+
# server unknown
|
55
|
+
disconnect_pool = server.description.max_wire_version < 8
|
56
|
+
end
|
57
|
+
|
49
58
|
server.unknown!
|
59
|
+
|
60
|
+
if disconnect_pool
|
61
|
+
server.pool.disconnect!
|
62
|
+
end
|
63
|
+
|
50
64
|
server.monitor.scan_semaphore.signal
|
51
65
|
end
|
66
|
+
|
52
67
|
session.process(result) if session
|
53
68
|
result
|
54
69
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (C) 2019 MongoDB, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
module Operation
|
17
|
+
class Result
|
18
|
+
|
19
|
+
# This module creates the Parser instance in legacy mode.
|
20
|
+
#
|
21
|
+
# @api private
|
22
|
+
module UseLegacyErrorParser
|
23
|
+
def parser
|
24
|
+
@parser ||= Error::Parser.new(first_document, replies, legacy: true)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -101,11 +101,6 @@ module Mongo
|
|
101
101
|
# @since 2.0.0
|
102
102
|
SELECTOR = :selector.freeze
|
103
103
|
|
104
|
-
# The startTransaction option
|
105
|
-
#
|
106
|
-
# @since 2.6.0
|
107
|
-
START_TRANSACTION = :start_transaction.freeze
|
108
|
-
|
109
104
|
# The field for number to return.
|
110
105
|
#
|
111
106
|
# @since 2.0.0
|
@@ -558,17 +553,6 @@ module Mongo
|
|
558
553
|
selector[Operation::ARRAY_FILTERS] if selector
|
559
554
|
end
|
560
555
|
|
561
|
-
# The startTransaction option.
|
562
|
-
#
|
563
|
-
# @example Get the startTransaction option.
|
564
|
-
# specifiable.start_transaction
|
565
|
-
#
|
566
|
-
# @return [ Boolean ] The startTransaction option.
|
567
|
-
#
|
568
|
-
def start_transaction
|
569
|
-
@spec[START_TRANSACTION]
|
570
|
-
end
|
571
|
-
|
572
556
|
# Does the operation have an acknowledged write concern.
|
573
557
|
#
|
574
558
|
# @example Determine whether the operation has an acknowledged write.
|