Changeset 22445


Ignore:
Timestamp:
2010-07-20T13:58:05+12:00 (14 years ago)
Author:
davidb
Message:

Incorporation of top-level parallel_import functionality into code base.

Location:
main/trunk/greenstone2/perllib
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/inexport.pm

    r22421 r22445  
    118118    $self->{'collection'} = shift @$argv;
    119119
     120    if ((defined $self->{'jobs'}) && ($self->{'jobs'}>1)) {
     121    require ParallelInexport;
     122    }
     123
    120124    return bless $self, $class;
    121125}
     
    350354
    351355    my $gli          = $self->{'gli'};
     356
     357    my $jobs         = $self->{'jobs'};
     358    my $epoch        = $self->{'epoch'};
    352359
    353360    # related to export
     
    566573       
    567574        # Play it safe, and run through the entire folder, only processing new or edited files
    568         &plugin::read ($pluginfo, $importdir, "", $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
    569 
     575       
     576            if ((defined $jobs) && ($jobs > 1))
     577            {
     578        # if jobs are set to >1, run in parallel using MPI helper
     579        # [hs, 1 july 2010]
     580        &ParallelInexport::farm_out_processes($jobs, $epoch, $importdir, $block_hash,
     581                              $self->{'collection'}, $self->{'site'});
     582            }
     583            else
     584            {
     585           &plugin::read ($pluginfo, $importdir, "", $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
     586            }
    570587    }
    571588    else {
    572         &plugin::read ($pluginfo, $importdir, "", $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
     589            if ((defined $jobs) && ($jobs > 1))
     590            {
     591        # if jobs are set to >1, run in parallel using MPI helper
     592        # [hs, 1 july 2010]
     593        &ParallelInexport::farm_out_processes($jobs, $epoch, $importdir, $block_hash,
     594                              $self->{'collection'}, $self->{'site'});
     595            }
     596            else
     597            {
     598        &plugin::read ($pluginfo, $importdir, "", $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
     599            }   
    573600    }
    574601
     
    685712    my $inexport_mode = $self->{'mode'};
    686713
    687     my $statsfile = $self->{'statsfile'};
    688     my $out       = $self->{'out'};
     714    my $statsfile   = $self->{'statsfile'};
     715    my $out         = $self->{'out'};
    689716    my $faillogname = $self->{'faillogname'};
    690     my $gli       = $self->{'gli'};
     717    my $gli         = $self->{'gli'};
     718    my $jobs        = $self->{'jobs'};
    691719
    692720    # write out import stats
    693     my $close_stats = 0;
    694     if ($statsfile !~ /^(STDERR|STDOUT)$/i) {
    695     if (open (STATS, ">$statsfile")) {
    696         $statsfile = 'import::STATS';
    697         $close_stats = 1;
    698     } else {
    699         &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile);
    700         &gsprintf($out, "{import.stats_backup}\n");
    701         $statsfile = 'STDERR';
    702     }
    703     }
    704 
    705     &gsprintf($out, "\n");
    706     &gsprintf($out, "*********************************************\n");
    707     &gsprintf($out, "{$inexport_mode.complete}\n");
    708     &gsprintf($out, "*********************************************\n");
    709 
    710     &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
    711     if ($close_stats) {
    712     close STATS;
     721
     722    if ((!defined $jobs) || ($jobs == 1))
     723    {
     724    # only output statistics if there are multiple jobs
     725    # [hs, 1 july 2010]
     726
     727    my $close_stats = 0;
     728    if ($statsfile !~ /^(STDERR|STDOUT)$/i) {
     729        if (open (STATS, ">$statsfile")) {
     730        $statsfile = 'import::STATS';
     731        $close_stats = 1;
     732        } else {
     733        &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile);
     734        &gsprintf($out, "{import.stats_backup}\n");
     735        $statsfile = 'STDERR';
     736        }
     737    }
     738   
     739    &gsprintf($out, "\n");
     740    &gsprintf($out, "*********************************************\n");
     741    &gsprintf($out, "{$inexport_mode.complete}\n");
     742    &gsprintf($out, "*********************************************\n");
     743   
     744    &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
     745    if ($close_stats) {
     746        close STATS;
     747    }
    713748    }
    714749
Note: See TracChangeset for help on using the changeset viewer.