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 |
|
---|
32 | package parallelmgbuilder;
|
---|
33 |
|
---|
34 | use mgbuilder;
|
---|
35 | use parallelbasebuilder;
|
---|
36 | use strict;
|
---|
37 |
|
---|
38 | BEGIN
|
---|
39 | {
|
---|
40 | # multiple inheritence FTW
|
---|
41 | @parallelmgbuilder::ISA = ('mgbuilder', 'parallelbasebuilder');
|
---|
42 | }
|
---|
43 |
|
---|
44 | # /** @function new()
|
---|
45 | # */
|
---|
46 | sub 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 | # */
|
---|
63 | sub 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 |
|
---|
84 | 1;
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|