source: gs2-extensions/parallel-building/trunk/src/perllib/parallelmgbuilder.pm@ 27233

Last change on this file since 27233 was 27233, checked in by jmt12, 11 years ago

Recipe generation code moved into subclass of mgbuilder called parallelmgbuilder

File size: 3.0 KB
Line 
1###############################################################################
2#
3# parallelmgbuilder.pm -- inherits from the MGBuilder object but adds parallel
4# indexing capability by way of a function that generates the 'recipe' for
5# indexing. This recipe including information on precedence and can be used by
6# a controller (such as OpenMPI) to parallelize parts of the recipe.
7#
8# A component of the Greenstone digital library software
9# from the New Zealand Digital Library Project at the
10# University of Waikato, New Zealand.
11#
12# Copyright (C) 2013 New Zealand Digital Library Project
13#
14# This program is free software; you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation; either version 2 of the License, or
17# (at your option) any later version.
18#
19# This program is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program; if not, write to the Free Software
26# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27#
28###########################################################################
29
30# @author John Thompson [jmt12], Waikato DL Research group
31
32package parallelmgbuilder;
33
34use mgbuilder;
35use parallelbasebuilder;
36use strict;
37
38BEGIN
39{
40 # multiple inheritence FTW
41 @parallelmgbuilder::ISA = ('mgbuilder', 'parallelbasebuilder');
42}
43
44# /** @function new()
45# */
46sub new
47{
48 my $class = shift(@_);
49 my $self = new mgbuilder(@_);
50 return bless($self, $class);
51}
52# /** new() **/
53
54# /** @function prepareIndexRecipe()
55# * MG is the most 'complex' recipe we currently support. While the compress
56# * text and infodb phases can be run in parallel, the indexes cannot be built
57# * until after the compress text phase is complete.
58# * @param $self
59# * @param $collection
60# * @param $recipe a reference to an array of recipe 'steps'
61# * @author jmt12
62# */
63sub prepareIndexRecipe
64{
65 my ($self, $collection, $recipe) = @_;
66 my $outhandle = $self->{'outhandle'};
67 my $verbosity = $self->{'verbosity'};
68 # 1. We start by building up the array of indexes, as we'll need to add them
69 # as child tasks to the compress text phase
70 my $index_tasks = ();
71 my $indexes = $self->{'collect_cfg'}->{'indexes'};
72 foreach my $index (@{$indexes})
73 {
74 push(@{$index_tasks}, {'command'=>'buildcol.pl -keepold -verbosity ' . $verbosity . ' -mode build_index -indexname ' . $index . ' ' . $collection});
75 }
76 # 2. Compressing the text - this time with dependent tasks
77 push(@{$recipe}, {'command'=>'buildcol.pl -keepold -verbosity ' . $verbosity . ' -mode compress_text ' . $collection, 'children'=>$index_tasks});
78 # 3. Info database building
79 push(@{$recipe}, {'command'=>'buildcol.pl -keepold -verbosity ' . $verbosity . ' -mode infodb ' . $collection});
80 # Complete!
81}
82# /** prepareIndexRecipe() **/
83
841;
85
86
87
Note: See TracBrowser for help on using the repository browser.