mongo 2.4.0.rc1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mongo/auth/cr/conversation.rb +1 -1
- data/lib/mongo/auth/ldap/conversation.rb +1 -1
- data/lib/mongo/auth/scram/conversation.rb +1 -1
- data/lib/mongo/auth/x509/conversation.rb +4 -2
- data/lib/mongo/client.rb +7 -4
- data/lib/mongo/cluster.rb +55 -5
- data/lib/mongo/cluster/app_metadata.rb +7 -1
- data/lib/mongo/cluster/topology.rb +7 -6
- data/lib/mongo/cluster/topology/replica_set.rb +48 -2
- data/lib/mongo/cluster/topology/sharded.rb +47 -1
- data/lib/mongo/cluster/topology/single.rb +55 -4
- data/lib/mongo/cluster/topology/unknown.rb +65 -9
- data/lib/mongo/error/invalid_server_preference.rb +3 -1
- data/lib/mongo/event.rb +8 -0
- data/lib/mongo/event/description_changed.rb +20 -2
- data/lib/mongo/event/member_discovered.rb +65 -0
- data/lib/mongo/event/primary_elected.rb +3 -1
- data/lib/mongo/event/standalone_discovered.rb +1 -1
- data/lib/mongo/monitoring.rb +41 -0
- data/lib/mongo/monitoring/event.rb +6 -0
- data/lib/mongo/monitoring/event/server_closed.rb +46 -0
- data/lib/mongo/monitoring/event/server_description_changed.rb +58 -0
- data/lib/mongo/monitoring/event/server_opening.rb +46 -0
- data/lib/mongo/monitoring/event/topology_changed.rb +46 -0
- data/lib/mongo/monitoring/event/topology_closed.rb +41 -0
- data/lib/mongo/monitoring/event/topology_opening.rb +41 -0
- data/lib/mongo/monitoring/publishable.rb +12 -0
- data/lib/mongo/monitoring/sdam_log_subscriber.rb +54 -0
- data/lib/mongo/monitoring/server_closed_log_subscriber.rb +30 -0
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/server_opening_log_subscriber.rb +30 -0
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +40 -0
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +30 -0
- data/lib/mongo/server.rb +6 -0
- data/lib/mongo/server/connection.rb +1 -1
- data/lib/mongo/server/description.rb +23 -3
- data/lib/mongo/server/description/inspector.rb +4 -2
- data/lib/mongo/server/description/inspector/description_changed.rb +2 -2
- data/lib/mongo/server/description/inspector/member_discovered.rb +59 -0
- data/lib/mongo/server/description/inspector/primary_elected.rb +2 -0
- data/lib/mongo/server_selector.rb +10 -5
- data/lib/mongo/server_selector/nearest.rb +1 -1
- data/lib/mongo/server_selector/primary_preferred.rb +1 -1
- data/lib/mongo/server_selector/secondary.rb +1 -1
- data/lib/mongo/server_selector/secondary_preferred.rb +1 -1
- data/lib/mongo/server_selector/selectable.rb +24 -12
- data/lib/mongo/uri.rb +1 -1
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -1
- data/spec/mongo/auth/cr_spec.rb +6 -1
- data/spec/mongo/auth/ldap_spec.rb +6 -1
- data/spec/mongo/auth/scram_spec.rb +6 -1
- data/spec/mongo/auth/x509/conversation_spec.rb +69 -0
- data/spec/mongo/auth/x509_spec.rb +9 -4
- data/spec/mongo/client_spec.rb +40 -2
- data/spec/mongo/cluster/topology/replica_set_spec.rb +218 -9
- data/spec/mongo/cluster/topology/sharded_spec.rb +17 -2
- data/spec/mongo/cluster/topology/single_spec.rb +19 -4
- data/spec/mongo/cluster/topology/unknown_spec.rb +19 -1
- data/spec/mongo/cluster/topology_spec.rb +11 -7
- data/spec/mongo/cluster_spec.rb +25 -7
- data/spec/mongo/max_staleness_spec.rb +40 -22
- data/spec/mongo/monitoring_spec.rb +2 -2
- data/spec/mongo/sdam_monitoring_spec.rb +60 -0
- data/spec/mongo/sdam_spec.rb +77 -0
- data/spec/mongo/server/connection_pool_spec.rb +6 -1
- data/spec/mongo/server/connection_spec.rb +6 -1
- data/spec/mongo/server/description_spec.rb +90 -1
- data/spec/mongo/server_selection_spec.rb +7 -6
- data/spec/mongo/server_selector/nearest_spec.rb +7 -7
- data/spec/mongo/server_selector/primary_preferred_spec.rb +7 -7
- data/spec/mongo/server_selector/primary_spec.rb +4 -4
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +6 -6
- data/spec/mongo/server_selector/secondary_spec.rb +6 -6
- data/spec/mongo/server_selector_spec.rb +8 -0
- data/spec/mongo/server_spec.rb +6 -1
- data/spec/mongo/uri_spec.rb +4 -4
- data/spec/spec_helper.rb +2 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +4 -4
- data/spec/support/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +15 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +1 -1
- data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Secondary.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +1 -1
- data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +23 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +4 -4
- data/spec/support/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +5 -5
- data/spec/support/max_staleness/ReplicaSetWithPrimary/{ShortHeartbeartShortMaxStaleness2.yml → LongHeartbeat.yml} +4 -4
- data/spec/support/max_staleness/ReplicaSetWithPrimary/{ShortHeartbeartShortMaxStaleness.yml → LongHeartbeat2.yml} +6 -10
- data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +3 -2
- data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +2 -2
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +2 -2
- data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +1 -1
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +3 -3
- data/spec/support/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +7 -11
- data/spec/support/max_staleness/Sharded/Incompatible.yml +4 -4
- data/spec/support/max_staleness/Sharded/SmallMaxStaleness.yml +10 -2
- data/spec/support/max_staleness/Single/Incompatible.yml +4 -4
- data/spec/support/max_staleness/Single/SmallMaxStaleness.yml +2 -2
- data/spec/support/max_staleness/Unknown/SmallMaxStaleness.yml +14 -0
- data/spec/support/sdam/rs/primary_mismatched_me.yml +2 -2
- data/spec/support/sdam/rs/secondary_mismatched_me.yml +2 -2
- data/spec/support/sdam_monitoring.rb +144 -0
- data/spec/support/sdam_monitoring/replica_set_with_no_primary.yml +112 -0
- data/spec/support/sdam_monitoring/replica_set_with_primary.yml +111 -0
- data/spec/support/sdam_monitoring/replica_set_with_removal.yml +106 -0
- data/spec/support/sdam_monitoring/required_replica_set.yml +84 -0
- data/spec/support/sdam_monitoring/standalone.yml +70 -0
- data/spec/support/server_discovery_and_monitoring.rb +34 -1
- data/spec/support/server_selection.rb +14 -11
- data/spec/support/shared/server_selector.rb +6 -0
- metadata +49 -13
- metadata.gz.sig +0 -0
- data/spec/mongo/server_discovery_and_monitoring_spec.rb +0 -115
|
@@ -16,3 +16,9 @@ require 'mongo/monitoring/event/secure'
|
|
|
16
16
|
require 'mongo/monitoring/event/command_started'
|
|
17
17
|
require 'mongo/monitoring/event/command_succeeded'
|
|
18
18
|
require 'mongo/monitoring/event/command_failed'
|
|
19
|
+
require 'mongo/monitoring/event/server_closed'
|
|
20
|
+
require 'mongo/monitoring/event/server_description_changed'
|
|
21
|
+
require 'mongo/monitoring/event/server_opening'
|
|
22
|
+
require 'mongo/monitoring/event/topology_changed'
|
|
23
|
+
require 'mongo/monitoring/event/topology_closed'
|
|
24
|
+
require 'mongo/monitoring/event/topology_opening'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
19
|
+
# Event fired when the server is closed.
|
|
20
|
+
#
|
|
21
|
+
# @since 2.4.0
|
|
22
|
+
class ServerClosed
|
|
23
|
+
|
|
24
|
+
# @return [ Address ] address The server address.
|
|
25
|
+
attr_reader :address
|
|
26
|
+
|
|
27
|
+
# @return [ Topology ] topology The topology.
|
|
28
|
+
attr_reader :topology
|
|
29
|
+
|
|
30
|
+
# Create the event.
|
|
31
|
+
#
|
|
32
|
+
# @example Create the event.
|
|
33
|
+
# ServerClosed.new(address)
|
|
34
|
+
#
|
|
35
|
+
# @param [ Address ] address The server address.
|
|
36
|
+
# @param [ Integer ] topology The topology.
|
|
37
|
+
#
|
|
38
|
+
# @since 2.4.0
|
|
39
|
+
def initialize(address, topology)
|
|
40
|
+
@address = address
|
|
41
|
+
@topology = topology
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
19
|
+
# Event fired when a server's description changes.
|
|
20
|
+
#
|
|
21
|
+
# @since 2.4.0
|
|
22
|
+
class ServerDescriptionChanged
|
|
23
|
+
|
|
24
|
+
# @return [ Address ] address The server address.
|
|
25
|
+
attr_reader :address
|
|
26
|
+
|
|
27
|
+
# @return [ Topology ] topology The topology.
|
|
28
|
+
attr_reader :topology
|
|
29
|
+
|
|
30
|
+
# @return [ Server::Description ] previous_description The previous server
|
|
31
|
+
# description.
|
|
32
|
+
attr_reader :previous_description
|
|
33
|
+
|
|
34
|
+
# @return [ Server::Description ] new_description The new server
|
|
35
|
+
# description.
|
|
36
|
+
attr_reader :new_description
|
|
37
|
+
|
|
38
|
+
# Create the event.
|
|
39
|
+
#
|
|
40
|
+
# @example Create the event.
|
|
41
|
+
# ServerDescriptionChanged.new(address, topology, previous, new)
|
|
42
|
+
#
|
|
43
|
+
# @param [ Address ] address The server address.
|
|
44
|
+
# @param [ Integer ] topology The topology.
|
|
45
|
+
# @param [ Server::Description ] previous_description The previous description.
|
|
46
|
+
# @param [ Server::Description ] new_description The new description.
|
|
47
|
+
#
|
|
48
|
+
# @since 2.4.0
|
|
49
|
+
def initialize(address, topology, previous_description, new_description)
|
|
50
|
+
@address = address
|
|
51
|
+
@topology = topology
|
|
52
|
+
@previous_description = previous_description
|
|
53
|
+
@new_description = new_description
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
19
|
+
# Event fired when the server is opening.
|
|
20
|
+
#
|
|
21
|
+
# @since 2.4.0
|
|
22
|
+
class ServerOpening
|
|
23
|
+
|
|
24
|
+
# @return [ Address ] address The server address.
|
|
25
|
+
attr_reader :address
|
|
26
|
+
|
|
27
|
+
# @return [ Topology ] topology The topology.
|
|
28
|
+
attr_reader :topology
|
|
29
|
+
|
|
30
|
+
# Create the event.
|
|
31
|
+
#
|
|
32
|
+
# @example Create the event.
|
|
33
|
+
# ServerOpening.new(address)
|
|
34
|
+
#
|
|
35
|
+
# @param [ Address ] address The server address.
|
|
36
|
+
# @param [ Integer ] topology The topology.
|
|
37
|
+
#
|
|
38
|
+
# @since 2.4.0
|
|
39
|
+
def initialize(address, topology)
|
|
40
|
+
@address = address
|
|
41
|
+
@topology = topology
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
19
|
+
# Event fired when the topology changes.
|
|
20
|
+
#
|
|
21
|
+
# @since 2.4.0
|
|
22
|
+
class TopologyChanged
|
|
23
|
+
|
|
24
|
+
# @return [ Cluster::Topology ] previous_topology The previous topology.
|
|
25
|
+
attr_reader :previous_topology
|
|
26
|
+
|
|
27
|
+
# @return [ Cluster::Topology ] new_topology The new topology.
|
|
28
|
+
attr_reader :new_topology
|
|
29
|
+
|
|
30
|
+
# Create the event.
|
|
31
|
+
#
|
|
32
|
+
# @example Create the event.
|
|
33
|
+
# TopologyChanged.new(previous, new)
|
|
34
|
+
#
|
|
35
|
+
# @param [ Cluster::Topology ] previous_topology The previous topology.
|
|
36
|
+
# @param [ Cluster::Topology ] new_topology The new topology.
|
|
37
|
+
#
|
|
38
|
+
# @since 2.4.0
|
|
39
|
+
def initialize(previous_topology, new_topology)
|
|
40
|
+
@previous_topology = previous_topology
|
|
41
|
+
@new_topology = new_topology
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
19
|
+
# Event fired when the topology closes.
|
|
20
|
+
#
|
|
21
|
+
# @since 2.4.0
|
|
22
|
+
class TopologyClosed
|
|
23
|
+
|
|
24
|
+
# @return [ Topology ] topology The topology.
|
|
25
|
+
attr_reader :topology
|
|
26
|
+
|
|
27
|
+
# Create the event.
|
|
28
|
+
#
|
|
29
|
+
# @example Create the event.
|
|
30
|
+
# TopologyClosed.new(topology)
|
|
31
|
+
#
|
|
32
|
+
# @param [ Integer ] topology The topology.
|
|
33
|
+
#
|
|
34
|
+
# @since 2.4.0
|
|
35
|
+
def initialize(topology)
|
|
36
|
+
@topology = topology
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
19
|
+
# Event fired when the topology is opening.
|
|
20
|
+
#
|
|
21
|
+
# @since 2.4.0
|
|
22
|
+
class TopologyOpening
|
|
23
|
+
|
|
24
|
+
# @return [ Topology ] topology The topology.
|
|
25
|
+
attr_reader :topology
|
|
26
|
+
|
|
27
|
+
# Create the event.
|
|
28
|
+
#
|
|
29
|
+
# @example Create the event.
|
|
30
|
+
# TopologyOpening.new(topology)
|
|
31
|
+
#
|
|
32
|
+
# @param [ Integer ] topology The topology.
|
|
33
|
+
#
|
|
34
|
+
# @since 2.4.0
|
|
35
|
+
def initialize(topology)
|
|
36
|
+
@topology = topology
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -55,6 +55,14 @@ module Mongo
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
def publish_event(topic, event)
|
|
59
|
+
monitoring.succeeded(topic, event)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def publish_sdam_event(topic, event)
|
|
63
|
+
monitoring.succeeded(topic, event) if monitoring?
|
|
64
|
+
end
|
|
65
|
+
|
|
58
66
|
private
|
|
59
67
|
|
|
60
68
|
def command_started(address, operation_id, payload)
|
|
@@ -101,6 +109,10 @@ module Mongo
|
|
|
101
109
|
def error?(document)
|
|
102
110
|
document && (document['ok'] == 0 || document.key?('$err'))
|
|
103
111
|
end
|
|
112
|
+
|
|
113
|
+
def monitoring?
|
|
114
|
+
options[:monitoring] != false
|
|
115
|
+
end
|
|
104
116
|
end
|
|
105
117
|
end
|
|
106
118
|
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
18
|
+
# Subscribes to SDAM events and logs them.
|
|
19
|
+
#
|
|
20
|
+
# @since 2.4.0
|
|
21
|
+
class SDAMLogSubscriber
|
|
22
|
+
include Loggable
|
|
23
|
+
|
|
24
|
+
# @return [ Hash ] options The options.
|
|
25
|
+
attr_reader :options
|
|
26
|
+
|
|
27
|
+
# Create the new log subscriber.
|
|
28
|
+
#
|
|
29
|
+
# @example Create the log subscriber.
|
|
30
|
+
# SDAMLogSubscriber.new
|
|
31
|
+
#
|
|
32
|
+
# @param [ Hash ] options The options.
|
|
33
|
+
#
|
|
34
|
+
# @option options [ Logger ] :logger An optional custom logger.
|
|
35
|
+
#
|
|
36
|
+
# @since 2.4.0
|
|
37
|
+
def initialize(options = {})
|
|
38
|
+
@options = options
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Handle the SDAM succeeded event.
|
|
42
|
+
#
|
|
43
|
+
# @example Handle the event.
|
|
44
|
+
# subscriber.succeeded(event)
|
|
45
|
+
#
|
|
46
|
+
# @param [ Event ] event The event.
|
|
47
|
+
#
|
|
48
|
+
# @since 2.4.0
|
|
49
|
+
def succeeded(event)
|
|
50
|
+
log_event(event) if logger.debug?
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
18
|
+
# Subscribes to Server Closed events and logs them.
|
|
19
|
+
#
|
|
20
|
+
# @since 2.4.0
|
|
21
|
+
class ServerClosedLogSubscriber < SDAMLogSubscriber
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def log_event(event)
|
|
26
|
+
log_debug("Server #{event.address} connection closed.")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
18
|
+
# Subscribes to Server Description Changed events and logs them.
|
|
19
|
+
#
|
|
20
|
+
# @since 2.4.0
|
|
21
|
+
class ServerDescriptionChangedLogSubscriber < SDAMLogSubscriber
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def log_event(event)
|
|
26
|
+
log_debug(
|
|
27
|
+
"Server description for #{event.address} changed from " +
|
|
28
|
+
"'#{event.previous_description.server_type}' to '#{event.new_description.server_type}'."
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (C) 2016 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
|
+
|
|
18
|
+
# Subscribes to Server Opening events and logs them.
|
|
19
|
+
#
|
|
20
|
+
# @since 2.4.0
|
|
21
|
+
class ServerOpeningLogSubscriber < SDAMLogSubscriber
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def log_event(event)
|
|
26
|
+
log_debug("Server #{event.address} initializing.")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|