Skip to content

Commit 42994d4

Browse files
author
Tom Christ
committed
Move pool replication commands to jetpants_collins as there is collins-specific usage
1 parent f8d27da commit 42994d4

File tree

2 files changed

+41
-42
lines changed

2 files changed

+41
-42
lines changed

bin/jetpants

-41
Original file line numberDiff line numberDiff line change
@@ -565,47 +565,6 @@ module Jetpants
565565
end
566566
end
567567

568-
desc 'pause_pool_replication', 'pause replication on all slaves in a given pool'
569-
method_option :pool
570-
def pause_pool_replication
571-
pool = Jetpants.topology.pool (options[:pool] || ask('Please enter the pool name: ')).downcase
572-
error "Unable to find pool" unless pool
573-
574-
master = pool.master
575-
error "Unable to find master for pool" unless master
576-
577-
slaves = master.slaves
578-
error "Master does not have any replicating slaves to pause" unless slaves and not slaves.empty?
579-
580-
inform "Pausing replication on #{slaves.size} slaves"
581-
slaves.concurrent_each do |slave|
582-
slave.disable_monitoring rescue inform "Warning! Unable to disable monitoring for slave: #{slave}"
583-
slave.pause_replication rescue inform "Warning! Unable to pause replication for slave: #{slave}"
584-
end
585-
end
586-
587-
desc 'resume_pool_replication', 'resume replication on all slaves according to collins for a given pool'
588-
method_option :pool
589-
def resume_pool_replication
590-
pool = Jetpants.topology.pool (options[:pool] || ask('Please enter the pool name: ')).downcase
591-
error "Unable to find pool" unless pool
592-
593-
master = pool.master
594-
error "Unable to find master for pool" unless master
595-
596-
slaves = pool.slaves_according_to_collins
597-
error "Unable to find any slaves (via collins) for pool" unless slaves and not slaves.empty?
598-
599-
inform "Resuming replication on #{slaves.size} slaves"
600-
slaves.concurrent_each(&:resume_replication)
601-
602-
inform "Preparing to enable monitoring after slaves catch up to master"
603-
slaves.concurrent_each do |slave|
604-
slave.catch_up_to_master
605-
slave.enable_monitoring
606-
end
607-
end
608-
609568
no_tasks do
610569
def is_ip? address
611570
address =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/

plugins/jetpants_collins/commandsuite.rb

+41-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@ def create_pool
5959
new_pool.collins_set(:application => application)
6060
end
6161
end
62-
62+
63+
desc 'pause_pool_replication', 'pause replication on all slaves in a given pool'
64+
method_option :pool
65+
def pause_pool_replication
66+
pool = Jetpants.topology.pool (options[:pool] || ask('Please enter the pool name: ')).downcase
67+
error "Unable to find pool" unless pool
68+
69+
master = pool.master
70+
error "Unable to find master for pool" unless master
71+
72+
slaves = master.slaves
73+
error "Master does not have any replicating slaves to pause" unless slaves and not slaves.empty?
74+
75+
inform "Pausing replication on #{slaves.size} slaves"
76+
slaves.concurrent_each do |slave|
77+
slave.disable_monitoring rescue inform "Warning! Unable to disable monitoring for slave: #{slave}"
78+
slave.pause_replication rescue inform "Warning! Unable to pause replication for slave: #{slave}"
79+
end
80+
end
81+
82+
desc 'resume_pool_replication', 'resume replication on all slaves according to collins for a given pool'
83+
method_option :pool
84+
def resume_pool_replication
85+
pool = Jetpants.topology.pool (options[:pool] || ask('Please enter the pool name: ')).downcase
86+
error "Unable to find pool" unless pool
87+
88+
master = pool.master
89+
error "Unable to find master for pool" unless master
90+
91+
slaves = pool.slaves_according_to_collins
92+
error "Unable to find any slaves (via collins) for pool" unless slaves and not slaves.empty?
93+
94+
inform "Resuming replication on #{slaves.size} slaves"
95+
slaves.concurrent_each(&:resume_replication)
96+
97+
inform "Preparing to enable monitoring after slaves catch up to master"
98+
slaves.concurrent_each do |slave|
99+
slave.catch_up_to_master
100+
slave.enable_monitoring
101+
end
102+
end
63103
end
64104
end

0 commit comments

Comments
 (0)