Changes as requested by daniel in merge feedback:

- change to get_slave_lag
- if then else
- chop comments 80 char wide
This commit is contained in:
Kenny Gryp
2014-04-23 13:24:11 +02:00
parent 4ecae6b50f
commit ef313207dc
6 changed files with 50 additions and 46 deletions

View File

@@ -8105,7 +8105,14 @@ sub main {
return; return;
}; };
my $get_lag = sub { my $get_lag;
# The plugin is able to override the slavelag check so tools like
# pt-heartbeat or other replicators (Tungsten...) can be used to
# measure replication lag
if ( $plugin && $plugin->can('get_slave_lag') ) {
$get_lag = $plugin->get_slave_lag(oktorun => \$oktorun);
} else {
$get_lag = sub {
my ($cxn) = @_; my ($cxn) = @_;
my $dbh = $cxn->dbh(); my $dbh = $cxn->dbh();
if ( !$dbh || !$dbh->ping() ) { if ( !$dbh || !$dbh->ping() ) {
@@ -8119,11 +8126,6 @@ sub main {
} }
return $ms->get_slave_lag($dbh); return $ms->get_slave_lag($dbh);
}; };
# The plugin is able to override the slavelag check so tools like pt-heartbeat
# or other replicators (Tungsten...) can be used to measure replication lag
if ( $plugin && $plugin->can('override_slavelag_check') ) {
$get_lag = $plugin->override_slavelag_check(oktorun => \$oktorun);
} }
$replica_lag = new ReplicaLagWaiter( $replica_lag = new ReplicaLagWaiter(
@@ -11351,7 +11353,7 @@ These hooks, in this order, are called if defined:
after_drop_old_table after_drop_old_table
before_drop_triggers before_drop_triggers
before_exit before_exit
override_slavelag_check get_slave_lag
Each hook is passed different arguments. To see which arguments are passed Each hook is passed different arguments. To see which arguments are passed
to a hook, search for the hook's name in the tool's source code, like: to a hook, search for the hook's name in the tool's source code, like:

View File

@@ -9579,7 +9579,14 @@ sub main {
return; return;
}; };
my $get_lag = sub { my $get_lag;
# The plugin is able to override the slavelag check so tools like
# pt-heartbeat or other replicators (Tungsten...) can be used to
# measure replication lag
if ( $plugin && $plugin->can('get_slave_lag') ) {
$get_lag = $plugin->get_slave_lag(oktorun => \$oktorun);
} else {
$get_lag = sub {
my ($cxn) = @_; my ($cxn) = @_;
my $dbh = $cxn->dbh(); my $dbh = $cxn->dbh();
if ( !$dbh || !$dbh->ping() ) { if ( !$dbh || !$dbh->ping() ) {
@@ -9595,11 +9602,6 @@ sub main {
} }
return $ms->get_slave_lag($dbh); return $ms->get_slave_lag($dbh);
}; };
# The plugin is able to override the slavelag check so tools like pt-heartbeat
# or other replicators (Tungsten...) can be used to measure replication lag
if ( $plugin && $plugin->can('override_slavelag_check') ) {
$get_lag = $plugin->override_slavelag_check(oktorun => \$oktorun);
} }
$replica_lag = new ReplicaLagWaiter( $replica_lag = new ReplicaLagWaiter(
@@ -12492,7 +12494,7 @@ These hooks, in this order, are called if defined:
init init
before_replicate_check before_replicate_check
after_replicate_check after_replicate_check
override_slavelag_check get_slave_lag
before_checksum_table before_checksum_table
after_checksum_table after_checksum_table

View File

@@ -56,7 +56,7 @@ my @called = $output =~ m/^PLUGIN \S+$/gm;
is_deeply( is_deeply(
\@called, \@called,
[ [
'PLUGIN override_slavelag_check', 'PLUGIN get_slave_lag',
'PLUGIN init', 'PLUGIN init',
'PLUGIN before_create_new_table', 'PLUGIN before_create_new_table',
'PLUGIN after_create_new_table', 'PLUGIN after_create_new_table',

View File

@@ -96,9 +96,9 @@ sub before_exit {
print "PLUGIN before_exit\n"; print "PLUGIN before_exit\n";
} }
sub override_slavelag_check { sub get_slave_lag {
my ($self, %args) = @_; my ($self, %args) = @_;
print "PLUGIN override_slavelag_check\n"; print "PLUGIN get_slave_lag\n";
return sub { return 0; }; return sub { return 0; };
} }

View File

@@ -59,7 +59,7 @@ my @called = $output =~ m/^PLUGIN \S+$/gm;
is_deeply( is_deeply(
\@called, \@called,
[ [
'PLUGIN override_slavelag_check', 'PLUGIN get_slave_lag',
'PLUGIN init', 'PLUGIN init',
'PLUGIN before_checksum_table', 'PLUGIN before_checksum_table',
'PLUGIN after_checksum_table', 'PLUGIN after_checksum_table',

View File

@@ -26,9 +26,9 @@ sub after_replicate_check {
print "PLUGIN after_replicate_check\n"; print "PLUGIN after_replicate_check\n";
} }
sub override_slavelag_check { sub get_slave_lag {
my ($self, %args) = @_; my ($self, %args) = @_;
print "PLUGIN override_slavelag_check\n"; print "PLUGIN get_slave_lag\n";
return sub { return 0; }; return sub { return 0; };
} }