Script for generating a series of parallel marc_stream_importer.pl
calls.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
--- /dev/null
+01080nam a2200289Ma 4500001001300000003000600013005001700019008004100036040001700077020001800094020001500112035002100127049000900148100001800157245008700175250002800262260004500290300000900335520026600344650004100610650002300651650002100674650002900695650002300724994001200747901003100759\1eocn779635453\1eOCoLC\1e20150623041534.0\1e091015s19uu nyu 000 0 eng d\1e \1faTXBAY\1fcTXBAY\1e \1fa9780545139700\1e \1fa0545139708\1e \1fa(OCoLC)779635453\1e \1faNTGA\1e1 \1faRowling, J.K.\1e10\1faHarry Potter and the Deathly Hallows :\1fcBy J.K. Rowling.\1fb#7 Harry Potter Series /\1e \1fa2009 Softcover Edition.\1e \1faNew York, New York :\1fbScholastic,\1fc2009.\1e \1fa759.\1e \1faBurdened with the dark, dangerous and seemingly impossible task of locating and destroying Voldemort's remaining Horcruxes, Harry, feeling alone and uncertain about his future, struggles to find the inner strength he needs to follow the path set out before him.\1e 4\1faHarry Potter - Fictitious Character.\1e 4\1faWizards - Fiction.\1e 4\1faMagic - Fiction.\1e 4\1faComing of Age - Fiction.\1e 4\1faEngland - Fiction.\1e \1faC0\1fbNTG\1e \1fa1415986\1fb\1fc1415986\1ftbiblio\1e\1d
\ No newline at end of file
--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+use IO::Socket::INET;
+
+my $parallel = 5;
+my $iterations = 2;
+my $host = 'localhost';
+my $port = 5544;
+
+open(MARC, $ARGV[0]) or die "$0 <marc_file>\n";
+my $marc = <MARC>;
+
+for my $proc (0..$parallel-1) {
+
+ next if fork(); # if parent
+
+ for my $iter (0..$iterations-1) {
+
+ my $socket = IO::Socket::INET->new(
+ PeerAddr => $host,
+ PeerPort => $port,
+ Proto => 'tcp'
+ ) or die "socket failure $!\n";
+
+ print "$proc : $iter : sending MARC\n";
+ $socket->print($marc) or die "socket print failure: $!\n";
+
+ while (my $line = $socket->getline) {
+ chomp($line);
+ print "$proc : $iter : Read: $line\n" if $line;
+ }
+
+ $socket->shutdown(2);
+ }
+
+ exit; # kill the child
+}
+
+while (wait() != -1) {}
+