[Bio] / Sprout / ERDBGenerator.pl Repository:
ViewVC logotype

Diff of /Sprout/ERDBGenerator.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Wed Oct 1 03:07:08 2008 UTC revision 1.3, Thu Oct 2 16:32:42 2008 UTC
# Line 129  Line 129 
129    
130  Create an event in the RSS feed when an error occurs.  Create an event in the RSS feed when an error occurs.
131    
132    =item label
133    
134    Name of this process, for display during tracing.
135    
136  =item workers  =item workers
137    
138  If C<0>, then this is considered to be a worker process and the sections in the  If C<0>, then this is considered to be a worker process and the sections in the
# Line 151  Line 155 
155                                                phone => ["", "phone number (international format) to call when load finishes"],                                                phone => ["", "phone number (international format) to call when load finishes"],
156                                                trace => ["2", "tracing level"],                                                trace => ["2", "tracing level"],
157                                                workers => ["1", "number of worker processes"],                                                workers => ["1", "number of worker processes"],
158                                                  label => ["Main", "name of this process"],
159                                                resume => ["", "if specified, the specified group and all groups that normally come after it will be loaded"],                                                resume => ["", "if specified, the specified group and all groups that normally come after it will be loaded"],
160                                                sections => ["*", "name of a file in the database's load directory containing a list of sections to process"],                                                sections => ["*", "name of a file in the database's load directory containing a list of sections to process"],
161                                             },                                             },
# Line 259  Line 264 
264              Trace("Sequential load started.") if T(2);              Trace("Sequential load started.") if T(2);
265              LoadFromInput($ih, $erdb, $source, \@realGroups, \%workerOptions);              LoadFromInput($ih, $erdb, $source, \@realGroups, \%workerOptions);
266          } else {          } else {
267              # Here we need to create the workers. The following array will contain              # Here we need to create the workers. The following arrays will contain,
268              # a list of open file handles. Each one will correspond to a worker.              # respectively, a list of open file handles and a list of worker labels.
269              # Writing to the file sends a section to a worker.              # Each one will correspond to a single worker. Writing to the handle in
270                # the first sends a section to the worker named in the second.
271              my @workers = ();              my @workers = ();
272              # Compute the command line to use for the worker.              my @labels = ();
273              my $command = "$0 " . Tracer::UnparseOptions(\%workerOptions) .              # Compute the positional parameters to use for the worker.
274                  " $database " . join(" ", @realGroups);              my $commandParms = join(" ", $database, @realGroups);
275              Trace("Worker command is: $command") if T(3);              my $command = $0;
276              # Create the workers.              # Create the workers.
277              for (my $i = 0; $i < $numWorkers; $i++) {              for (my $i = 0; $i < $numWorkers; $i++) {
278                  my $oh = Open(undef, "| $command");                  my $label = "$options->{label}$i";
279                    $workerOptions{label} = $label;
280                    my $commandOptions = Tracer::UnparseOptions(\%workerOptions);
281                    my $oh = Open(undef, "| $command $commandOptions $commandParms");
282                    select $oh; $| = 1; select STDOUT;
283                  push @workers, $oh;                  push @workers, $oh;
284                    push @labels, $label;
285              }              }
286              # Now we assign sections to the workers.              # Now we assign sections to the workers.
287                my $w = 0;
288              while (! eof $ih) {              while (! eof $ih) {
289                  # Get the name of the next section.                  # Get the name of the next section.
290                  my $line = <$ih>;                  my $line = <$ih>;
291                  # Get the next worker in rotation.                  # Get the next worker in rotation.
292                  my $worker = shift @workers;                  my $worker = $workers[$w];
                 push @workers, $worker;  
293                  # Send this section to it.                  # Send this section to it.
294                  print $worker $line;                  print $worker $line;
295                    Trace(Tracer::Strip($line) . " sent to $labels[$w]") if T(3);
296                    # Position on the next worker.
297                    $w = ($w + 1) % $numWorkers;
298              }              }
299              # All done, wait for the workers to finish.              # All done, wait for the workers to finish.
300              for my $worker (@workers) {              for my $worker (@workers) {
# Line 360  Line 374 
374                  # Check for a kill file.                  # Check for a kill file.
375                  if (-f $killFileName) {                  if (-f $killFileName) {
376                      # Found one, so kill ourselves.                      # Found one, so kill ourselves.
377                      Trace("Worker $$ terminated by kill file.") if T(2);                      Trace("$options->{label} terminated by kill file.") if T(2);
378                      $killed = 1;                      $killed = 1;
379                  } else {                  } else {
380                      # No kill file, so we process the section.                      # No kill file, so we process the section.
381                      Trace("Processing section $section for group $group in worker $$.") if T(3);                      Trace("Processing section $section for group $group in $options->{label}($$).") if T(3);
382                      my $ok = $loaders{$group}->ProcessSection($section);                      my $ok = $loaders{$group}->ProcessSection($section);
383                      # Check to see if we've exceeded the maximum error count. We only care                      # Check to see if we've exceeded the maximum error count. We only care
384                      # if maxErrors is nonzero.                      # if maxErrors is nonzero.

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3