[Koha-cvs] koha/C4 Biblio.pm [rel_3_0]

paul poulain paul at koha-fr.org
Wed Dec 20 17:51:00 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	paul poulain <tipaul>	06/12/20 16:51:00

Modified files:
	C4             : Biblio.pm 

Log message:
	ZEBRA update :
	- adding a new table : when a biblio is added/modified/ deleted, an entry is entered in this table
	- the zebraqueue_start.pl script read it & does the stuff.
	
	code coming from head (tumer). it can be run every minut instead of once every day for dev_week code.
	
	I just have commented the previous code (=real time update) in Biblio.pm, we will be able to reactivate it once indexdata fixes zebra update bug !

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.178.2.41&r2=1.178.2.42

Patches:
Index: Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.178.2.41
retrieving revision 1.178.2.42
diff -u -b -r1.178.2.41 -r1.178.2.42
--- Biblio.pm	20 Dec 2006 08:54:44 -0000	1.178.2.41
+++ Biblio.pm	20 Dec 2006 16:51:00 -0000	1.178.2.42
@@ -33,7 +33,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.178.2.41 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.178.2.42 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
 
 @ISA = qw( Exporter );
 
@@ -3395,88 +3395,99 @@
     my ( $dbh, $biblionumber, $op, $server ) = @_;
 
     #warn "SERVER:".$server;
