| 299 | |
| 300 | # the individual parts into one single database |
| 301 | my $infodb_type = $self->{'collectcfg'}->{'infodbtype'}; |
| 302 | my $mpi_conf_path = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, 'mpi.conf'); |
| 303 | if ( -f $mpi_conf_path && &dbutil::supportsMerge($infodb_type) ) |
| 304 | { |
| 305 | print STDERR ' * Merging ' . $infodb_type . ' databases... '; |
| 306 | my @databases = ('archiveinf-src','archiveinf-doc'); |
| 307 | foreach my $database (@databases) |
| 308 | { |
| 309 | # generate the path to the target database without any hostname suffix |
| 310 | my $archive_db_path = &dbutil::get_infodb_file_path($infodb_type, $database, $self->{'archivedir'}, 0, ''); |
| 311 | #rint STDERR " - merging to: " . $archive_db_path . "\n"; |
| 312 | open(MPIHOSTS, '<:utf8', $mpi_conf_path) or die("Failed to open mpi.conf for reading"); |
| 313 | my $line; |
| 314 | while ($line = <MPIHOSTS>) |
| 315 | { |
| 316 | if ($line =~ /^([a-z0-9\-]+)/i) |
| 317 | { |
| 318 | my $hostname = $1; |
| 319 | ###rint STDERR " - searching for database for: " . $hostname . "\n"; |
| 320 | my $mergable_db_path = &dbutil::get_infodb_file_path($infodb_type, $database, $self->{'archivedir'}, 0, $hostname); |
| 321 | ###rint STDERR "[debug] " . $mergable_db_path . "\n"; |
| 322 | if (-f $mergable_db_path) |
| 323 | { |
| 324 | ###rint STDERR " - merge $mergable_db_path > $archive_db_path\n"; |
| 325 | &dbutil::merge_databases($infodb_type, $mergable_db_path, $archive_db_path); |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | close(MPIHOSTS); |
| 330 | } |
| 331 | print "Done!\n"; |
| 332 | } |
| 333 | |