mongo 2.4.0.rc1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongo/auth/cr/conversation.rb +1 -1
  5. data/lib/mongo/auth/ldap/conversation.rb +1 -1
  6. data/lib/mongo/auth/scram/conversation.rb +1 -1
  7. data/lib/mongo/auth/x509/conversation.rb +4 -2
  8. data/lib/mongo/client.rb +7 -4
  9. data/lib/mongo/cluster.rb +55 -5
  10. data/lib/mongo/cluster/app_metadata.rb +7 -1
  11. data/lib/mongo/cluster/topology.rb +7 -6
  12. data/lib/mongo/cluster/topology/replica_set.rb +48 -2
  13. data/lib/mongo/cluster/topology/sharded.rb +47 -1
  14. data/lib/mongo/cluster/topology/single.rb +55 -4
  15. data/lib/mongo/cluster/topology/unknown.rb +65 -9
  16. data/lib/mongo/error/invalid_server_preference.rb +3 -1
  17. data/lib/mongo/event.rb +8 -0
  18. data/lib/mongo/event/description_changed.rb +20 -2
  19. data/lib/mongo/event/member_discovered.rb +65 -0
  20. data/lib/mongo/event/primary_elected.rb +3 -1
  21. data/lib/mongo/event/standalone_discovered.rb +1 -1
  22. data/lib/mongo/monitoring.rb +41 -0
  23. data/lib/mongo/monitoring/event.rb +6 -0
  24. data/lib/mongo/monitoring/event/server_closed.rb +46 -0
  25. data/lib/mongo/monitoring/event/server_description_changed.rb +58 -0
  26. data/lib/mongo/monitoring/event/server_opening.rb +46 -0
  27. data/lib/mongo/monitoring/event/topology_changed.rb +46 -0
  28. data/lib/mongo/monitoring/event/topology_closed.rb +41 -0
  29. data/lib/mongo/monitoring/event/topology_opening.rb +41 -0
  30. data/lib/mongo/monitoring/publishable.rb +12 -0
  31. data/lib/mongo/monitoring/sdam_log_subscriber.rb +54 -0
  32. data/lib/mongo/monitoring/server_closed_log_subscriber.rb +30 -0
  33. data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +33 -0
  34. data/lib/mongo/monitoring/server_opening_log_subscriber.rb +30 -0
  35. data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +40 -0
  36. data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +30 -0
  37. data/lib/mongo/server.rb +6 -0
  38. data/lib/mongo/server/connection.rb +1 -1
  39. data/lib/mongo/server/description.rb +23 -3
  40. data/lib/mongo/server/description/inspector.rb +4 -2
  41. data/lib/mongo/server/description/inspector/description_changed.rb +2 -2
  42. data/lib/mongo/server/description/inspector/member_discovered.rb +59 -0
  43. data/lib/mongo/server/description/inspector/primary_elected.rb +2 -0
  44. data/lib/mongo/server_selector.rb +10 -5
  45. data/lib/mongo/server_selector/nearest.rb +1 -1
  46. data/lib/mongo/server_selector/primary_preferred.rb +1 -1
  47. data/lib/mongo/server_selector/secondary.rb +1 -1
  48. data/lib/mongo/server_selector/secondary_preferred.rb +1 -1
  49. data/lib/mongo/server_selector/selectable.rb +24 -12
  50. data/lib/mongo/uri.rb +1 -1
  51. data/lib/mongo/version.rb +1 -1
  52. data/mongo.gemspec +1 -1
  53. data/spec/mongo/auth/cr_spec.rb +6 -1
  54. data/spec/mongo/auth/ldap_spec.rb +6 -1
  55. data/spec/mongo/auth/scram_spec.rb +6 -1
  56. data/spec/mongo/auth/x509/conversation_spec.rb +69 -0
  57. data/spec/mongo/auth/x509_spec.rb +9 -4
  58. data/spec/mongo/client_spec.rb +40 -2
  59. data/spec/mongo/cluster/topology/replica_set_spec.rb +218 -9
  60. data/spec/mongo/cluster/topology/sharded_spec.rb +17 -2
  61. data/spec/mongo/cluster/topology/single_spec.rb +19 -4
  62. data/spec/mongo/cluster/topology/unknown_spec.rb +19 -1
  63. data/spec/mongo/cluster/topology_spec.rb +11 -7
  64. data/spec/mongo/cluster_spec.rb +25 -7
  65. data/spec/mongo/max_staleness_spec.rb +40 -22
  66. data/spec/mongo/monitoring_spec.rb +2 -2
  67. data/spec/mongo/sdam_monitoring_spec.rb +60 -0
  68. data/spec/mongo/sdam_spec.rb +77 -0
  69. data/spec/mongo/server/connection_pool_spec.rb +6 -1
  70. data/spec/mongo/server/connection_spec.rb +6 -1
  71. data/spec/mongo/server/description_spec.rb +90 -1
  72. data/spec/mongo/server_selection_spec.rb +7 -6
  73. data/spec/mongo/server_selector/nearest_spec.rb +7 -7
  74. data/spec/mongo/server_selector/primary_preferred_spec.rb +7 -7
  75. data/spec/mongo/server_selector/primary_spec.rb +4 -4
  76. data/spec/mongo/server_selector/secondary_preferred_spec.rb +6 -6
  77. data/spec/mongo/server_selector/secondary_spec.rb +6 -6
  78. data/spec/mongo/server_selector_spec.rb +8 -0
  79. data/spec/mongo/server_spec.rb +6 -1
  80. data/spec/mongo/uri_spec.rb +4 -4
  81. data/spec/spec_helper.rb +2 -0
  82. data/spec/support/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +4 -4
  83. data/spec/support/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +3 -3
  84. data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest.yml +3 -3
  85. data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +3 -3
  86. data/spec/support/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +15 -0
  87. data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +1 -1
  88. data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +3 -3
  89. data/spec/support/max_staleness/ReplicaSetNoPrimary/Secondary.yml +3 -3
  90. data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +1 -1
  91. data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +3 -3
  92. data/spec/support/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +23 -0
  93. data/spec/support/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +4 -4
  94. data/spec/support/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +5 -5
  95. data/spec/support/max_staleness/ReplicaSetWithPrimary/{ShortHeartbeartShortMaxStaleness2.yml → LongHeartbeat.yml} +4 -4
  96. data/spec/support/max_staleness/ReplicaSetWithPrimary/{ShortHeartbeartShortMaxStaleness.yml → LongHeartbeat2.yml} +6 -10
  97. data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +3 -2
  98. data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +2 -2
  99. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest.yml +3 -3
  100. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +3 -3
  101. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +3 -3
  102. data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +2 -2
  103. data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +3 -3
  104. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +1 -1
  105. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +3 -3
  106. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +3 -3
  107. data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +3 -3
  108. data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +3 -3
  109. data/spec/support/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +7 -11
  110. data/spec/support/max_staleness/Sharded/Incompatible.yml +4 -4
  111. data/spec/support/max_staleness/Sharded/SmallMaxStaleness.yml +10 -2
  112. data/spec/support/max_staleness/Single/Incompatible.yml +4 -4
  113. data/spec/support/max_staleness/Single/SmallMaxStaleness.yml +2 -2
  114. data/spec/support/max_staleness/Unknown/SmallMaxStaleness.yml +14 -0
  115. data/spec/support/sdam/rs/primary_mismatched_me.yml +2 -2
  116. data/spec/support/sdam/rs/secondary_mismatched_me.yml +2 -2
  117. data/spec/support/sdam_monitoring.rb +144 -0
  118. data/spec/support/sdam_monitoring/replica_set_with_no_primary.yml +112 -0
  119. data/spec/support/sdam_monitoring/replica_set_with_primary.yml +111 -0
  120. data/spec/support/sdam_monitoring/replica_set_with_removal.yml +106 -0
  121. data/spec/support/sdam_monitoring/required_replica_set.yml +84 -0
  122. data/spec/support/sdam_monitoring/standalone.yml +70 -0
  123. data/spec/support/server_discovery_and_monitoring.rb +34 -1
  124. data/spec/support/server_selection.rb +14 -11
  125. data/spec/support/shared/server_selector.rb +6 -0
  126. metadata +49 -13
  127. metadata.gz.sig +0 -0
  128. 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