| 1 | package ETLp::Plugin::Iterative::PLSQL; | ||
| 2 | |||
| 3 | use MooseX::Declare; | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | ETLp::Plugin::Iterative::SteadyStateCheck - Check that a file's size isn't | ||
| 8 | changing | ||
| 9 | |||
| 10 | =cut | ||
| 11 | |||
| 12 | class ETLp::Plugin::Iterative::SteadyStateCheck extends ETLp::Plugin { | ||
| 13 | |||
| 14 | sub type { | ||
| 15 | return 'steady_state_check'; | ||
| 16 | } | ||
| 17 | |||
| 18 | method run (Str $filename) { | ||
| 19 | my $interval = $self->item->{interval} || 5; | ||
| 20 | |||
| 21 | my $curr_size = -s $filename; | ||
| 22 | sleep $interval; | ||
| 23 | |||
| 24 | while ((-s $filename) != $curr_size) { | ||
| 25 | $curr_size = -s $filename; | ||
| 26 | sleep $interval; | ||
| 27 | } | ||
| 28 | |||
| 29 | return $filename; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | =head1 METHODS | ||
| 34 | |||
| 35 | =head2 type | ||
| 36 | |||
| 37 | Registers the plugin type. | ||
| 38 | |||
| 39 | =head2 run | ||
| 40 | |||
| 41 | Wait until the size of the supplied file stops changing. Will pause for | ||
| 42 | the interval defined in the item before repeating the check. The | ||
| 43 | interval defaults to five seconds if none is provided. | ||
| 44 | |||
| 45 | =head3 paramaters | ||
| 46 | |||
| 47 | * filename - the name of the file under consideration | ||
| 48 | |||
| 49 | -head3 returns | ||
| 50 | |||
| 51 | * filename - this will be the same as the supplied file name | ||
| 52 | |||
| 53 | |||
| 54 | =head1 LICENSE AND COPYRIGHT | ||
| 55 | |||
| 56 | Copyright 2010 Redbone Systems Ltd | ||
| 57 | |||
| 58 | This program is free software; you can redistribute it and/or modify it | ||
| 59 | under the terms of either: the GNU General Public License as published | ||
| 60 | by the Free Software Foundation; or the Artistic License. | ||
| 61 | |||
| 62 | The terms are in the LICENSE file that accompanies this application |