-    my @Zconnbiblio;
-    my $tried     = 0;
-    my $recon     = 0;
-    my $reconnect = 0;
-    my $record;
-    my $shadow;
-
-  reconnect:
-    $Zconnbiblio[0] = C4::Context->Zconn( $server, 0, 1 );
-
-    if ( $server eq "biblioserver" ) {
-
-        # it's unclear to me whether this should be in xml or MARC format
-        # but it is clear it should be nabbed from zebra rather than from
-        # the koha tables
-        $record = GetMarcBiblio($biblionumber);
-        $record = $record->as_xml_record() if $record;
-#            warn "RECORD $biblionumber => ".$record;
-        $shadow="biblioservershadow";
-
-        #           warn "RECORD $biblionumber => ".$record;
-        $shadow = "biblioservershadow";
-
-    }
-    elsif ( $server eq "authorityserver" ) {
-        $record = C4::AuthoritiesMarc::XMLgetauthority( $dbh, $biblionumber );
-        $shadow = "authorityservershadow";
-    }    ## Add other servers as necessary
-
-    my $Zpackage = $Zconnbiblio[0]->package();
-    $Zpackage->option( action => $op );
-    $Zpackage->option( record => $record );
-
-  retry:
-    $Zpackage->send("update");
-    my $i;
-    my $event;
-
-    while ( ( $i = ZOOM::event( \@Zconnbiblio ) ) != 0 ) {
-        $event = $Zconnbiblio[0]->last_event();
-        last if $event == ZOOM::Event::ZEND;
-    }
-
-    my ( $error, $errmsg, $addinfo, $diagset ) = $Zconnbiblio[0]->error_x();
-    if ( $error == 10000 && $reconnect == 0 )
-    {    ## This is serious ZEBRA server is not available -reconnect
-        warn "problem with zebra server connection";
-        $reconnect = 1;
-        my $res = system('sc start "Z39.50 Server" >c:/zebraserver/error.log');
-
-        #warn "Trying to restart ZEBRA Server";
-        #goto "reconnect";
-    }
-    elsif ( $error == 10007 && $tried < 2 )
-    {    ## timeout --another 30 looonng seconds for this update
-        $tried = $tried + 1;
-        warn "warn: timeout, trying again";
-        goto "retry";
-    }
-    elsif ( $error == 10004 && $recon == 0 ) {    ##Lost connection -reconnect
-        $recon = 1;
-        warn "error: reconnecting to zebra";
-        goto "reconnect";
-
-   # as a last resort, we save the data to the filesystem to be indexed in batch
-    }
-    elsif ($error) {
-        warn
-"Error-$server   $op $biblionumber /errcode:, $error, /MSG:,$errmsg,$addinfo \n";
-        $Zpackage->destroy();
-        $Zconnbiblio[0]->destroy();
-        zebraopfiles( $dbh, $biblionumber, $record, $op, $server );
-        return;
-    }
-    if ( C4::Context->$shadow ) {
-        $Zpackage->send('commit');
-        while ( ( $i = ZOOM::event( \@Zconnbiblio ) ) != 0 ) {
-
-            #waiting zebra to finish;
-         }
-    }
-    $Zpackage->destroy();
+#
+# true zebraop commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates
+# at the same time
+# replaced by a zebraqueue table, that is filled with zebraop to run.
+# the table is emptied by misc/cronjobs/zebraqueue_start.pl script
+
+my $sth=$dbh->prepare("insert into zebraqueue  (biblio_auth_number ,server,operation) values(?,?,?)");
+$sth->execute($biblionumber,$server,$op);
+$sth->finish;
+
+#
+#     my @Zconnbiblio;
+#     my $tried     = 0;
+#     my $recon     = 0;
+#     my $reconnect = 0;
+#     my $record;
+#     my $shadow;
+# 
+#   reconnect:
+#     $Zconnbiblio[0] = C4::Context->Zconn( $server, 0, 1 );
+# 
+#     if ( $server eq "biblioserver" ) {
+# 
+#         # it's unclear to me whether this should be in xml or MARC format
+#         # but it is clear it should be nabbed from zebra rather than from
+#         # the koha tables
+#         $record = GetMarcBiblio($biblionumber);
+#         $record = $record->as_xml_record() if $record;
+# #            warn "RECORD $biblionumber => ".$record;
+#         $shadow="biblioservershadow";
+# 
+#         #           warn "RECORD $biblionumber => ".$record;
+#         $shadow = "biblioservershadow";
+# 
+#     }
+#     elsif ( $server eq "authorityserver" ) {
+#         $record = C4::AuthoritiesMarc::XMLgetauthority( $dbh, $biblionumber );
+#         $shadow = "authorityservershadow";
+#     }    ## Add other servers as necessary
+# 
+#     my $Zpackage = $Zconnbiblio[0]->package();
+#     $Zpackage->option( action => $op );
+#     $Zpackage->option( record => $record );
+# 
+#   retry:
+#     $Zpackage->send("update");
+#     my $i;
+#     my $event;
+# 
+#     while ( ( $i = ZOOM::event( \@Zconnbiblio ) ) != 0 ) {
+#         $event = $Zconnbiblio[0]->last_event();
+#         last if $event == ZOOM::Event::ZEND;
+#     }
+# 
+#     my ( $error, $errmsg, $addinfo, $diagset ) = $Zconnbiblio[0]->error_x();
+#     if ( $error == 10000 && $reconnect == 0 )
+#     {    ## This is serious ZEBRA server is not available -reconnect
+#         warn "problem with zebra server connection";
+#         $reconnect = 1;
+#         my $res = system('sc start "Z39.50 Server" >c:/zebraserver/error.log');
+# 
+#         #warn "Trying to restart ZEBRA Server";
+#         #goto "reconnect";
+#     }
+#     elsif ( $error == 10007 && $tried < 2 )
+#     {    ## timeout --another 30 looonng seconds for this update
+#         $tried = $tried + 1;
+#         warn "warn: timeout, trying again";
+#         goto "retry";
+#     }
+#     elsif ( $error == 10004 && $recon == 0 ) {    ##Lost connection -reconnect
+#         $recon = 1;
+#         warn "error: reconnecting to zebra";
+#         goto "reconnect";
+# 
+#    # as a last resort, we save the data to the filesystem to be indexed in batch
+#     }
+#     elsif ($error) {
+#         warn
+# "Error-$server   $op $biblionumber /errcode:, $error, /MSG:,$errmsg,$addinfo \n";
+#         $Zpackage->destroy();
+#         $Zconnbiblio[0]->destroy();
+#         zebraopfiles( $dbh, $biblionumber, $record, $op, $server );
+#         return;
+#     }
+#     if ( C4::Context->$shadow ) {
+#         $Zpackage->send('commit');
+#         while ( ( $i = ZOOM::event( \@Zconnbiblio ) ) != 0 ) {
+# 
+#             #waiting zebra to finish;
+#          }
+#     }
+#     $Zpackage->destroy();
 }
 
 =head2 calculatelc
@@ -3573,8 +3584,17 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.178.2.41 2006/12/20 08:54:44 toins Exp $
+# $Id: Biblio.pm,v 1.178.2.42 2006/12/20 16:51:00 tipaul Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.178.2.42  2006/12/20 16:51:00  tipaul
+# ZEBRA update :
+# - adding a new table : when a biblio is added/modified/ deleted, an entry is entered in this table
+# - the zebraqueue_start.pl script read it & does the stuff.
+#
+# code coming from head (tumer). it can be run every minut instead of once every day for dev_week code.
+#
+# I just have commented the previous code (=real time update) in Biblio.pm, we will be able to reactivate it once indexdata fixes zebra update bug !
+#
 # Revision 1.178.2.41  2006/12/20 08:54:44  toins
 # GetXmlBiblio wasn't exported.
 #





More information about the Koha-cvs mailing list