[open-ils-commits] [GIT] Evergreen ILS branch master updated. a454ee5fa4938f60f60975e943db9433d52a3916

Evergreen Git git at git.evergreen-ils.org
Mon Mar 11 17:51:23 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  a454ee5fa4938f60f60975e943db9433d52a3916 (commit)
      from  f93b9f4d5b8778993ceefc1b9163a2ec8bc28313 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a454ee5fa4938f60f60975e943db9433d52a3916
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Fri Apr 6 14:39:28 2012 -0400

    Error Checking for Hold Targeter
    
    Because having it leave lock files around is annoying.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/support-scripts/hold_targeter.pl b/Open-ILS/src/support-scripts/hold_targeter.pl
index cd62227..2ca196e 100755
--- a/Open-ILS/src/support-scripts/hold_targeter.pl
+++ b/Open-ILS/src/support-scripts/hold_targeter.pl
@@ -10,6 +10,7 @@ use OpenSRF::Utils::JSON;
 use OpenSRF::System;
 use OpenSRF::Utils::SettingsClient;
 use OpenSRF::MultiSession;
+use OpenSRF::EX qw(:try);
 
 my $config = shift || die "bootstrap config required\n";
 my $lockfile = shift || "/tmp/hold_targeter-LOCK";
@@ -22,54 +23,76 @@ open(F, ">$lockfile");
 print F $$;
 close F;
 
-OpenSRF::System->bootstrap_client( config_file => $config );
-my $settings = OpenSRF::Utils::SettingsClient->new;
-my $parallel = $settings->config_value( hold_targeter => 'parallel' ) || 1; 
+my $settings;
+my $parallel;
 
-if ($parallel == 1) {
+try {
+    OpenSRF::System->bootstrap_client( config_file => $config );
+    $settings = OpenSRF::Utils::SettingsClient->new;
+    $parallel = $settings->config_value( hold_targeter => 'parallel' ) || 1;
+} otherwise {
+    my $e = shift;
+    warn "$e\n";
+    unlink $lockfile;
+    exit 1;
+};
 
-    my $r = OpenSRF::AppSession
-               ->create( 'open-ils.storage' )
-               ->request( 'open-ils.storage.action.hold_request.copy_targeter' => '24h' );
+if ($parallel == 1) {
 
-    while (!$r->complete) { 
-        my $start = time;
-        $r->recv(timeout => 3600);
-        last if (time() - $start) >= 3600;
+    try {
+        my $r = OpenSRF::AppSession
+                   ->create( 'open-ils.storage' )
+                   ->request( 'open-ils.storage.action.hold_request.copy_targeter' => '24h' );
+
+        while (!$r->complete) { 
+            my $start = time;
+            $r->recv(timeout => 3600);
+            last if (time() - $start) >= 3600;
+        };
+    } otherwise {
+        my $e = shift;
+        warn "Failure in single-session targeter:\n$e\n";
     };
 
 } else {
 
-    my $multi_targeter = OpenSRF::MultiSession->new(
-        app => 'open-ils.storage', 
-        cap => $parallel, 
-        api_level => 1,
-        session_hash_function => sub {
-            my $ses = shift;
-            my $req = shift;
-            return $_[-1]; # last parameter is the ID of the metarecord associated with the
-                           # request's target; using this as the hash function value ensures
-                           # that parallel targeters won't try to simultaneously handle two
-                           # hold requests that have overlapping pools of copies that could
-                           # fill those requests
-        }
-    );
-
-    my $storage = OpenSRF::AppSession->create("open-ils.storage");
-
-    my $r = $storage->request('open-ils.storage.action.hold_request.targetable_holds.id_list', '24h');
-    while ( my $h = $r->recv ) {
-        die $r->failed->stringify . "\n" if $r->failed;
-        if (my $hold = $h->content) {
-            $multi_targeter->request( 'open-ils.storage.action.hold_request.copy_targeter', '', $hold->[0], $hold->[1]);
+    try {
+        my $multi_targeter = OpenSRF::MultiSession->new(
+            app => 'open-ils.storage', 
+            cap => $parallel, 
+            api_level => 1,
+            session_hash_function => sub {
+                my $ses = shift;
+                my $req = shift;
+                return $_[-1]; # last parameter is the ID of the metarecord associated with the
+                               # request's target; using this as the hash function value ensures
+                               # that parallel targeters won't try to simultaneously handle two
+                               # hold requests that have overlapping pools of copies that could
+                               # fill those requests
+            }
+        );
+    
+        my $storage = OpenSRF::AppSession->create("open-ils.storage");
+    
+        my $r = $storage->request('open-ils.storage.action.hold_request.targetable_holds.id_list', '24h');
+        while ( my $h = $r->recv ) {
+            if ($r->failed) {
+                print $r->failed->stringify . "\n";
+                last;
+            }
+            if (my $hold = $h->content) {
+                $multi_targeter->request( 'open-ils.storage.action.hold_request.copy_targeter', '', $hold->[0], $hold->[1]);
+            }
         }
+    
+        $storage->disconnect();
+    
+        $multi_targeter->session_wait(1);
+        $multi_targeter->disconnect;
+    } otherwise {
+        my $e = shift;
+        warn "Failure in multi-session targeter:\n$e\n";
     }
-
-    $storage->disconnect();
-
-    $multi_targeter->session_wait(1);
-    $multi_targeter->disconnect;
-
 }
 
 unlink $lockfile;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/support-scripts/hold_targeter.pl |  101 +++++++++++++++----------
 1 files changed, 62 insertions(+), 39 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list