mongolly 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ require 'debugger'
|
|
7
7
|
|
8
8
|
class Mongo::MongoClient
|
9
9
|
MAX_DISABLE_BALANCER_WAIT = 60*5 # 5 Minutes
|
10
|
+
REPLICA_SNAPSHOT_THRESHOLD = 60*5 # 5 Minutes
|
10
11
|
|
11
12
|
def snapshot_ebs(options={})
|
12
13
|
|
@@ -33,12 +34,12 @@ class Mongo::MongoClient
|
|
33
34
|
ssh_command(options[:config_server_ssh_user], config_server, options[:mongo_start_command], options[:config_server_ssh_keypath])
|
34
35
|
end
|
35
36
|
else
|
36
|
-
backup_instance(snapshot_ebs_target, options,
|
37
|
+
backup_instance(snapshot_ebs_target(REPLICA_SNAPSHOT_THRESHOLD), options, false )
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
protected
|
41
|
-
def snapshot_ebs_target
|
42
|
+
def snapshot_ebs_target(threshold=nil)
|
42
43
|
host_port.join(':')
|
43
44
|
end
|
44
45
|
|
@@ -54,6 +55,9 @@ protected
|
|
54
55
|
|
55
56
|
raise RuntimeError.new "no suitable volumes found" unless volumes.length > 0
|
56
57
|
|
58
|
+
# Force lock with multiple volumes
|
59
|
+
lock = true if volumes.length > 1
|
60
|
+
|
57
61
|
backup_block = proc do
|
58
62
|
volumes.each do |volume|
|
59
63
|
@mongolly_logger.debug("Snapshotting #{volume.id} with tag #{options[:backup_key]}")
|
@@ -2,15 +2,21 @@ require 'mongo'
|
|
2
2
|
|
3
3
|
class Mongo::MongoReplicaSetClient
|
4
4
|
|
5
|
-
def most_current_secondary
|
5
|
+
def most_current_secondary(threshold = 0)
|
6
6
|
replica = self['admin'].command( replSetGetStatus: 1 )
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
secondaries = replica['members'].select { |m| m['state'] == 2 }.sort_by { |m| m['name'] }
|
8
|
+
most_current = secondaries.first
|
9
|
+
secondaries[1..-1].each do |secondary|
|
10
|
+
if (secondary['optime'] - most_current['optime']) > threshold
|
11
|
+
most_current = secondary
|
12
|
+
end
|
13
|
+
end
|
14
|
+
@mongolly_logger.debug("Found most current secondary #{most_current['name']}")
|
15
|
+
most_current['name']
|
10
16
|
end
|
11
17
|
|
12
18
|
protected
|
13
|
-
def snapshot_ebs_target
|
14
|
-
most_current_secondary
|
19
|
+
def snapshot_ebs_target(threshold = 0)
|
20
|
+
most_current_secondary(threshold)
|
15
21
|
end
|
16
22
|
end
|
data/lib/mongolly/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongolly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|