mongo 2.3.1 → 2.4.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 +2 -3
- data/lib/mongo/bulk_write.rb +8 -7
- data/lib/mongo/bulk_write/combineable.rb +4 -0
- data/lib/mongo/bulk_write/transformable.rb +17 -5
- data/lib/mongo/bulk_write/validatable.rb +1 -0
- data/lib/mongo/client.rb +3 -0
- data/lib/mongo/cluster.rb +8 -0
- data/lib/mongo/cluster/app_metadata.rb +135 -0
- data/lib/mongo/collection.rb +42 -10
- data/lib/mongo/collection/view.rb +15 -1
- data/lib/mongo/collection/view/aggregation.rb +5 -0
- data/lib/mongo/collection/view/builder/aggregation.rb +13 -3
- data/lib/mongo/collection/view/builder/find_command.rb +7 -21
- data/lib/mongo/collection/view/builder/map_reduce.rb +22 -5
- data/lib/mongo/collection/view/iterable.rb +1 -0
- data/lib/mongo/collection/view/map_reduce.rb +5 -0
- data/lib/mongo/collection/view/readable.rb +35 -14
- data/lib/mongo/collection/view/writable.rb +54 -23
- data/lib/mongo/cursor/builder/get_more_command.rb +2 -3
- data/lib/mongo/database.rb +10 -2
- data/lib/mongo/error.rb +2 -0
- data/lib/mongo/error/invalid_application_name.rb +38 -0
- data/lib/mongo/error/invalid_server_preference.rb +24 -3
- data/lib/mongo/error/unsupported_collation.rb +51 -0
- data/lib/mongo/index/view.rb +28 -15
- data/lib/mongo/operation.rb +6 -0
- data/lib/mongo/operation/commands.rb +3 -0
- data/lib/mongo/operation/commands/aggregate.rb +10 -10
- data/lib/mongo/operation/commands/create.rb +45 -0
- data/lib/mongo/operation/commands/drop.rb +45 -0
- data/lib/mongo/operation/commands/drop_database.rb +45 -0
- data/lib/mongo/operation/commands/map_reduce.rb +12 -1
- data/lib/mongo/operation/commands/parallel_scan.rb +1 -0
- data/lib/mongo/operation/read_preference.rb +9 -9
- data/lib/mongo/operation/specifiable.rb +34 -0
- data/lib/mongo/operation/takes_write_concern.rb +35 -0
- data/lib/mongo/operation/write/bulk/bulkable.rb +1 -1
- data/lib/mongo/operation/write/command/create_index.rb +6 -0
- data/lib/mongo/operation/write/command/drop_index.rb +6 -0
- data/lib/mongo/operation/write/command/insert.rb +1 -1
- data/lib/mongo/operation/write/command/update.rb +1 -0
- data/lib/mongo/operation/write/command/writable.rb +2 -2
- data/lib/mongo/operation/write/create_index.rb +2 -2
- data/lib/mongo/operation/write/create_user.rb +1 -1
- data/lib/mongo/operation/write/delete.rb +5 -1
- data/lib/mongo/operation/write/gle.rb +1 -1
- data/lib/mongo/operation/write/insert.rb +2 -2
- data/lib/mongo/operation/write/remove_user.rb +1 -1
- data/lib/mongo/operation/write/update.rb +5 -1
- data/lib/mongo/operation/write/update_user.rb +1 -1
- data/lib/mongo/operation/write/write_command_enabled.rb +10 -2
- data/lib/mongo/protocol/insert.rb +1 -2
- data/lib/mongo/protocol/query.rb +3 -7
- data/lib/mongo/server.rb +8 -3
- data/lib/mongo/server/connection.rb +17 -11
- data/lib/mongo/server/description.rb +22 -0
- data/lib/mongo/server/description/features.rb +2 -0
- data/lib/mongo/server/monitor.rb +5 -0
- data/lib/mongo/server/monitor/connection.rb +11 -0
- data/lib/mongo/server_selector/nearest.rb +9 -6
- data/lib/mongo/server_selector/primary.rb +4 -0
- data/lib/mongo/server_selector/primary_preferred.rb +7 -1
- data/lib/mongo/server_selector/secondary.rb +5 -0
- data/lib/mongo/server_selector/secondary_preferred.rb +7 -2
- data/lib/mongo/server_selector/selectable.rb +57 -10
- data/lib/mongo/socket/ssl.rb +1 -0
- data/lib/mongo/uri.rb +4 -0
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo/write_concern.rb +1 -0
- data/mongo.gemspec +1 -1
- data/spec/mongo/auth/cr_spec.rb +7 -1
- data/spec/mongo/auth/ldap_spec.rb +7 -1
- data/spec/mongo/auth/scram_spec.rb +7 -1
- data/spec/mongo/auth/x509_spec.rb +7 -1
- data/spec/mongo/bulk_write_spec.rb +598 -5
- data/spec/mongo/client_spec.rb +47 -1
- data/spec/mongo/cluster/app_metadata_spec.rb +104 -0
- data/spec/mongo/cluster/topology/replica_set_spec.rb +14 -8
- data/spec/mongo/cluster/topology/sharded_spec.rb +9 -3
- data/spec/mongo/cluster/topology/single_spec.rb +10 -4
- data/spec/mongo/cluster_spec.rb +29 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +139 -0
- data/spec/mongo/collection/view/builder/find_command_spec.rb +6 -243
- data/spec/mongo/collection/view/map_reduce_spec.rb +104 -0
- data/spec/mongo/collection/view/readable_spec.rb +83 -0
- data/spec/mongo/collection/view/writable_spec.rb +447 -1
- data/spec/mongo/collection/view_spec.rb +57 -0
- data/spec/mongo/collection_spec.rb +926 -101
- data/spec/mongo/crud_spec.rb +4 -5
- data/spec/mongo/database_spec.rb +99 -1
- data/spec/mongo/index/view_spec.rb +360 -31
- data/spec/mongo/max_staleness_spec.rb +108 -0
- data/spec/mongo/operation/read_preference_spec.rb +8 -8
- data/spec/mongo/operation/write/command/delete_spec.rb +1 -1
- data/spec/mongo/operation/write/command/insert_spec.rb +1 -1
- data/spec/mongo/operation/write/command/update_spec.rb +1 -1
- data/spec/mongo/server/connection_pool_spec.rb +3 -1
- data/spec/mongo/server/connection_spec.rb +17 -7
- data/spec/mongo/server/description/features_spec.rb +50 -0
- data/spec/mongo/server/description_spec.rb +9 -3
- data/spec/mongo/server_selection_spec.rb +5 -3
- data/spec/mongo/server_selector/nearest_spec.rb +73 -0
- data/spec/mongo/server_selector/primary_preferred_spec.rb +73 -0
- data/spec/mongo/server_selector/primary_spec.rb +36 -0
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +73 -0
- data/spec/mongo/server_selector/secondary_spec.rb +73 -0
- data/spec/mongo/server_selector_spec.rb +53 -0
- data/spec/mongo/server_spec.rb +3 -1
- data/spec/mongo/uri_spec.rb +54 -0
- data/spec/mongo/write_concern_spec.rb +18 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/authorization.rb +8 -1
- data/spec/support/crud.rb +15 -0
- data/spec/support/crud/read.rb +27 -19
- data/spec/support/crud/write.rb +28 -3
- data/spec/support/crud_tests/read/aggregate.yml +15 -3
- data/spec/support/crud_tests/read/count.yml +14 -3
- data/spec/support/crud_tests/read/distinct.yml +13 -1
- data/spec/support/crud_tests/read/find.yml +12 -2
- data/spec/support/crud_tests/write/deleteMany.yml +22 -1
- data/spec/support/crud_tests/write/deleteOne.yml +20 -1
- data/spec/support/crud_tests/write/findOneAndDelete.yml +27 -2
- data/spec/support/crud_tests/write/findOneAndReplace.yml +43 -14
- data/spec/support/crud_tests/write/findOneAndUpdate.yml +50 -8
- data/spec/support/crud_tests/write/replaceOne.yml +34 -10
- data/spec/support/crud_tests/write/updateMany.yml +42 -11
- data/spec/support/crud_tests/write/updateOne.yml +32 -7
- data/spec/support/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +26 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +25 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +27 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +36 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Secondary.yml +51 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +26 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +51 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +26 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +25 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +35 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +25 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +23 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +36 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +27 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +27 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +26 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +59 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +43 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +59 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +43 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/ShortHeartbeartShortMaxStaleness.yml +29 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/ShortHeartbeartShortMaxStaleness2.yml +29 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +27 -0
- data/spec/support/max_staleness/Sharded/Incompatible.yml +25 -0
- data/spec/support/max_staleness/Sharded/SmallMaxStaleness.yml +20 -0
- data/spec/support/max_staleness/Single/Incompatible.yml +18 -0
- data/spec/support/max_staleness/Single/SmallMaxStaleness.yml +20 -0
- data/spec/support/server_selection.rb +25 -0
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest_multiple.yml +27 -0
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_multi_tags.yml +31 -0
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_multi_tags2.yml +31 -0
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest_multiple.yml +34 -0
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.yml +28 -0
- data/spec/support/shared/server_selector.rb +4 -3
- metadata +91 -6
- metadata.gz.sig +0 -0
@@ -2,6 +2,8 @@ data:
|
|
2
2
|
- {_id: 1, x: 11}
|
3
3
|
- {_id: 2, x: 22}
|
4
4
|
- {_id: 3, x: 33}
|
5
|
+
- {_id: 4, x: 'ping'}
|
6
|
+
- {_id: 5, x: 'pINg'}
|
5
7
|
|
6
8
|
tests:
|
7
9
|
-
|
@@ -9,9 +11,9 @@ tests:
|
|
9
11
|
operation:
|
10
12
|
name: "updateMany"
|
11
13
|
arguments:
|
12
|
-
filter:
|
13
|
-
_id: {$gt: 1}
|
14
|
-
update:
|
14
|
+
filter:
|
15
|
+
_id: {$gt: 1, $lt: 4}
|
16
|
+
update:
|
15
17
|
$inc: {x: 1}
|
16
18
|
|
17
19
|
outcome:
|
@@ -23,13 +25,37 @@ tests:
|
|
23
25
|
- {_id: 1, x: 11}
|
24
26
|
- {_id: 2, x: 23}
|
25
27
|
- {_id: 3, x: 34}
|
28
|
+
- {_id: 4, x: 'ping'}
|
29
|
+
- {_id: 5, x: 'pINg'}
|
30
|
+
-
|
31
|
+
description: "UpdateMany when many documents match with collation"
|
32
|
+
operation:
|
33
|
+
name: "updateMany"
|
34
|
+
arguments:
|
35
|
+
filter:
|
36
|
+
x: 'ping'
|
37
|
+
update:
|
38
|
+
$set: {x: 'pong'}
|
39
|
+
collation: { locale: 'en_US', strength: 2 }
|
40
|
+
|
41
|
+
outcome:
|
42
|
+
result:
|
43
|
+
matchedCount: 2
|
44
|
+
modifiedCount: 2
|
45
|
+
collection:
|
46
|
+
data:
|
47
|
+
- {_id: 1, x: 11}
|
48
|
+
- {_id: 2, x: 22}
|
49
|
+
- {_id: 3, x: 33}
|
50
|
+
- {_id: 4, x: 'pong'}
|
51
|
+
- {_id: 5, x: 'pong'}
|
26
52
|
-
|
27
53
|
description: "UpdateMany when one document matches"
|
28
54
|
operation:
|
29
55
|
name: "updateMany"
|
30
56
|
arguments:
|
31
57
|
filter: {_id: 1}
|
32
|
-
update:
|
58
|
+
update:
|
33
59
|
$inc: {x: 1}
|
34
60
|
|
35
61
|
outcome:
|
@@ -41,13 +67,15 @@ tests:
|
|
41
67
|
- {_id: 1, x: 12}
|
42
68
|
- {_id: 2, x: 22}
|
43
69
|
- {_id: 3, x: 33}
|
70
|
+
- {_id: 4, x: 'ping'}
|
71
|
+
- {_id: 5, x: 'pINg'}
|
44
72
|
-
|
45
73
|
description: "UpdateMany when no documents match"
|
46
74
|
operation:
|
47
75
|
name: "updateMany"
|
48
76
|
arguments:
|
49
|
-
filter: {_id:
|
50
|
-
update:
|
77
|
+
filter: {_id: 6}
|
78
|
+
update:
|
51
79
|
$inc: {x: 1}
|
52
80
|
|
53
81
|
outcome:
|
@@ -59,13 +87,15 @@ tests:
|
|
59
87
|
- {_id: 1, x: 11}
|
60
88
|
- {_id: 2, x: 22}
|
61
89
|
- {_id: 3, x: 33}
|
90
|
+
- {_id: 4, x: 'ping'}
|
91
|
+
- {_id: 5, x: 'pINg'}
|
62
92
|
-
|
63
93
|
description: "UpdateMany with upsert when no documents match"
|
64
94
|
operation:
|
65
95
|
name: "updateMany"
|
66
96
|
arguments:
|
67
|
-
filter: {_id:
|
68
|
-
update:
|
97
|
+
filter: {_id: 6}
|
98
|
+
update:
|
69
99
|
$inc: {x: 1}
|
70
100
|
upsert: true
|
71
101
|
|
@@ -73,11 +103,12 @@ tests:
|
|
73
103
|
result:
|
74
104
|
matchedCount: 0
|
75
105
|
modifiedCount: 0
|
76
|
-
upsertedId:
|
106
|
+
upsertedId: 6
|
77
107
|
collection:
|
78
108
|
data:
|
79
109
|
- {_id: 1, x: 11}
|
80
110
|
- {_id: 2, x: 22}
|
81
111
|
- {_id: 3, x: 33}
|
82
|
-
- {_id: 4, x:
|
83
|
-
|
112
|
+
- {_id: 4, x: 'ping'}
|
113
|
+
- {_id: 5, x: 'pINg'}
|
114
|
+
- {_id: 6, x: 1}
|
@@ -2,6 +2,7 @@ data:
|
|
2
2
|
- {_id: 1, x: 11}
|
3
3
|
- {_id: 2, x: 22}
|
4
4
|
- {_id: 3, x: 33}
|
5
|
+
- {_id: 4, x: 'ping'}
|
5
6
|
|
6
7
|
tests:
|
7
8
|
-
|
@@ -9,9 +10,9 @@ tests:
|
|
9
10
|
operation:
|
10
11
|
name: "updateOne"
|
11
12
|
arguments:
|
12
|
-
filter:
|
13
|
+
filter:
|
13
14
|
_id: {$gt: 1}
|
14
|
-
update:
|
15
|
+
update:
|
15
16
|
$inc: {x: 1}
|
16
17
|
|
17
18
|
outcome:
|
@@ -26,7 +27,7 @@ tests:
|
|
26
27
|
name: "updateOne"
|
27
28
|
arguments:
|
28
29
|
filter: {_id: 1}
|
29
|
-
update:
|
30
|
+
update:
|
30
31
|
$inc: {x: 1}
|
31
32
|
|
32
33
|
outcome:
|
@@ -38,12 +39,34 @@ tests:
|
|
38
39
|
- {_id: 1, x: 12}
|
39
40
|
- {_id: 2, x: 22}
|
40
41
|
- {_id: 3, x: 33}
|
42
|
+
- {_id: 4, x: 'ping'}
|
43
|
+
-
|
44
|
+
description: "UpdateOne when one document matches with collation"
|
45
|
+
operation:
|
46
|
+
name: "updateOne"
|
47
|
+
arguments:
|
48
|
+
filter: {x: 'PING'}
|
49
|
+
update:
|
50
|
+
$set: {x: 'pong'}
|
51
|
+
collation: { locale: 'en_US', strength: 2}
|
52
|
+
|
53
|
+
outcome:
|
54
|
+
result:
|
55
|
+
matchedCount: 1
|
56
|
+
modifiedCount: 1
|
57
|
+
collection:
|
58
|
+
data:
|
59
|
+
- {_id: 1, x: 11}
|
60
|
+
- {_id: 2, x: 22}
|
61
|
+
- {_id: 3, x: 33}
|
62
|
+
- {_id: 4, x: 'pong'}
|
63
|
+
|
41
64
|
-
|
42
65
|
description: "UpdateOne when no documents match"
|
43
66
|
operation:
|
44
67
|
name: "updateOne"
|
45
68
|
arguments:
|
46
|
-
filter: {_id:
|
69
|
+
filter: {_id: 5}
|
47
70
|
update:
|
48
71
|
$inc: {x: 1}
|
49
72
|
|
@@ -56,12 +79,13 @@ tests:
|
|
56
79
|
- {_id: 1, x: 11}
|
57
80
|
- {_id: 2, x: 22}
|
58
81
|
- {_id: 3, x: 33}
|
82
|
+
- {_id: 4, x: 'ping'}
|
59
83
|
-
|
60
84
|
description: "UpdateOne with upsert when no documents match"
|
61
85
|
operation:
|
62
86
|
name: "updateOne"
|
63
87
|
arguments:
|
64
|
-
filter: {_id:
|
88
|
+
filter: {_id: 5}
|
65
89
|
update:
|
66
90
|
$inc: {x: 1}
|
67
91
|
upsert: true
|
@@ -70,11 +94,12 @@ tests:
|
|
70
94
|
result:
|
71
95
|
matchedCount: 0
|
72
96
|
modifiedCount: 0
|
73
|
-
upsertedId:
|
97
|
+
upsertedId: 5
|
74
98
|
collection:
|
75
99
|
data:
|
76
100
|
- {_id: 1, x: 11}
|
77
101
|
- {_id: 2, x: 22}
|
78
102
|
- {_id: 3, x: 33}
|
79
|
-
- {_id: 4, x:
|
103
|
+
- {_id: 4, x: 'ping'}
|
104
|
+
- {_id: 5, x: 1}
|
80
105
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# By default, a read preference sets no maximum on staleness.
|
2
|
+
---
|
3
|
+
topology_description:
|
4
|
+
type: ReplicaSetNoPrimary
|
5
|
+
servers:
|
6
|
+
- &1
|
7
|
+
address: a:27017
|
8
|
+
type: RSSecondary
|
9
|
+
avg_rtt_ms: 50 # Too far.
|
10
|
+
lastUpdateTime: 0
|
11
|
+
maxWireVersion: 5
|
12
|
+
lastWrite: {lastWriteDate: {$numberLong: "1000001"}}
|
13
|
+
- &2
|
14
|
+
address: b:27017
|
15
|
+
type: RSSecondary
|
16
|
+
avg_rtt_ms: 5
|
17
|
+
lastUpdateTime: 0
|
18
|
+
maxWireVersion: 5
|
19
|
+
lastWrite: {lastWriteDate: {$numberLong: "1"}} # Very stale.
|
20
|
+
read_preference:
|
21
|
+
mode: Nearest
|
22
|
+
suitable_servers: # Very stale server is fine.
|
23
|
+
- *1
|
24
|
+
- *2
|
25
|
+
in_latency_window:
|
26
|
+
- *2
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# During server selection,
|
2
|
+
# clients (drivers or mongos) MUST raise an error if ``maxStalenessMS`` is not zero or null,
|
3
|
+
# and any server's ``maxWireVersion`` is less than 5 (`SERVER-23893`_).
|
4
|
+
---
|
5
|
+
topology_description:
|
6
|
+
type: ReplicaSetNoPrimary
|
7
|
+
servers:
|
8
|
+
- &1
|
9
|
+
address: a:27017
|
10
|
+
type: RSSecondary
|
11
|
+
avg_rtt_ms: 5
|
12
|
+
lastUpdateTime: 0
|
13
|
+
maxWireVersion: 5
|
14
|
+
lastWrite: {lastWriteDate: {$numberLong: "2"}}
|
15
|
+
- &2
|
16
|
+
address: b:27017
|
17
|
+
type: RSSecondary
|
18
|
+
avg_rtt_ms: 5
|
19
|
+
lastUpdateTime: 0
|
20
|
+
maxWireVersion: 4 # Incompatible.
|
21
|
+
lastWrite: {lastWriteDate: {$numberLong: "1"}}
|
22
|
+
read_preference:
|
23
|
+
mode: Nearest
|
24
|
+
maxStalenessMS: 120000
|
25
|
+
error: true
|
@@ -0,0 +1,33 @@
|
|
1
|
+
heartbeatFrequencyMS: 25000 # 25 seconds.
|
2
|
+
topology_description:
|
3
|
+
type: ReplicaSetNoPrimary
|
4
|
+
servers:
|
5
|
+
- &1
|
6
|
+
address: a:27017
|
7
|
+
type: RSSecondary
|
8
|
+
avg_rtt_ms: 5
|
9
|
+
lastUpdateTime: 1
|
10
|
+
lastWrite: {lastWriteDate: {$numberLong: "25002"}}
|
11
|
+
maxWireVersion: 5
|
12
|
+
- &2
|
13
|
+
address: b:27017
|
14
|
+
type: RSSecondary
|
15
|
+
avg_rtt_ms: 50 # Too far.
|
16
|
+
lastUpdateTime: 25002 # Not used when there's no primary.
|
17
|
+
lastWrite: {lastWriteDate: {$numberLong: "2"}} # 25 sec stale + 25 sec heartbeat <= 50 sec maxStaleness.
|
18
|
+
maxWireVersion: 5
|
19
|
+
- &3
|
20
|
+
address: c:27017
|
21
|
+
type: RSSecondary
|
22
|
+
avg_rtt_ms: 5
|
23
|
+
lastUpdateTime: 25001
|
24
|
+
lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale.
|
25
|
+
maxWireVersion: 5
|
26
|
+
read_preference:
|
27
|
+
mode: Nearest
|
28
|
+
maxStalenessMS: 50000
|
29
|
+
suitable_servers:
|
30
|
+
- *1
|
31
|
+
- *2
|
32
|
+
in_latency_window:
|
33
|
+
- *1
|
@@ -0,0 +1,33 @@
|
|
1
|
+
heartbeatFrequencyMS: 25000 # 25 seconds.
|
2
|
+
topology_description:
|
3
|
+
type: ReplicaSetNoPrimary
|
4
|
+
servers:
|
5
|
+
- &1
|
6
|
+
address: a:27017
|
7
|
+
type: RSSecondary
|
8
|
+
avg_rtt_ms: 5
|
9
|
+
lastUpdateTime: 0
|
10
|
+
lastWrite: {lastWriteDate: {$numberLong: "25002"}}
|
11
|
+
maxWireVersion: 5
|
12
|
+
- &2
|
13
|
+
address: b:27017
|
14
|
+
type: RSSecondary
|
15
|
+
avg_rtt_ms: 50 # Too far.
|
16
|
+
lastUpdateTime: 0
|
17
|
+
lastWrite: {lastWriteDate: {$numberLong: "2"}} # 25 sec stale + 25 sec heartbeat <= 50 sec maxStaleness.
|
18
|
+
maxWireVersion: 5
|
19
|
+
- &3
|
20
|
+
address: c:27017
|
21
|
+
avg_rtt_ms: 5
|
22
|
+
lastUpdateTime: 0
|
23
|
+
type: RSSecondary
|
24
|
+
lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale.
|
25
|
+
maxWireVersion: 5
|
26
|
+
read_preference:
|
27
|
+
mode: Nearest
|
28
|
+
maxStalenessMS: 50000
|
29
|
+
suitable_servers:
|
30
|
+
- *1
|
31
|
+
- *2
|
32
|
+
in_latency_window:
|
33
|
+
- *1
|
@@ -0,0 +1,33 @@
|
|
1
|
+
heartbeatFrequencyMS: 25000 # 25 seconds.
|
2
|
+
topology_description:
|
3
|
+
type: ReplicaSetNoPrimary
|
4
|
+
servers:
|
5
|
+
- &1
|
6
|
+
address: a:27017
|
7
|
+
type: RSSecondary
|
8
|
+
avg_rtt_ms: 50 # Too far.
|
9
|
+
lastUpdateTime: 0
|
10
|
+
lastWrite: {lastWriteDate: {$numberLong: "25002"}}
|
11
|
+
maxWireVersion: 5
|
12
|
+
- &2
|
13
|
+
address: b:27017
|
14
|
+
type: RSSecondary
|
15
|
+
avg_rtt_ms: 5
|
16
|
+
lastUpdateTime: 0
|
17
|
+
lastWrite: {lastWriteDate: {$numberLong: "2"}} # 25 sec stale + 25 sec heartbeat <= 50 sec maxStaleness.
|
18
|
+
maxWireVersion: 5
|
19
|
+
- &3
|
20
|
+
address: c:27017
|
21
|
+
avg_rtt_ms: 5
|
22
|
+
lastUpdateTime: 0
|
23
|
+
type: RSSecondary
|
24
|
+
lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale.
|
25
|
+
maxWireVersion: 5
|
26
|
+
read_preference:
|
27
|
+
mode: Nearest
|
28
|
+
maxStalenessMS: 50000
|
29
|
+
suitable_servers:
|
30
|
+
- *1
|
31
|
+
- *2
|
32
|
+
in_latency_window:
|
33
|
+
- *2
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Fallback to secondary if no primary.
|
2
|
+
---
|
3
|
+
heartbeatFrequencyMS: 25000 # 25 seconds.
|
4
|
+
topology_description:
|
5
|
+
type: ReplicaSetNoPrimary
|
6
|
+
servers:
|
7
|
+
- &1
|
8
|
+
address: a:27017
|
9
|
+
type: RSSecondary
|
10
|
+
avg_rtt_ms: 5
|
11
|
+
lastUpdateTime: 0
|
12
|
+
maxWireVersion: 5
|
13
|
+
lastWrite: {lastWriteDate: {$numberLong: "1000001"}}
|
14
|
+
- &2
|
15
|
+
address: b:27017
|
16
|
+
type: RSSecondary
|
17
|
+
avg_rtt_ms: 5
|
18
|
+
lastUpdateTime: 0
|
19
|
+
maxWireVersion: 5
|
20
|
+
lastWrite: {lastWriteDate: {$numberLong: "1"}} # Very stale.
|
21
|
+
read_preference:
|
22
|
+
mode: PrimaryPreferred
|
23
|
+
maxStalenessMS: 50000
|
24
|
+
suitable_servers:
|
25
|
+
- *1
|
26
|
+
in_latency_window:
|
27
|
+
- *1
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# maxStalenessMS is applied before tag sets. With tag sets
|
2
|
+
# [{data_center: nyc}, {data_center: tokyo}], if the only node in NYC is stale
|
3
|
+
# then use Tokyo.
|
4
|
+
---
|
5
|
+
heartbeatFrequencyMS: 25000 # 25 seconds.
|
6
|
+
topology_description:
|
7
|
+
type: ReplicaSetNoPrimary
|
8
|
+
servers:
|
9
|
+
- &1
|
10
|
+
address: a:27017
|
11
|
+
type: RSSecondary
|
12
|
+
avg_rtt_ms: 5
|
13
|
+
lastUpdateTime: 0
|
14
|
+
lastWrite: {lastWriteDate: {$numberLong: "25002"}}
|
15
|
+
maxWireVersion: 5
|
16
|
+
tags:
|
17
|
+
data_center: tokyo # Matches second tag set.
|
18
|
+
- &2
|
19
|
+
address: b:27017
|
20
|
+
type: RSSecondary
|
21
|
+
avg_rtt_ms: 5
|
22
|
+
lastUpdateTime: 0
|
23
|
+
lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale.
|
24
|
+
maxWireVersion: 5
|
25
|
+
tags:
|
26
|
+
data_center: nyc
|
27
|
+
read_preference:
|
28
|
+
mode: PrimaryPreferred
|
29
|
+
maxStalenessMS: 50000
|
30
|
+
tag_sets:
|
31
|
+
- data_center: nyc
|
32
|
+
- data_center: tokyo
|
33
|
+
suitable_servers:
|
34
|
+
- *1
|
35
|
+
in_latency_window:
|
36
|
+
- *1
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Latest secondary's lastWriteDate is used normally with read preference tags.
|
2
|
+
---
|
3
|
+
heartbeatFrequencyMS: 25000 # 25 seconds.
|
4
|
+
topology_description:
|
5
|
+
type: ReplicaSetNoPrimary
|
6
|
+
servers:
|
7
|
+
- &1
|
8
|
+
address: a:27017
|
9
|
+
type: RSSecondary
|
10
|
+
avg_rtt_ms: 5
|
11
|
+
lastUpdateTime: 0
|
12
|
+
maxWireVersion: 5
|
13
|
+
lastWrite: {lastWriteDate: {$numberLong: "25002"}}
|
14
|
+
tags:
|
15
|
+
data_center: tokyo # No match, but its lastWriteDate is used in estimate.
|
16
|
+
- &2
|
17
|
+
address: b:27017
|
18
|
+
type: RSSecondary
|
19
|
+
avg_rtt_ms: 5
|
20
|
+
lastUpdateTime: 0
|
21
|
+
maxWireVersion: 5
|
22
|
+
lastWrite: {lastWriteDate: {$numberLong: "2"}} # 25 sec stale + 25 sec heartbeat <= 50 sec maxStaleness.
|
23
|
+
tags:
|
24
|
+
data_center: nyc
|
25
|
+
- &3
|
26
|
+
address: c:27017
|
27
|
+
type: RSSecondary
|
28
|
+
avg_rtt_ms: 5
|
29
|
+
lastUpdateTime: 0
|
30
|
+
maxWireVersion: 5
|
31
|
+
lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale.
|
32
|
+
tags:
|
33
|
+
data_center: nyc
|
34
|
+
- &4
|
35
|
+
address: d:27017
|
36
|
+
type: RSSecondary
|
37
|
+
avg_rtt_ms: 5
|
38
|
+
lastUpdateTime: 0
|
39
|
+
maxWireVersion: 5
|
40
|
+
lastWrite: {lastWriteDate: {$numberLong: "2"}}
|
41
|
+
tags:
|
42
|
+
data_center: tokyo # No match.
|
43
|
+
read_preference:
|
44
|
+
mode: Secondary
|
45
|
+
maxStalenessMS: 50000
|
46
|
+
tag_sets:
|
47
|
+
- data_center: nyc
|
48
|
+
suitable_servers:
|
49
|
+
- *2
|
50
|
+
in_latency_window:
|
51
|
+
- *2
|