| 1 | package File::Rsync::Mirror::Recent; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # use warnings; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use File::Rsync::Mirror::Recentfile; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | File::Rsync::Mirror::Recent - mirroring via rsync made efficient | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | package File::Rsync::Mirror::Recent; | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | ▶ | use File::Basename qw(basename dirname fileparse); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 11 | ▶ | use File::Copy qw(cp); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | ▶ | use File::Path qw(mkpath); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | ▶ | use File::Rsync; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 11 | ▶ | use File::Rsync::Mirror::Recentfile::Done (); # at least needed by thaw() | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 11 | ▶ | use File::Rsync::Mirror::Recentfile::FakeBigFloat qw(:all); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 11 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | ▶ | use List::Pairwise qw(mapp grepp); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 11 | ▶ | use List::Util qw(first max); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | ▶ | use Scalar::Util qw(blessed reftype); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 11 | ▶ | use Storable; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | ▶ | use Time::HiRes qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 11 | ▶ | use YAML::Syck; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 11 | ▶ | use version; our $VERSION = qv('0.4.6'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | The documentation in here is normally not needed because the code is | ||||||||||||||||||||||||||||||||||||||||||
| 36 | considered to be run from several standalone programs. For a quick | ||||||||||||||||||||||||||||||||||||||||||
| 37 | overview, see the file README.mirrorcpan and the bin/ directory of the | ||||||||||||||||||||||||||||||||||||||||||
| 38 | distribution. For the architectural ideas see the section THE | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ARCHITECTURE OF A COLLECTION OF RECENTFILES below. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | File::Rsync::Mirror::Recent establishes a view on a collection of | ||||||||||||||||||||||||||||||||||||||||||
| 42 | File::Rsync::Mirror::Recentfile objects and provides abstractions | ||||||||||||||||||||||||||||||||||||||||||
| 43 | spanning multiple time intervals associated with those. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 EXPORT | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | No exports. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | =head1 CONSTRUCTORS | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | =head2 my $obj = CLASS->new(%hash) | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | Constructor. On every argument pair the key is a method name and the | ||||||||||||||||||||||||||||||||||||||||||
| 54 | value is an argument to that method name. | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 108 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 108 | my($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 108 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 108 | ▶ | while (@args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 114 | my($method,$arg) = splice @args, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 114 | $self->$method($arg); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 108 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | =head2 my $obj = CLASS->thaw($statusfile) | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | Constructor from a statusfile left over from a previous | ||||||||||||||||||||||||||||||||||||||||||
| 71 | rmirror run. See also C<runstatusfile>. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub _thaw_without_pathdb { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_thaw_without_pathdb: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my($self,$file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | open my $fh, $file or die "Can't open '$file': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | local $/ = "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $in_pathdb = 0; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $tfile = File::Temp->new | |||||||||||||||||||||||||||||||||||||||||
| 81 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 82 | TEMPLATE => "Recent-thaw-XXXX", | ||||||||||||||||||||||||||||||||||||||||||
| 83 | TMPDIR => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | UNLINK => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | CLEANUP => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | SUFFIX => '.dat', | ||||||||||||||||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $template_for_eop; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ($in_pathdb) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (/$template_for_eop/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $in_pathdb = 0; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | } elsif (/(\s+)-\s*__pathdb\s*:/) { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $in_pathdb = 1; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $next_attr = sprintf "^%s\\S", " ?" x length($1); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $template_for_eop = qr{$next_attr}; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | print $tfile $_ unless $in_pathdb; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | close $tfile or die "Could not close: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $return = $self->thaw($tfile->filename); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $return->_havelostpathdb(1); | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | unlink $tfile->filename; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub thaw { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
thaw: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | die "thaw called without statusfile argument" unless defined $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | unless (-e $file){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | Carp::confess("Alert: statusfile '$file' not found"); | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | require YAML::Syck; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $start = time; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $sleeptime = 0.02; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | while (not mkdir "$file.lock") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $err = $!; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | Time::HiRes::sleep $sleeptime; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $waiting = time - $start; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ($waiting >= 3){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | warn "*** waiting ($waiting) for lock ($err) ***"; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $sleeptime = 1; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $size = -s $file; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $serialized = YAML::Syck::LoadFile($file); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | rmdir "$file.lock" or die "Could not rmdir lockfile: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $charged_self = $serialized->{reduced_self}; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $class = blessed $self; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | bless $charged_self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $rfs = $serialized->{reduced_rfs}; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $rfclass = $class . "file"; # "Recent" . "file" | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $pathdb = $charged_self->_pathdb; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | for my $rf (@$rfs) { | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | bless $rf, $rfclass; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $rf->_pathdb($pathdb); | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $charged_self->_recentfiles($rfs); | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $charged_self->_principal_recentfile($rfs->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 141 | # die "FIXME: thaw all recentfiles from reduced_rfs into _recentfiles as well, watch out for pathdb and rsync"; | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return $charged_self; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | =head1 ACCESSORS | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 11 | my @accessors; | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 11 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 11 | @accessors = | |||||||||||||||||||||||||||||||||||||||||
| 153 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 154 | "__pathdb", | ||||||||||||||||||||||||||||||||||||||||||
| 155 | "_dirtymark", # keeps track of the dirtymark of the recentfiles | ||||||||||||||||||||||||||||||||||||||||||
| 156 | "_havelostpathdb", # boolean | ||||||||||||||||||||||||||||||||||||||||||
| 157 | "_have_written_statusfile", # boolean | ||||||||||||||||||||||||||||||||||||||||||
| 158 | "_logfilefordone", # turns on _logfile on all DONE | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # systems (disk intensive) | ||||||||||||||||||||||||||||||||||||||||||
| 160 | "_max_one_state", # when we have no time left but want | ||||||||||||||||||||||||||||||||||||||||||
| 161 | # at least get one file per | ||||||||||||||||||||||||||||||||||||||||||
| 162 | # iteration to avoid procrastination | ||||||||||||||||||||||||||||||||||||||||||
| 163 | "_principal_recentfile", | ||||||||||||||||||||||||||||||||||||||||||
| 164 | "_recentfiles", | ||||||||||||||||||||||||||||||||||||||||||
| 165 | "_rsync", | ||||||||||||||||||||||||||||||||||||||||||
| 166 | "_runstatusfile", # occasionally dumps all rfs | ||||||||||||||||||||||||||||||||||||||||||
| 167 | "_verbose", # internal variable for verbose setter/getter | ||||||||||||||||||||||||||||||||||||||||||
| 168 | "_verboselog", # internal variable for verboselog setter/getter | ||||||||||||||||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 11 | my @pod_lines = | |||||||||||||||||||||||||||||||||||||||||
| 172 | 11 | split /\n/, <<'=cut'; push @accessors, grep {s/^=item\s+//} @pod_lines; } | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | =item ignore_link_stat_errors | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | as in F:R:M:Recentfile | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | =item local | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | Option to specify the local principal file for operations with a local | ||||||||||||||||||||||||||||||||||||||||||
| 183 | collection of recentfiles. | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | =item localroot | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | as in F:R:M:Recentfile | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | =item max_files_per_connection | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | as in F:R:M:Recentfile | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | =item remote | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | The remote principal recentfile in rsync notation. E.g. | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | pause.perl.org::authors/RECENT.recent | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | =item remoteroot | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | as in F:R:M:Recentfile | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | =item remote_recentfile | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | Rsync address of the remote C<RECENT.recent> symlink or whichever name | ||||||||||||||||||||||||||||||||||||||||||
| 206 | the principal remote recentfile has. | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | =item rsync_options | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | Things like compress, links, times or checksums. Passed in to the | ||||||||||||||||||||||||||||||||||||||||||
| 211 | File::Rsync object used to run the mirror. Can be a hashref or an | ||||||||||||||||||||||||||||||||||||||||||
| 212 | arrayref. Depending on the version of File::Rsync it is passed on as a | ||||||||||||||||||||||||||||||||||||||||||
| 213 | hashref or as a flat list. | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | =item tempdir | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | as in F:R:M:Recentfile | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | =item ttl | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | Minimum time before fetching the principal recentfile again. | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 11 | ▶ | use accessors @accessors; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | =head2 $arrayref = $obj->news ( %options ) | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | Test this with: | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | perl -Ilib bin/rrr-news \ | ||||||||||||||||||||||||||||||||||||||||||
| 236 | -after 1217200539 \ | ||||||||||||||||||||||||||||||||||||||||||
| 237 | -max 12 \ | ||||||||||||||||||||||||||||||||||||||||||
| 238 | -local /home/ftp/pub/PAUSE/authors/RECENT.recent | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | perl -Ilib bin/rrr-news \ | ||||||||||||||||||||||||||||||||||||||||||
| 241 | -after 1217200539 \ | ||||||||||||||||||||||||||||||||||||||||||
| 242 | -rsync=compress=1 \ | ||||||||||||||||||||||||||||||||||||||||||
| 243 | -rsync=links=1 \ | ||||||||||||||||||||||||||||||||||||||||||
| 244 | -localroot /home/ftp/pub/PAUSE/authors/ \ | ||||||||||||||||||||||||||||||||||||||||||
| 245 | -remote pause.perl.org::authors/RECENT.recent | ||||||||||||||||||||||||||||||||||||||||||
| 246 | -verbose | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | All parameters that can be passed to | ||||||||||||||||||||||||||||||||||||||||||
| 249 | File:Rsync:Mirror:Recentfile::recent_events() can also be specified | ||||||||||||||||||||||||||||||||||||||||||
| 250 | here. | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | One additional option is supported. If C<$Options{callback}> is | ||||||||||||||||||||||||||||||||||||||||||
| 253 | specified, it must be a subref. This sub is called whenever one chunk | ||||||||||||||||||||||||||||||||||||||||||
| 254 | of events is found. The first argument to the callback is a reference | ||||||||||||||||||||||||||||||||||||||||||
| 255 | to the currently accumulated array of events. | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | Note: all data are kept in memory. | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 100 | ▶ | sub news { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
news: called CC=18 SCAR=43.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 100 | my($self, %opt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 100 | my $local = $self->local; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 100 | ▶ | unless ($local) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if (my $remote = $self->remote) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $localroot; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if ($localroot = $self->localroot) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | # nice, they know what they are doing | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | die "FIXME: remote called without localroot should trigger File::Temp.... TBD, sorry"; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | die "Alert: neither local nor remote specified, cannot continue"; | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 100 | my $rfs = $self->recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 100 | my $ret = []; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 100 | my $before; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 100 | for my $rf (@$rfs) { | |||||||||||||||||||||||||||||||||||||||||
| 280 | 500 | my %locopt = %opt; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 500 | $locopt{before} = $before; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 500 | ▶ | if ($opt{max}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $locopt{max} -= scalar @$ret; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | last if $locopt{max} <= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 500 | $locopt{info} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 500 | my $res = $rf->recent_events(%locopt); | |||||||||||||||||||||||||||||||||||||||||
| 288 | 500 | ▶ | if (@$res){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 500 | push @$ret, @$res; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 500 | ▶ | if ($opt{max} && scalar @$ret > $opt{max}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt{"max"} and scalar @$ret > $opt{"max"}
MC/DC0%0/2
$opt{"max"} and scalar @$ret > $opt{"max"}
$opt{"max"}
scalar @$ret > $opt{"max"}
Truth table33%1/3
A and B
A= $opt{"max"}B= scalar @$ret > $opt{"max"}
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 500 | ▶ | if ($opt{after}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ( $locopt{info}{last} && _bigfloatlt($locopt{info}{last}{epoch},$opt{after}) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$locopt{"info"}{"last"} and &_bigfloatlt($locopt{"info"}{"last"}{"epoch"}, $opt{"after"})
MC/DC0%0/2
$locopt{"info"}{"last"} and &_bigfloatlt($locopt{"info"}{"last"}{"epoch"}, $opt{"after"})
$locopt{"info"}{"last"}
&_bigfloatlt($locopt{"info"}{"last"}{"epoch"}, $opt{"after"})
Truth table0%0/3
A and B
A= $locopt{"info"}{"last"}B= &_bigfloatlt($locopt{"info"}{"last"}{"epoch"}, $opt{"after"})
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if ( _bigfloatgt($opt{after},$locopt{info}{first}{epoch}) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 500 | ▶ | if (!@$res){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 500 | $before = $res->[-1]{epoch}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 500 | ▶ | $before = $opt{before} if $opt{before} && _bigfloatlt($opt{before},$before); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt{"before"} and &_bigfloatlt($opt{"before"}, $before)
MC/DC0%0/2
$opt{"before"} and &_bigfloatlt($opt{"before"}, $before)
$opt{"before"}
&_bigfloatlt($opt{"before"}, $before)
Truth table33%1/3
A and B
A= $opt{"before"}B= &_bigfloatlt($opt{"before"}, $before)
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 500 | ▶ | if (my $sub = $opt{callback}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $sub->($ret); | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 100 | $ret; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | =head2 overview ( %options ) | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | returns a small table that summarizes the state of all recentfiles | ||||||||||||||||||||||||||||||||||||||||||
| 317 | collected in this Recent object. | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | $options{verbose}=1 increases the number of columns displayed. | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | Here is an example output: | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | Ival Cnt Max Min Span Util Cloud | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 1h 47 1225053014.38 1225049650.91 3363.47 93.4% ^ ^ | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 6h 324 1225052939.66 1225033394.84 19544.82 90.5% ^ ^ | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 1d 437 1225049651.53 1224966402.53 83248.99 96.4% ^ ^ | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 1W 1585 1225039015.75 1224435339.46 603676.29 99.8% ^ ^ | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 1M 5855 1225017376.65 1222428503.57 2588873.08 99.9% ^ ^ | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 1Q 17066 1224578930.40 1216803512.90 7775417.50 100.0% ^ ^ | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 1Y 15901 1223966162.56 1216766820.67 7199341.89 22.8% ^ ^ | ||||||||||||||||||||||||||||||||||||||||||
| 331 | Z 9909 1223966162.56 1216766820.67 7199341.89 - ^ ^ | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | I<Max> is the name of the interval. | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | I<Cnt> is the number of entries in this recentfile. | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | I<Max> is the highest(first) epoch in this recentfile, rounded. | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | I<Min> is the lowest(last) epoch in this recentfile, rounded. | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | I<Span> is the timespan currently covered, rounded. | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | I<Util> is I<Span> devided by the designated timespan of this | ||||||||||||||||||||||||||||||||||||||||||
| 344 | recentfile. | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | I<Cloud> is ascii art illustrating the sequence of the Max and Min | ||||||||||||||||||||||||||||||||||||||||||
| 347 | timestamps. | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 2 | ▶ | sub overview { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
overview: called CC=14 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 2 | my($self,%options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 2 | my $rfs = $self->recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 2 | my(@s,%rank); | |||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | RECENTFILE: for my $rf (@$rfs) { | |||||||||||||||||||||||||||||||||||||||||
| 355 | 12 | my $re=$rf->recent_events; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 12 | my $rfsummary; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 12 | ▶ | if (@$re) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 12 | my $span = $re->[0]{epoch}-$re->[-1]{epoch}; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 12 | my $merged = $rf->merged; | |||||||||||||||||||||||||||||||||||||||||
| 360 | $rfsummary = | ||||||||||||||||||||||||||||||||||||||||||
| 361 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 362 | "Ival", | ||||||||||||||||||||||||||||||||||||||||||
| 363 | $rf->interval, | ||||||||||||||||||||||||||||||||||||||||||
| 364 | "Cnt", | ||||||||||||||||||||||||||||||||||||||||||
| 365 | scalar @$re, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | "Dirtymark", | ||||||||||||||||||||||||||||||||||||||||||
| 367 | $rf->dirtymark ? sprintf("%.2f",$rf->dirtymark) : "-", | ||||||||||||||||||||||||||||||||||||||||||
| 368 | "Produced", | ||||||||||||||||||||||||||||||||||||||||||
| 369 | sprintf ("%.2f", $rf->{ORIG}{Producers}{time}||0), | ||||||||||||||||||||||||||||||||||||||||||
| 370 | "Merged", | ||||||||||||||||||||||||||||||||||||||||||
| 371 | ($rf->interval eq "Z" | ||||||||||||||||||||||||||||||||||||||||||
| 372 | ? | ||||||||||||||||||||||||||||||||||||||||||
| 373 | "-" | ||||||||||||||||||||||||||||||||||||||||||
| 374 | : | ||||||||||||||||||||||||||||||||||||||||||
| 375 | sprintf ("%.2f", $merged->{epoch} || 0)), | ||||||||||||||||||||||||||||||||||||||||||
| 376 | "Max", | ||||||||||||||||||||||||||||||||||||||||||
| 377 | sprintf ("%.2f", $re->[0]{epoch}), | ||||||||||||||||||||||||||||||||||||||||||
| 378 | "Min", | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 12 | ▶ | sprintf ("%.2f", $re->[-1]{epoch}), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition50%2/4
$rf->{'ORIG'}{'Producers'}{'time'} || 0
$merged->{'epoch'} || 0
MC/DC0%0/1
$rf->{'ORIG'}{'Producers'}{'time'} || 0
$rf->{'ORIG'}{'Producers'}{'time'}
MC/DC0%0/1
$merged->{'epoch'} || 0
$merged->{'epoch'}
Truth table50%1/2
A
A= $rf->{'ORIG'}{'Producers'}{'time'}
Truth table50%1/2
A
A= $merged->{'epoch'}
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | "Span", | ||||||||||||||||||||||||||||||||||||||||||
| 381 | sprintf ("%.2f", $span), | ||||||||||||||||||||||||||||||||||||||||||
| 382 | "Util", # u9n:) | ||||||||||||||||||||||||||||||||||||||||||
| 383 | ($rf->interval eq "Z" | ||||||||||||||||||||||||||||||||||||||||||
| 384 | ? | ||||||||||||||||||||||||||||||||||||||||||
| 385 | "-" | ||||||||||||||||||||||||||||||||||||||||||
| 386 | : | ||||||||||||||||||||||||||||||||||||||||||
| 387 | sprintf ("%5.1f%%", 100 * $span / $rf->interval_secs) | ||||||||||||||||||||||||||||||||||||||||||
| 388 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 389 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 12 | ▶ | @rank{mapp {$b} grepp {$a =~ /^(Max|Min)$/} @$rfsummary} = (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | next RECENTFILE; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 12 | push @s, $rfsummary; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 2 | @rank{sort {$b <=> $a} keys %rank} = 1..keys %rank; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 2 | my $maxrank = max values %rank; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 2 | for my $rfsummary (@s) { | |||||||||||||||||||||||||||||||||||||||||
| 399 | 12 | my $string = " " x $maxrank; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 12 | my @borders; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 12 | for my $ele (qw(Max Min)) { | |||||||||||||||||||||||||||||||||||||||||
| 402 | 24 | ▶ | my($r) = mapp {$b} grepp {$a eq $ele} @$rfsummary; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 24 | push @borders, $rank{$r}-1; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 12 | for ($borders[0],$borders[1]) { | |||||||||||||||||||||||||||||||||||||||||
| 406 | 24 | substr($string,$_,1) = "^"; | |||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 12 | push @$rfsummary, "Cloud", $string; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | ▶ | unless ($options{verbose}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | my %filter = map {($_=>1)} qw(Ival Cnt Max Min Span Util Cloud); | |||||||||||||||||||||||||||||||||||||||||
| 412 | 2 | for (@s) { | |||||||||||||||||||||||||||||||||||||||||
| 413 | 12 | ▶ | $_ = [mapp {($a,$b)} grepp {!!$filter{$a}} @$_]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | my @sprintf; | |||||||||||||||||||||||||||||||||||||||||
| 417 | 2 | ▶ | for (my $i = 0; $i <= $#{$s[0]}; $i+=2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 14 | my $maxlength = max ((map { length $_->[$i+1] } @s), length $s[0][$i]); | |||||||||||||||||||||||||||||||||||||||||
| 419 | 14 | push @sprintf, "%" . $maxlength . "s"; | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | 2 | my $sprintf = join " ", @sprintf; | |||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | $sprintf .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 423 | 2 | ▶ | my $headline = sprintf $sprintf, mapp {$a} @{$s[0]}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 2 | ▶ | join "", $headline, map { sprintf $sprintf, mapp {$b} @$_ } @s; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | =head2 _pathdb | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | Keeping track of already handled files. Currently it is a hash, will | ||||||||||||||||||||||||||||||||||||||||||
| 430 | probably become a database with its own accessors. | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 108 | ▶ | sub _pathdb { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pathdb: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 108 | my($self, $set) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 436 | 108 | ▶ | if ($set) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $self->__pathdb ($set); | |||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 108 | my $pathdb = $self->__pathdb; | |||||||||||||||||||||||||||||||||||||||||
| 440 | 108 | ▶ | unless (defined $pathdb) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 108 | $self->__pathdb(+{}); | |||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 108 | return $self->__pathdb; | |||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | =head2 $recentfile = $obj->principal_recentfile () | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | returns the principal recentfile object of this tree. | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 451 | # mirrors the recentfile and instantiates the recentfile object | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | sub _principal_recentfile_fromremote { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_principal_recentfile_fromremote: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 454 | # get the remote recentfile | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | my $rrfile = $self->remote or die "Alert: cannot construct a recentfile object without the 'remote' attribute"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my $splitter = qr{(.+)/([^/]*)}; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my($remoteroot,$rfilename) = $rrfile =~ $splitter; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $self->remoteroot($remoteroot); | |||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my($abslfile, $fh); | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | if (!defined $rfilename) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | die "Alert: Cannot resolve '$rrfile', does not match $splitter"; | |||||||||||||||||||||||||||||||||||||||||
| 462 | ▶ | } elsif (not length $rfilename or $rfilename eq "RECENT.recent") { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not length $rfilename or $rfilename eq "RECENT.recent"
MC/DC0%0/2
not length $rfilename or $rfilename eq "RECENT.recent"
not length $rfilename
$rfilename eq "RECENT.recent"
Truth table0%0/3
not(A) or B
A= not length $rfilenameB= $rfilename eq "RECENT.recent"
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ($abslfile,$rfilename,$fh) = $self->_principal_recentfile_fromremote_resosymlink($rfilename); | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my @need_args = | |||||||||||||||||||||||||||||||||||||||||
| 466 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 467 | "ignore_link_stat_errors", | ||||||||||||||||||||||||||||||||||||||||||
| 468 | "localroot", | ||||||||||||||||||||||||||||||||||||||||||
| 469 | "max_files_per_connection", | ||||||||||||||||||||||||||||||||||||||||||
| 470 | "remoteroot", | ||||||||||||||||||||||||||||||||||||||||||
| 471 | "rsync_options", | ||||||||||||||||||||||||||||||||||||||||||
| 472 | "tempdir", | ||||||||||||||||||||||||||||||||||||||||||
| 473 | "ttl", | ||||||||||||||||||||||||||||||||||||||||||
| 474 | "verbose", | ||||||||||||||||||||||||||||||||||||||||||
| 475 | "verboselog", | ||||||||||||||||||||||||||||||||||||||||||
| 476 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my $rf0; | |||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | unless ($abslfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $rf0 = File::Rsync::Mirror::Recentfile->new (map {($_ => $self->$_)} @need_args); | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $rf0->split_rfilename($rfilename); | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $abslfile = $rf0->get_remote_recentfile_as_tempfile (); | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $rf0 = File::Rsync::Mirror::Recentfile->new_from_file ( $abslfile ); | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $rf0->_current_tempfile ( $abslfile ); | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $rf0->_current_tempfile_fh ( $fh ); | |||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $rf0->_use_tempfile (1); | |||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | for my $override (@need_args) { | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $rf0->$override ( $self->$override ); | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $rf0->is_slave (1); | |||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | return $rf0; | |||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 108 | ▶ | sub principal_recentfile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
principal_recentfile: called CC=5 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 108 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 108 | my $rf0 = $self->_principal_recentfile; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 108 | ▶ | return $rf0 if defined $rf0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 108 | my $local = $self->local; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 108 | ▶ | if ($local) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 108 | $rf0 = File::Rsync::Mirror::Recentfile->new_from_file ($local); | |||||||||||||||||||||||||||||||||||||||||
| 500 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if (my $remote = $self->remote) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my $localroot; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if ($localroot = $self->localroot) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | # nice, they know what they are doing | ||||||||||||||||||||||||||||||||||||||||||
| 505 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | die "FIXME: remote called without localroot should trigger File::Temp.... TBD, sorry"; | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $rf0 = $self->_principal_recentfile_fromremote; | |||||||||||||||||||||||||||||||||||||||||
| 509 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | die "Alert: neither local nor remote specified, cannot continue"; | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 513 | 108 | $self->_principal_recentfile($rf0); | |||||||||||||||||||||||||||||||||||||||||
| 514 | 108 | return $rf0; | |||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | =head2 $recentfiles_arrayref = $obj->recentfiles () | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | returns a reference to the complete list of recentfile objects that | ||||||||||||||||||||||||||||||||||||||||||
| 520 | describe this tree. No guarantee is given that the represented | ||||||||||||||||||||||||||||||||||||||||||
| 521 | recentfiles exist or have been read. They are just bare objects. | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 114 | ▶ | sub recentfiles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recentfiles: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | 114 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 527 | 114 | my $rfs = $self->_recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 528 | 114 | ▶ | return $rfs if defined $rfs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | 108 | my $rf0 = $self->principal_recentfile; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 108 | my $pathdb = $self->_pathdb; | |||||||||||||||||||||||||||||||||||||||||
| 531 | 108 | $rf0->_pathdb ($pathdb); | |||||||||||||||||||||||||||||||||||||||||
| 532 | 108 | my $aggregator = $rf0->aggregator; | |||||||||||||||||||||||||||||||||||||||||
| 533 | 108 | my @rf = $rf0; | |||||||||||||||||||||||||||||||||||||||||
| 534 | 108 | for my $agg (@$aggregator) { | |||||||||||||||||||||||||||||||||||||||||
| 535 | 440 | my $nrf = $rf0->_sparse_clone; | |||||||||||||||||||||||||||||||||||||||||
| 536 | 440 | $nrf->interval ( $agg ); | |||||||||||||||||||||||||||||||||||||||||
| 537 | 440 | $nrf->have_mirrored ( 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 538 | 440 | $nrf->_pathdb ( $pathdb ); | |||||||||||||||||||||||||||||||||||||||||
| 539 | 440 | push @rf, $nrf; | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 108 | $self->_recentfiles(\@rf); | |||||||||||||||||||||||||||||||||||||||||
| 542 | 108 | return \@rf; | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | =head2 $success = $obj->rmirror ( %options ) | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | Mirrors all recentfiles of the I<remote> address working through all | ||||||||||||||||||||||||||||||||||||||||||
| 548 | of them, mirroring their contents. | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | Test this with: | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | use File::Rsync::Mirror::Recent; | ||||||||||||||||||||||||||||||||||||||||||
| 553 | my $rrr = File::Rsync::Mirror::Recent->new( | ||||||||||||||||||||||||||||||||||||||||||
| 554 | ignore_link_stat_errors => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 555 | localroot => "/home/ftp/pub/PAUSE/authors", | ||||||||||||||||||||||||||||||||||||||||||
| 556 | remote => "pause.perl.org::authors/RECENT.recent", | ||||||||||||||||||||||||||||||||||||||||||
| 557 | max_files_per_connection => 5000, | ||||||||||||||||||||||||||||||||||||||||||
| 558 | rsync_options => { | ||||||||||||||||||||||||||||||||||||||||||
| 559 | compress => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 560 | links => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 561 | times => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 562 | checksum => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 563 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 564 | verbose => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 565 | _runstatusfile => "recent-rmirror-state.yml", | ||||||||||||||||||||||||||||||||||||||||||
| 566 | _logfilefordone => "recent-rmirror-donelog.log", | ||||||||||||||||||||||||||||||||||||||||||
| 567 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 568 | $rrr->rmirror ( "skip-deletes" => 1, loop => 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | Or try without the loop parameter and write the loop yourself: | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | use File::Rsync::Mirror::Recent; | ||||||||||||||||||||||||||||||||||||||||||
| 573 | my @rrr; | ||||||||||||||||||||||||||||||||||||||||||
| 574 | for my $t ("authors","modules"){ | ||||||||||||||||||||||||||||||||||||||||||
| 575 | my $rrr = File::Rsync::Mirror::Recent->new( | ||||||||||||||||||||||||||||||||||||||||||
| 576 | ignore_link_stat_errors => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 577 | localroot => "/home/ftp/pub/PAUSE/$t", | ||||||||||||||||||||||||||||||||||||||||||
| 578 | remote => "pause.perl.org::$t/RECENT.recent", | ||||||||||||||||||||||||||||||||||||||||||
| 579 | max_files_per_connection => 512, | ||||||||||||||||||||||||||||||||||||||||||
| 580 | rsync_options => { | ||||||||||||||||||||||||||||||||||||||||||
| 581 | compress => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 582 | links => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 583 | times => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 584 | checksum => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 585 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 586 | verbose => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 587 | _runstatusfile => "recent-rmirror-state-$t.yml", | ||||||||||||||||||||||||||||||||||||||||||
| 588 | _logfilefordone => "recent-rmirror-donelog-$t.log", | ||||||||||||||||||||||||||||||||||||||||||
| 589 | ttl => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 590 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 591 | push @rrr, $rrr; | ||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | while (){ | ||||||||||||||||||||||||||||||||||||||||||
| 594 | for my $rrr (@rrr){ | ||||||||||||||||||||||||||||||||||||||||||
| 595 | $rrr->rmirror ( "skip-deletes" => 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | warn "sleeping 23\n"; sleep 23; | ||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 602 | # _alluptodate is unused but at least it worked last time I needed it, | ||||||||||||||||||||||||||||||||||||||||||
| 603 | # so let us keep it around | ||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | sub _alluptodate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_alluptodate: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my $sdm = $self->_dirtymark; | |||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | return unless defined $sdm; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | for my $rf (@{$self->recentfiles}) { | |||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | return if $rf->seeded; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my $rfdm = $rf->dirtymark; | |||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | return unless defined $rfdm; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | return unless $rfdm eq $sdm; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my $done = $rf->done; | |||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | return unless defined $done; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my $done_intervals = $done->_intervals; | |||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | return if !defined $done_intervals; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | # nonono, may be more than one, only covered it must be: | ||||||||||||||||||||||||||||||||||||||||||
| 618 | # return if @$done_intervals > 1; | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my $minmax = $rf->minmax; | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | return unless defined $minmax; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | return unless $done->covered(@$minmax{qw(max min)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | # $DB::single++; | ||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | sub _fullseed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fullseed: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | for ( @{$self->recentfiles} ) { $_->seed(1) } | |||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | sub rmirror { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rmirror: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my($self, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $rfs = $self->recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $self->principal_recentfile->seed; | |||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | my $_sigint = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 637 | # XXX exit gracefully (reminder) | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | # XXX needs accessor: warning, if set too low, we do nothing but | ||||||||||||||||||||||||||||||||||||||||||
| 641 | # mirror the principal! | ||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | my $minimum_time_per_loop = 20; | |||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | if (my $logfile = $self->_logfilefordone) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | for my $i (0..$#$rfs) { | |||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $rfs->[$i]->done->_logfile($logfile); | |||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | if (my $dirtymark = $self->principal_recentfile->dirtymark) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $mydm = $self->_dirtymark; | |||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if (!defined $mydm){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $self->_dirtymark($dirtymark); | |||||||||||||||||||||||||||||||||||||||||
| 653 | } elsif ($dirtymark ne $mydm) { | ||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if ($self->verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | if (my $vl = $self->verboselog) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | open $fh, ">>", $vl or die "Could not open >> '$vl': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 658 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $fh = \*STDERR; | |||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | print $fh "NewDirtymark: old[$mydm] new[$dirtymark]\n"; | |||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $self->_dirtymark($dirtymark); | |||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my $rstfile = $self->runstatusfile; | |||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | unless ($self->_have_written_statusfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $self->_rmirror_runstatusfile_write ($rstfile, \%options); | |||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $self->_have_written_statusfile(1); | |||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $self->_rmirror_loop($minimum_time_per_loop,\%options); | |||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | sub _rmirror_loop { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rmirror_loop: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | my($self,$minimum_time_per_loop,$options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | LOOP: while () { | |||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my $ttleave = time + $minimum_time_per_loop; | |||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | my $rstfile = $self->runstatusfile; | |||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my $otherproc = $self->_thaw_without_pathdb ($rstfile); | |||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my $pid = fork; | |||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | if (! defined $pid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | warn "Contention: $!"; | |||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | sleep 0.25; | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | next LOOP; | |||||||||||||||||||||||||||||||||||||||||
| 685 | } elsif ($pid) { | ||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | waitpid($pid,0); | |||||||||||||||||||||||||||||||||||||||||
| 687 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | $self = $self->thaw ($rstfile); | |||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my $rfs = $self->recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | $self->principal_recentfile->seed; | |||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | RECENTFILE: for my $i (0..$#$rfs) { | |||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my $rf = $rfs->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if (time > $ttleave) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | # Must make sure that one file can get fetched in any case | ||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $self->_max_one_state(1); | |||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | if ($rf->seeded) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $self->_rmirror_mirror ($i, $options); | |||||||||||||||||||||||||||||||||||||||||
| 699 | } elsif ($rf->uptodate) { | ||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | if ($i < $#$rfs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | $rfs->[$i+1]->done->merge($rf->done); | |||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||
| 703 | # no further seed necessary because "periodic" does it | ||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | next RECENTFILE; | |||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | WORKUNIT: while (time < $ttleave) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ▶ | if ($rf->uptodate) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $self->_rmirror_sleep_per_connection ($i); | |||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | next RECENTFILE; | |||||||||||||||||||||||||||||||||||||||||
| 710 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | $self->_rmirror_mirror ($i, $options); | |||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | if ($self->_max_one_state) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | last RECENTFILE; | |||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | $self->_max_one_state(0); | |||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | my $exit = 0; | |||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | if ($rfs->[-1]->uptodate) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | $self->_rmirror_cleanup; | |||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | unless ($options->{loop}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | $exit = 1; | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | $self->_rmirror_runstatusfile_write ($rstfile, $options); | |||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | exit if $exit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | last LOOP; | |||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | $otherproc = $self->_thaw_without_pathdb ($rstfile); | |||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | if (!$options->{loop} && $otherproc && $otherproc->recentfiles->[-1]->uptodate) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $options->{"loop"} and $otherproc and $otherproc->recentfiles->[-1]->uptodate
not $options->{"loop"} and $otherproc
MC/DC0%0/3
not $options->{"loop"} and $otherproc and $otherproc->recentfiles->[-1]->uptodate
not $options->{"loop"}
$otherproc
$otherproc->recentfiles->[-1]->uptodate
Truth table0%0/4
not(A) and B and C
A= not $options->{"loop"}B= $otherprocC= $otherproc->recentfiles->[-1]->uptodate
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | last LOOP; | |||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $sleep = $ttleave - time; | |||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | if ($sleep > 0.01) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $self->_rmirror_endofloop_sleep ($sleep); | |||||||||||||||||||||||||||||||||||||||||
| 738 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 739 | # negative time not invented yet:) | ||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | sub _rmirror_mirror { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rmirror_mirror: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | my($self, $i, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my $rfs = $self->recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | my $rf = $rfs->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my %locopt = %$options; | |||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | if ($self->_max_one_state) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | $locopt{max} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $locopt{piecemeal} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $rf->mirror (%locopt); | |||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | if ($i==0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 755 | # we limit to 0 for the case that upstream is broken and has | ||||||||||||||||||||||||||||||||||||||||||
| 756 | # more than one timestamp (happened on PAUSE 200903) | ||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | if (my $dirtymark = $rf->dirtymark) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | my $mydm = $self->_dirtymark; | |||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | if (!defined $mydm or $dirtymark ne $mydm) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $mydm or $dirtymark ne $mydm
MC/DC0%0/2
not defined $mydm or $dirtymark ne $mydm
not defined $mydm
$dirtymark ne $mydm
Truth table0%0/3
not(A) or B
A= not defined $mydmB= $dirtymark ne $mydm
| |||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $self->_dirtymark($dirtymark); | |||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $self->_fullseed; | |||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | sub _rmirror_sleep_per_connection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rmirror_sleep_per_connection: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my($self, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | my $rfs = $self->recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | my $rf = $rfs->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | my $sleep = $rf->sleep_per_connection; | |||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | $sleep = 0.42 unless defined $sleep; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | Time::HiRes::sleep $sleep; | |||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | $rfs->[$i+1]->done->merge($rf->done) if $i < $#$rfs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | sub _rmirror_cleanup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rmirror_cleanup: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | my $pathdb = $self->_pathdb(); | |||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | for my $k (keys %$pathdb) { | |||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | delete $pathdb->{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | my $rfs = $self->recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | for my $i (0..$#$rfs-1) { | |||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | my $thismerged = $rfs->[$i]->merged; | |||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my $next = $rfs->[$i+1]; | |||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | my $nextminmax = $next->minmax; | |||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | if (not defined $thismerged->{epoch} or _bigfloatlt($nextminmax->{max},$thismerged->{epoch})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $thismerged->{"epoch"} or &_bigfloatlt($nextminmax->{"max"}, $thismerged->{"epoch"})
MC/DC0%0/2
not defined $thismerged->{"epoch"} or &_bigfloatlt($nextminmax->{"max"}, $thismerged->{"epoch"})
not defined $thismerged->{"epoch"}
&_bigfloatlt($nextminmax->{"max"}, $thismerged->{"epoch"})
Truth table0%0/3
not(A) or B
A= not defined $thismerged->{"epoch"}B= &_bigfloatlt($nextminmax->{"max"}, $thismerged->{"epoch"})
| |||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | $next->seed; | |||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||
| 794 | =head2 $file = $obj->runstatusfile ($set) | ||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | Getter/setter for C<_runstatusfile> attribute. Defaults to a temporary | ||||||||||||||||||||||||||||||||||||||||||
| 797 | file created by C<File::Temp>. A status file is required for | ||||||||||||||||||||||||||||||||||||||||||
| 798 | C<rmirror> working. Since it may be interesting for debugging | ||||||||||||||||||||||||||||||||||||||||||
| 799 | purposes, you may want to specify a permanent file for this. | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | sub runstatusfile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
runstatusfile: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | my($self,$set) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | if (defined $set) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $self->_runstatusfile ($set); | |||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | my $x = $self->_runstatusfile; | |||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | unless (defined $x) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | require File::Temp; | |||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | my $tfile = File::Temp->new | |||||||||||||||||||||||||||||||||||||||||
| 811 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 812 | TEMPLATE => "Recent-XXXX", | ||||||||||||||||||||||||||||||||||||||||||
| 813 | TMPDIR => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 814 | UNLINK => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 815 | CLEANUP => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 816 | SUFFIX => '.dat', | ||||||||||||||||||||||||||||||||||||||||||
| 817 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | $self->_runstatusfile($tfile->filename); | |||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | return $self->_runstatusfile; | |||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | # unused code.... it was an oops, discovered the thaw() method too | ||||||||||||||||||||||||||||||||||||||||||
| 824 | # late, and starting writing this here.... | ||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | sub _rmirror_runstatusfile_read { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rmirror_runstatusfile_read: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | my($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | require YAML::Syck; | |||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | my $start = time; | |||||||||||||||||||||||||||||||||||||||||
| 830 | # XXX is locking useful here? | ||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | ▶ | while (not mkdir "$file.lock") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | Time::HiRes::sleep 0.2; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | warn "*** waiting for lock ***" if time - $start >= 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my $yml = YAML::Syck::LoadFile $file; | |||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | rmdir "$file.lock" or die "Could not rmdir lockfile: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | my $rself = $yml->{reduced_self}; | |||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my $rfs = $yml->{reduced_rfs}; | |||||||||||||||||||||||||||||||||||||||||
| 839 | # XXX bring them into self | ||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | sub _rmirror_runstatusfile_write { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rmirror_runstatusfile_write: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | my($self, $file, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | my $rself; | |||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | ▶ | while (my($k,$v) = each %$self) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | next if $k =~ /^-(_principal_recentfile|_recentfiles)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | $rself->{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | my $rfs = $self->recentfiles; | |||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $rrfs; | |||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | for my $i (0..$#$rfs) { | |||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my $rf = $rfs->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | while (my($k,$v) = each %$rf) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | ▶ | next if $k =~ /^-(_current_tempfile_fh|_pathdb|_rsync)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | $rrfs->[$i]{$k} = $rfs->[$i]{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | require YAML::Syck; | |||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my $start = time; | |||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | ▶ | while (not mkdir "$file.lock") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | Time::HiRes::sleep 0.15; | |||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | warn "*** waiting for lock directory '$file.lock' ***" if time - $start >= 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||
| 864 | YAML::Syck::DumpFile | ||||||||||||||||||||||||||||||||||||||||||
| 865 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | "$file.new", | |||||||||||||||||||||||||||||||||||||||||
| 867 | { | ||||||||||||||||||||||||||||||||||||||||||
| 868 | options => $options, | ||||||||||||||||||||||||||||||||||||||||||
| 869 | time => time, | ||||||||||||||||||||||||||||||||||||||||||
| 870 | reduced_rfs => $rrfs, | ||||||||||||||||||||||||||||||||||||||||||
| 871 | reduced_self => $rself, | ||||||||||||||||||||||||||||||||||||||||||
| 872 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | rename "$file.new", $file or die "Could not rename: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | rmdir "$file.lock" or die "Could not rmdir lockfile: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | sub _rmirror_endofloop_sleep { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rmirror_endofloop_sleep: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | my($self, $sleep) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | if ($self->verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | if (my $vl = $self->verboselog) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | ▶ | open $fh, ">>", $vl or die "Could not open >> '$vl': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 883 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $fh = \*STDERR; | |||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | printf $fh | |||||||||||||||||||||||||||||||||||||||||
| 887 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 888 | "Dorm %d (%s secs)\n", | ||||||||||||||||||||||||||||||||||||||||||
| 889 | time, | ||||||||||||||||||||||||||||||||||||||||||
| 890 | $sleep, | ||||||||||||||||||||||||||||||||||||||||||
| 891 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | sleep $sleep; | |||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | # it returns two things: abslfile and rfilename. But the abslfile is | ||||||||||||||||||||||||||||||||||||||||||
| 897 | # undef when the rfilename ends in .recent. A weird interface, my | ||||||||||||||||||||||||||||||||||||||||||
| 898 | # friend. | ||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | sub _principal_recentfile_fromremote_resosymlink { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_principal_recentfile_fromremote_resosymlink: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my($self, $rfilename) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | $rfilename = "RECENT.recent" unless length $rfilename; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | my $abslfile = undef; | |||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | ▶ | if ($rfilename =~ /\.recent$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 905 | # may be a file *or* a symlink, | ||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ($abslfile,$fh) = $self->_fetch_as_tempfile ($rfilename); | |||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | while (-l $abslfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $symlink = readlink $abslfile; | |||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | ▶ | if ($symlink =~ m|/|) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | die "FIXME: filenames containing '/' not supported, got '$symlink'"; | |||||||||||||||||||||||||||||||||||||||||
| 911 | } | ||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my $localrfile = File::Spec->catfile($self->localroot, $rfilename); | |||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | if (-e $localrfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | my $old_symlink = readlink $localrfile; | |||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | ▶ | if ($old_symlink eq $symlink) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ▶ | unlink $abslfile or die "Cannot unlink '$abslfile': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 917 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | unlink $localrfile; # may fail | |||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | rename $abslfile, $localrfile or die "Cannot rename to '$localrfile': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||
| 921 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | rename $abslfile, $localrfile or die "Cannot rename to '$localrfile': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | ($abslfile,$fh) = $self->_fetch_as_tempfile ($symlink); | |||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | return ($abslfile, $rfilename, $fh); | |||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | # takes a basename, returns an absolute name, does not delete the | ||||||||||||||||||||||||||||||||||||||||||
| 931 | # file, throws the $fh away. Caller must rename or unlink | ||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||
| 933 | # XXX needs to activate the fh in the rf0 so that it is able to unlink | ||||||||||||||||||||||||||||||||||||||||||
| 934 | # the file. I would like that the file is used immediately by $rf0 | ||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | sub _fetch_as_tempfile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_as_tempfile: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | my($self, $rfile) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | my($suffix) = $rfile =~ /(\.[^\.]+)$/; | |||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | ▶ | $suffix = "" unless defined $suffix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | my $fh = File::Temp->new | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->tempdir || $self->localroot
MC/DC0%0/2
$self->tempdir || $self->localroot
$self->tempdir
$self->localroot
Truth table0%0/3
A || B
A= $self->tempdirB= $self->localroot
| |||||||||||||||||||||||||||||||||||||||||||
| 940 | (TEMPLATE => sprintf(".FRMRecent-%s-XXXX", | ||||||||||||||||||||||||||||||||||||||||||
| 941 | $rfile, | ||||||||||||||||||||||||||||||||||||||||||
| 942 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 943 | DIR => $self->tempdir || $self->localroot, | ||||||||||||||||||||||||||||||||||||||||||
| 944 | SUFFIX => $suffix, | ||||||||||||||||||||||||||||||||||||||||||
| 945 | UNLINK => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 946 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | my $rsync; | |||||||||||||||||||||||||||||||||||||||||
| 948 | my @rsync_options; | ||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | if (my $rso = $self->rsync_options) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | ▶ | if (ref $rso eq "HASH") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | @rsync_options = %$rso; | |||||||||||||||||||||||||||||||||||||||||
| 952 | } elsif (ref $rso eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | @rsync_options = @$rso; | |||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||
| 955 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | @rsync_options = (); | |||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | if ($File::Rsync::VERSION <= 0.45) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | $rsync = File::Rsync->new({@rsync_options}); | |||||||||||||||||||||||||||||||||||||||||
| 960 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | $rsync = File::Rsync->new(@rsync_options); | |||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | unless ($rsync) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | Carp::confess(YAML::Syck::Dump($self->rsync_options)); | |||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | my $dst = $fh->filename; | |||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | local($ENV{LANG}) = "C"; | |||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | $rsync->exec | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 970 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 971 | src => join("/",$self->remoteroot,$rfile), | ||||||||||||||||||||||||||||||||||||||||||
| 972 | dst => $dst, | ||||||||||||||||||||||||||||||||||||||||||
| 973 | ) or die "Could not mirror '$rfile' to $fh\: ".join(" ",$rsync->err); | ||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | ▶ | unless (-l $dst) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | my $mode = 0644; | |||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | chmod $mode, $dst or die "Could not chmod $mode '$dst': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | return($dst,$fh); | |||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | =head2 $verbose = $obj->verbose ( $set ) | ||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | Getter/setter method to set verbosity for this F:R:M:Recent object and | ||||||||||||||||||||||||||||||||||||||||||
| 984 | all associated Recentfile objects. | ||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | sub verbose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | my($self,$set) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | if (defined $set) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | for ( @{$self->recentfiles} ) { $_->verbose($set) } | |||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | $self->_verbose ($set); | |||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | my $x = $self->_verbose; | |||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | ▶ | unless (defined $x) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $x = 0; | |||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | $self->_verbose ($x); | |||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | return $x; | |||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||
| 1002 | =head2 my $vl = $obj->verboselog ( $set ) | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | Getter/setter method for the path to the logfile to write verbose | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | progress information to. | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||
| 1007 | Note: This is a primitive stop gap solution to get simple verbose | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | logging working. The program still sends error messages to STDERR. | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | Switching to Log4perl or similar is probably the way to go. TBD. | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ▶ | sub verboselog { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verboselog: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | my($self,$set) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | if (defined $set) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | for ( @{$self->recentfiles} ) { $_->verboselog($set) } | |||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | $self->_verboselog ($set); | |||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | my $x = $self->_verboselog; | |||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | ▶ | unless (defined $x) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | $x = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | $self->_verboselog ($x); | |||||||||||||||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | return $x; | |||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||
| 1026 | =head1 THE ARCHITECTURE OF A COLLECTION OF RECENTFILES | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | The idea is that we want to have a short file that records really | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | recent changes. So that a fresh mirror can be kept fresh as long as | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | the connectivity is given. Then we want longer files that record the | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | history before. So when the mirror falls behind the update period | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | reflected in the shortest file, it can complement the list of recent | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | file events with the next one. And if this is not long enough we want | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | another one, again a bit longer. And we want one that completes the | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | history back to the oldest file. The index files together do contain | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | the complete list of current files. The longer a period covered by an | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | index file is gone the less often the index file is updated. For | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | practical reasons adjacent files will often overlap a bit but this is | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | neither necessary nor enforced. Enforced is only that there must not | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | ever be a gap between two adjacent index files that would have to | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | contain a file reference. That's the basic idea. The following example | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | represents a tree that has a few updates every day: | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | RECENT.recent -> RECENT-1h.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | RECENT-1h.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | RECENT-6h.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | RECENT-1d.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | RECENT-1M.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | RECENT-1W.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | RECENT-1Q.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | RECENT-1Y.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | RECENT-Z.yaml | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||
| 1054 | Each of these files represents a contract to hold a record for every | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | filesystem event within the period indicated in the filename. | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | The first file is the principal file, in so far it is the one that is | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | written first after a filesystem change. Usually a symlink links to it | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | with a filename that has the same filenameroot and the suffix | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | C<.recent>. On systems that do not support symlinks there is a plain | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | copy maintained instead. | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||
| 1063 | The last file, the Z file, contains the complementary files that are | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | in none of the other files. It may contain C<delete> events but often | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | C<delete> events are discarded at the transition to the Z file. | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||
| 1067 | =head2 SITE SEEING TOUR | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||
| 1069 | This section illustrates the operation of a server-client couple in a | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | fictious installation that has to deal with a long time of inactivity. | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | I think such an edge case installation demonstrates the economic | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | behaviour of our model of overlapping time slices best. | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | The sleeping beauty (http://en.wikipedia.org/wiki/Sleeping_Beauty) is | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | a classic fairytale of a princess sleeping for a hundred years. The | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | story inspired the test case 02-aurora.t. | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||
| 1078 | Given an upstream server where the people stop feeding new files for | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | one hundred years. That upstream server has no driving energy to do | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | major changes to its RECENT files. Cronjobs will continue to shift | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | things towards the Z file but soon will stop doing so since all of | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | them have to keep their promise to record files covering a certain | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | period. Soon all RECENT files will cover exactly their native period. | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||
| 1085 | Downstream servers will stubbornly ask their question to the rsync | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | server whether there is a newer RECENT.recent. As soon as the smallest | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | RECENT file has reached the state of maximum possible merge with the | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | second smallest RECENT file, the answer of the rsync server will | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | always be: nothing new. And downstream servers that were uptodate on | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | the previous request will be satisfied and do nothing. Never will they | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | request a download. The answer that there is no change is sufficient | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | to determine that there is no change in the whole tree. | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||
| 1094 | Let's presume the smallest RECENT file on this castle is a 1h file and | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | downstream decides to ask every 30 minutes. Now the hundred years are | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | over and upstream starts producing files again. One file every minute. | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | After one minute it will move old files over to the, say, 1d file. In | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | the next sixty minutes it will not be allowed to move any other file | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | over to the 1d file. At some point in time downstream will ask the | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | obligatory question "anything new?" and it will get the current 1h | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | file. It will recognize in the meta part of the current file which | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | timestamps have been moved to the 1d file, it will recognize that it | ||||||||||||||||||||||||||||||||||||||||||
| 1103 | has all those. It will have no need to download the 1d file, it will | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | download the missing files and be done. No second RECENT file needs to | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | be downloaded. | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||
| 1107 | Downstream only decides to download another RECENT file when not doing | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | so would result in a gap between two recent files. Such that | ||||||||||||||||||||||||||||||||||||||||||
| 1109 | consistency checks would become impossible. Or for potentially | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | interested third parties, like down-down-stream servers. | ||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||
| 1112 | Downloads of RECENT files are subject to rsync optimizations in that | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | rsync does some level of blockwise checksumming that is considered | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | efficient to avoid copying blocks of data that have not changed. Our | ||||||||||||||||||||||||||||||||||||||||||
| 1115 | format is that of an ordered array, so that large blocks stay constant | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | when elements are prepended to the array. This means we usually do not | ||||||||||||||||||||||||||||||||||||||||||
| 1117 | have to rsync full RECENT files. Only if they are really small, the | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | rsync algorithm will not come into play but that's OK for small files. | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | Upstream servers are extremely lazy in writing the larger files. See | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | File::Rsync::Mirror::Recentfile::aggregate() for the specs. Long | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | before the one hundred years are over, the upstream server will stop | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | changing files. Slowly everything that existed before upstream fell | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | asleep trickles into the Z file. Say, the second-largest RECENT file | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | is a 1Y file and the third-largest RECENT file is a 1Q file, then it | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | will take at least one quarter of a year that the 1Y file will be | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | merged into the Z file. From that point in time everything will have | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | been merged into the Z file and the server's job to call C<aggregate> | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | regularly will become a noop. Consequently downstream will never again | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | download anything. Just the obligatory question: anything new? | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||
| 1132 | =head2 THE INDIVIDUAL RECENTFILE | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||
| 1134 | A I<recentfile> consists of a hash that has two keys: C<meta> and | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | C<recent>. The C<meta> part has metadata and the C<recent> part has a | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | list of fileobjects. | ||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | =head2 THE META PART | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||
| 1140 | Here we find things that are pretty much self explaining: all | ||||||||||||||||||||||||||||||||||||||||||
| 1141 | lowercase attributes are accessors and as such explained in the | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | manpages. The uppercase attribute C<Producers> contains version | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | information about involved software components. | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||
| 1145 | Even though the lowercase attributes are documented in the | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | F:R:M:Recentfile manpage, let's focus on the important stuff to make | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | sure nothing goes by unnoticed: meta contains the aggregator levels in | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | use in this installation, in other words the names of the RECENT | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | files, eg: | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||
| 1151 | aggregator: | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | - 3s | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | - 8s | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | - 21s | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | - 55s | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | - Z | ||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||
| 1158 | It contains a dirtymark telling us the timestamp of the last protocol | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | violation of the upstream server: | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||
| 1161 | dirtymark: '1325093856.49272' | ||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||
| 1163 | Plus a few things convenient in a situation where we need to do some | ||||||||||||||||||||||||||||||||||||||||||
| 1164 | debugging. | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||
| 1166 | And it contains information about which timestamp is the maximum | ||||||||||||||||||||||||||||||||||||||||||
| 1167 | timestamp in the neighboring file. This is probably the most important | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | data in meta: | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||
| 1170 | merged: | ||||||||||||||||||||||||||||||||||||||||||
| 1171 | epoch: 1307159461.94575 | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||
| 1173 | This keeps track of the highest epoch we would find if we looked into | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | the next RECENT file. | ||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||
| 1176 | Another entry is the minmax, eg: | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||
| 1178 | minmax: | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | max: 1307161441.97444 | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | min: 1307140103.70322 | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||
| 1182 | The merged/epoch and minmax examples above illustrate one case of an | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | overlap (130715... is between 130716... and 130714...). The syncing | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | strategy for the client is in general the imperative: if the interval | ||||||||||||||||||||||||||||||||||||||||||
| 1185 | covered by a recentfile (minmax) and the interval covered by the next | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | higher recentfile (merged/epoch) do not overlap anymore, then it is | ||||||||||||||||||||||||||||||||||||||||||
| 1187 | time to refresh the next recentfile. | ||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||
| 1189 | =head2 THE RECENT PART | ||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||
| 1191 | This is the interesting part. Every entry refers to some filesystem | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | change (with path, epoch, type). | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||
| 1194 | The I<epoch> value is the point in time when some change was | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | I<registered> but can be set to arbitrary values. Do not be tempted to | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | believe that the entry has a direct relation to something like | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | modification time or change time on the filesystem level. They are not | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | reflecting release dates. (If you want exact release dates: Barbie is | ||||||||||||||||||||||||||||||||||||||||||
| 1199 | providing a database of them. See | ||||||||||||||||||||||||||||||||||||||||||
| 1200 | http://use.perl.org/~barbie/journal/37907). | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||
| 1202 | All these entries can be devided into two types (denoted by the | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | I<type> attribute): C<new>s and C<delete>s. Changes and creations are | ||||||||||||||||||||||||||||||||||||||||||
| 1204 | C<new>s. Deletes are C<delete>s. | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||
| 1206 | Besides an I<epoch> and a I<type> attribute we find a third one: | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | I<path>. This path is relative to the directory we find the | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | I<recentfile> in. | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||
| 1210 | The order of the entries in the I<recentfile> is by decreasing epoch | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | attribute. These are unique floating point numbers. When the server | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | has ntp running correctly, then the timestamps are usually reflecting | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | a real epoch. If time is running backwards, we trump the system epoch | ||||||||||||||||||||||||||||||||||||||||||
| 1214 | with strictly monotonically increasing floating point timestamps and | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | guarantee they are unique. | ||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||
| 1217 | =head1 CORRUPTION AND RECOVERY | ||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||
| 1219 | If the origin host breaks the promise to deliver consistent and | ||||||||||||||||||||||||||||||||||||||||||
| 1220 | complete I<recentfiles> then it must update its C<dirtymark> and all | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | slaves must discard what they cosider the truth. | ||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||
| 1223 | In the worst case that something goes wrong despite the dirtymark | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | mechanism the way back to sanity can be achieved through traditional | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | rsyncing between the hosts. But please be wary doing that: mixing | ||||||||||||||||||||||||||||||||||||||||||
| 1226 | traditional rsync and the F:R:M:R technique can lead to gratuitous | ||||||||||||||||||||||||||||||||||||||||||
| 1227 | extra errors. If you're the last host in a chain, there's nobody you | ||||||||||||||||||||||||||||||||||||||||||
| 1228 | can disturb, but if you have downstream clients, it is possible that | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | rsync copies a RECENT file before the contained files are actually | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | available. | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||
| 1232 | =head1 BACKGROUND | ||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | This is about speeding up rsync operation on large trees. Uses a small | ||||||||||||||||||||||||||||||||||||||||||
| 1235 | metadata cocktail and pull technology. | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||
| 1237 | rersyncrecent solves this problem with a couple of (usually 2-10) | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | lightweight index files which cover different overlapping time | ||||||||||||||||||||||||||||||||||||||||||
| 1239 | intervals. The master writes these files and the clients/slaves can | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | construct the full tree from the information contained in them. The | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | most recent index file usually covers the last seconds or minutes or | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | hours of the tree and depending on the needs, slaves can rsync every | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | few seconds or minutes and then bring their trees in full sync. | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||
| 1245 | The rersyncrecent model was developed for CPAN but as it is both | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | convenient and economic it is also a general purpose solution. I'm | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | looking forward to see a CPAN backbone that is only a few seconds | ||||||||||||||||||||||||||||||||||||||||||
| 1248 | behind PAUSE. | ||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||
| 1250 | =head2 NON-COMPETITORS | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||
| 1252 | File::Mirror JWU/File-Mirror/File-Mirror-0.10.tar.gz only local trees | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | Mirror::YAML ADAMK/Mirror-YAML-0.03.tar.gz some sort of inner circle | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | Net::DownloadMirror KNORR/Net-DownloadMirror-0.04.tar.gz FTP sites and stuff | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | Net::MirrorDir KNORR/Net-MirrorDir-0.05.tar.gz dito | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | Net::UploadMirror KNORR/Net-UploadMirror-0.06.tar.gz dito | ||||||||||||||||||||||||||||||||||||||||||
| 1257 | Pushmi::Mirror CLKAO/Pushmi-v1.0.0.tar.gz something SVK | ||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||
| 1259 | rsnapshot www.rsnapshot.org focus on backup | ||||||||||||||||||||||||||||||||||||||||||
| 1260 | csync www.csync.org more like unison | ||||||||||||||||||||||||||||||||||||||||||
| 1261 | multi-rsync sourceforge 167893 lan push to many | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | chasm chasmd.org per-directory manifests | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||
| 1264 | =head2 COMPETITORS | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||
| 1266 | The problem to solve which clusters and ftp mirrors and otherwise | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | replicated datasets like CPAN share: how to transfer only a minimum | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | amount of data to determine the diff between two hosts. | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | Normally it takes a long time to determine the diff itself before it | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | can be transferred. Known solutions at the time of this writing are | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | csync2, and rsync 3 batch mode. | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||
| 1274 | For many years the best solution was B<csync2> which solves the | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | problem by maintaining a sqlite database on both ends and talking a | ||||||||||||||||||||||||||||||||||||||||||
| 1276 | highly sophisticated protocol to quickly determine which files to send | ||||||||||||||||||||||||||||||||||||||||||
| 1277 | and which to delete at any given point in time. Csync2 is often | ||||||||||||||||||||||||||||||||||||||||||
| 1278 | inconvenient because it is push technology and the act of syncing | ||||||||||||||||||||||||||||||||||||||||||
| 1279 | demands quite an intimate relationship between the sender and the | ||||||||||||||||||||||||||||||||||||||||||
| 1280 | receiver. This is hard to achieve in an environment of loosely coupled | ||||||||||||||||||||||||||||||||||||||||||
| 1281 | sites where the number of sites is large or connections are unreliable | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | or network topology is changing. | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||
| 1284 | B<Rsync 3 batch mode> works around these problems by providing | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | rsync-able batch files which allow receiving nodes to replay the | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | history of the other nodes. This reduces the need to have an | ||||||||||||||||||||||||||||||||||||||||||
| 1287 | incestuous relation but it has the disadvantage that these batch files | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | replicate the contents of the involved files. This seems inappropriate | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | when the nodes already have a means of communicating over rsync. | ||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||
| 1291 | =head2 HONORABLE MENTION | ||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||
| 1293 | B<instantmirror> at https://fedorahosted.org/InstantMirror/ is an | ||||||||||||||||||||||||||||||||||||||||||
| 1294 | ambitious project that tries to combine various technologies (squid, | ||||||||||||||||||||||||||||||||||||||||||
| 1295 | bittorrent) to overcome the current slowness with the main focus on | ||||||||||||||||||||||||||||||||||||||||||
| 1296 | fedora. It's been founded in 2009-03 and at the time of this writing | ||||||||||||||||||||||||||||||||||||||||||
| 1297 | it is still a bit early to comment on. | ||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||
| 1299 | =head1 LIMITATIONS | ||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||
| 1301 | If the tree of the master server is changing faster than the bandwidth | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | permits to mirror then additional protocols may need to be deployed. | ||||||||||||||||||||||||||||||||||||||||||
| 1303 | Certainly p2p/bittorrent can help in such situations because | ||||||||||||||||||||||||||||||||||||||||||
| 1304 | downloading sites help each other and bittorrent chunks large files | ||||||||||||||||||||||||||||||||||||||||||
| 1305 | into pieces. | ||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||
| 1307 | =head1 INOTIFY | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||
| 1309 | Currently the origin server has two options. The traditional one is to | ||||||||||||||||||||||||||||||||||||||||||
| 1310 | strictly keep track of injected and removed files through all involved | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | processes and call C<update> on every file system event. The other | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | option is to let data come in and use the assistance of inotify. PAUSE | ||||||||||||||||||||||||||||||||||||||||||
| 1313 | is running the former, the cpan master site is running the latter. | ||||||||||||||||||||||||||||||||||||||||||
| 1314 | Both work equally well for CPAN because CPAN has not yet had any | ||||||||||||||||||||||||||||||||||||||||||
| 1315 | problem with upload storms. On installations that have to deal with | ||||||||||||||||||||||||||||||||||||||||||
| 1316 | more uploaded data than inotify+rrr can handle it's better to use the | ||||||||||||||||||||||||||||||||||||||||||
| 1317 | traditional method such that the relevant processes can build up some | ||||||||||||||||||||||||||||||||||||||||||
| 1318 | backpressure to throttle writing processes until we're ready to accept | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | the next data chunk. | ||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||
| 1321 | =head1 FUTURE DIRECTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||
| 1323 | Convince other users outside the CPAN like | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | http://fedoraproject.org/wiki/Infrastructure/Mirroring | ||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||
| 1326 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||
| 1328 | L<File::Rsync::Mirror::Recentfile>, | ||||||||||||||||||||||||||||||||||||||||||
| 1329 | L<File::Rsync::Mirror::Recentfile::Done>, | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | L<File::Rsync::Mirror::Recentfile::FakeBigFloat> | ||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||
| 1332 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||
| 1334 | Please report any bugs or feature requests through the web interface | ||||||||||||||||||||||||||||||||||||||||||
| 1335 | at | ||||||||||||||||||||||||||||||||||||||||||
| 1336 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Rsync-Mirror-Recent>. | ||||||||||||||||||||||||||||||||||||||||||
| 1337 | I will be notified, and then you'll automatically be notified of | ||||||||||||||||||||||||||||||||||||||||||
| 1338 | progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||
| 1340 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||
| 1342 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||
| 1344 | perldoc File::Rsync::Mirror::Recent | ||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||
| 1346 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||
| 1348 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||
| 1350 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||
| 1352 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Rsync-Mirror-Recent> | ||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||
| 1354 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||
| 1356 | L<http://annocpan.org/dist/File-Rsync-Mirror-Recent> | ||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||
| 1358 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||
| 1360 | L<http://cpanratings.perl.org/d/File-Rsync-Mirror-Recent> | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||
| 1362 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | L<http://search.cpan.org/dist/File-Rsync-Mirror-Recent> | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||
| 1366 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||
| 1369 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||
| 1371 | Thanks to RJBS for module-starter. | ||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||
| 1373 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||
| 1375 | Andreas König | ||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||
| 1377 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||
| 1379 | Copyright 2008, 2009 Andreas König. | ||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||
| 1381 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 1382 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||
| 1385 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||
| 1387 | 11 | 1; # End of File::Rsync::Mirror::Recent | |||||||||||||||||||||||||||||||||||||||||