/[Search-Estraier]/trunk/scripts/estcp-mt.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/scripts/estcp-mt.pl

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

revision 86 by dpavlin, Thu Jan 19 14:33:33 2006 UTC revision 87 by dpavlin, Sat Jan 21 17:37:07 2006 UTC
# Line 38  my $to_n = new Search::Estraier::Node( Line 38  my $to_n = new Search::Estraier::Node(
38  );  );
39    
40  unless(eval{ $to_n->name }) {  unless(eval{ $to_n->name }) {
41          if ($to =~ m#^(http://.+)/node/(\w+)$#) {          if ($to =~ m#^(http://.+)/node/([^/]+)$#) {
42                  my ($url,$name) = ($1,$2);                  my ($url,$name) = ($1,$2);
43                  print "Creating '$name' on $url\n";                  print "Creating '$name' on $url\n";
44                  $to_n->shuttle_url( $url . '/master?action=nodeadd',                  $to_n->shuttle_url( $url . '/master?action=nodeadd',
# Line 59  my $q_drafts = Thread::Queue->new; Line 59  my $q_drafts = Thread::Queue->new;
59    
60  my $get_thr = threads->new( sub {  my $get_thr = threads->new( sub {
61          while (my $id = $q_id->dequeue) {          while (my $id = $q_id->dequeue) {
62                    #warn "get ", $id || 'undef',"\n";
63                    if ($id < 0) {
64                            $q_drafts->enqueue( '' );       # abort put thread
65                            last;
66                    };
67                  print STDERR "get_thr, id: $id\n" if ($debug);                  print STDERR "get_thr, id: $id\n" if ($debug);
68                  my $doc_draft = $from_n->_fetch_doc( id => $id, chomp_resbody => 1 );                  my $doc_draft = $from_n->_fetch_doc( id => $id, chomp_resbody => 1 );
69                  $q_drafts->enqueue( $doc_draft );                  $q_drafts->enqueue( $doc_draft );
# Line 71  my $doc_num = $from_n->doc_num || 1; Line 76  my $doc_num = $from_n->doc_num || 1;
76    
77  my $put_thr = threads->new( sub {  my $put_thr = threads->new( sub {
78          while (my $doc_draft = $q_drafts->dequeue) {          while (my $doc_draft = $q_drafts->dequeue) {
79                    last unless ($doc_draft);
80                  print STDERR "put_thr, $doc_draft\n" if ($debug);                  print STDERR "put_thr, $doc_draft\n" if ($debug);
81                  $to_n->shuttle_url( $to_n->{url} . '/put_doc', 'text/x-estraier-draft', $doc_draft, undef) == 200 or die "can't insert $doc_draft\n";                  $to_n->shuttle_url( $to_n->{url} . '/put_doc', 'text/x-estraier-draft', $doc_draft, undef) == 200 or die "can't insert $doc_draft\n";
82    
# Line 115  while($more) { Line 121  while($more) {
121    
122                  $q_id->enqueue( $id );                  $q_id->enqueue( $id );
123          }          }
124          warn "$prev\n";          warn "$prev\n" if ($debug);
125    
126  }  }
127    $q_id->enqueue( -1 );   # last one
128    
129  $get_thr->join;  $get_thr->join;
130  $put_thr->join;  $put_thr->join;
131    
132  print "Copy completed.\n";  printf "Copy of %d records completed [%1.2f rec/s]\n", $i,
133            ( $i / ((time() - $t) || 1) );
134    

Legend:
Removed from v.86  
changed lines
  Added in v.87

  ViewVC Help
Powered by ViewVC 1.1.26