Bugzilla – Attachment 20574 Details for
Bug 6435
[ENH] Added daemon mode parameters to rebuild_zebra.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
My attempt to generate a useful patch from Doug's bizarre diff file.
0001-bug_6435-Patch-to-add-daemon-mode-to-rebuild_zebra.p.patch (text/plain), 3.59 KB, created by
Mark Tompsett
on 2013-08-23 03:57:24 UTC
(
hide
)
Description:
My attempt to generate a useful patch from Doug's bizarre diff file.
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2013-08-23 03:57:24 UTC
Size:
3.59 KB
patch
obsolete
>From 45bc06694f2ac4248405f527c7802c8c896c9436 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Thu, 22 Aug 2013 23:46:05 -0400 >Subject: [PATCH] bug_6435 - Patch to add daemon mode to rebuild_zebra.pl > >This patch was generated based on Doug Kingston's diff. > >This improved patch adds a variable to set the sleep time >between checks for new records to index. The check is very >cheap and not dependent on the size of the catalog so we can >make it every 5 seconds. Any records found (probably just >one), are indexed by zebra incrementally. This will make new >records nearly instantly available for search. >--- > misc/migration_tools/rebuild_zebra.pl | 42 ++++++++++++++++++++++++++------- > 1 file changed, 33 insertions(+), 9 deletions(-) > >diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl >index a46526d..280968e 100755 >--- a/misc/migration_tools/rebuild_zebra.pl >+++ b/misc/migration_tools/rebuild_zebra.pl >@@ -21,6 +21,8 @@ $|=1; # flushes output > # If the cron job starts us in an unreadable dir, we will break without > # this. > chdir $ENV{HOME} if (!(-r '.')); >+my $daemon_mode; >+my $daemon_sleep = 5; > my $directory; > my $nosanitize; > my $skip_export; >@@ -45,6 +47,8 @@ my $run_user = (getpwuid($<))[0]; > my $verbose_logging = 0; > my $zebraidx_log_opt = " -v none,fatal,warn "; > my $result = GetOptions( >+ 'daemon' => \$daemon_mode, >+ 'sleep:i' => \$daemon_sleep, > 'd:s' => \$directory, > 'r|reset' => \$reset, > 's' => \$skip_export, >@@ -152,16 +156,13 @@ if ($do_munge) { > > my $tester = XML::LibXML->new(); > >-if ($authorities) { >- index_records('authority', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir); >-} else { >- print "skipping authorities\n" if ( $verbose_logging ); >-} >- >-if ($biblios) { >- index_records('biblio', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $biblioserverdir); >+if ($daemon_mode) { >+ while (1) { >+ do_one_pass() if ( zebraqueue_not_empty() ); >+ sleep $daemon_sleep; >+ } > } else { >- print "skipping biblios\n" if ( $verbose_logging ); >+ do_one_pass(); > } > > >@@ -191,6 +192,29 @@ if ($keep_export) { > } > } > >+sub do_one_pass { >+ if ($authorities) { >+ index_records('authority', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir); >+ } else { >+ print "skipping authorities\n" if ( $verbose_logging ); >+ } >+ >+ if ($biblios) { >+ index_records('biblio', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $biblioserverdir); >+ } else { >+ print "skipping biblios\n" if ( $verbose_logging ); >+ } >+} >+ >+# Check the zebra update queue and return true if there are records to process >+sub zebraqueue_not_empty { >+ my $query = $dbh->prepare('SELECT COUNT(*) FROM zebraqueue WHERE done = 0;'); >+ $query->execute; >+ my $count = $query->fetchrow_arrayref->[0]; >+ print "queued records: $count\n" if $verbose_logging > 0; >+ return $count > 0; >+} >+ > # This checks to see if the zebra directories exist under the provided path. > # If they don't, then zebra is likely to spit the dummy. This returns true > # if the directories had to be created, false otherwise. >-- >1.7.10.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6435
:
19267
|
19710
|
20574
|
20575
|
21097
|
21099
|
21390
|
21391
|
22039
|
22040
|
22080
|
22201
|
22457
|
22851
|
22859
|
22986