[open-ils-commits] r16676 - in branches/rel_1_6/Open-ILS/src: perlmods/OpenILS/Application support-scripts (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jun 11 09:50:26 EDT 2010
Author: erickson
Date: 2010-06-11 09:50:24 -0400 (Fri, 11 Jun 2010)
New Revision: 16676
Modified:
branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
branches/rel_1_6/Open-ILS/src/support-scripts/action_trigger_runner.pl
Log:
added a number of info messages to the action/trigger runner and server code. the messages provide summary data about what event defs / hooks are being processed and when/if they complete or timeout.
Modified: branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2010-06-11 13:49:45 UTC (rev 16675)
+++ branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2010-06-11 13:50:24 UTC (rev 16676)
@@ -422,10 +422,22 @@
$class =~ s/^Fieldmapper:://o;
$class =~ s/::/_/go;
-
my $method = 'search_'. $class;
- my $object_ids = $editor->$method( $filter, {idlist => 1, timeout => 7200} );
+ # for cleaner logging
+ my $def_id = $def->id;
+ my $hook = $def->hook;
+
+ $logger->info("trigger: create_batch_events() collecting object IDs for def=$def_id / hook=$hook");
+
+ my $object_ids = $editor->$method( $filter, {idlist => 1, timeout => 10800} );
+
+ if($object_ids) {
+ $logger->info("trigger: create_batch_events() fetched ".scalar(@$object_ids)." object IDs for def=$def_id / hook=$hook");
+ } else {
+ $logger->warn("trigger: create_batch_events() timeout occurred collecting object IDs for def=$def_id / hook=$hook");
+ }
+
for my $o_id (@$object_ids) {
my $event = Fieldmapper::action_trigger::event->new();
@@ -437,8 +449,12 @@
$client->respond( $event->id );
}
+
+ $logger->info("trigger: create_batch_events() successfully created events for def=$def_id / hook=$hook");
}
+ $logger->info("trigger: create_batch_events() done creating events");
+
$editor->commit;
return undef;
@@ -467,7 +483,7 @@
my $e = OpenILS::Application::Trigger::Event->new($event_id);
if ($e->validate->valid) {
- $logger->info("Event is valid, reacting...");
+ $logger->info("trigger: Event is valid, reacting...");
$e->react->cleanup;
}
@@ -495,7 +511,7 @@
my $e = OpenILS::Application::Trigger::EventGroup->new(@$events);
if ($e->validate->valid) {
- $logger->info("Event group is valid, reacting...");
+ $logger->info("trigger: Event group is valid, reacting...");
$e->react->cleanup;
}
@@ -523,7 +539,7 @@
return $editor->search_action_trigger_event(
[{ state => 'pending', run_time => {'<' => 'now'} }, { order_by => { atev => [ qw/run_time add_time/] } }],
- { idlist=> 1, timeout => 7200 }
+ { idlist=> 1, timeout => 7200, substream => 1 }
);
}
__PACKAGE__->register_method(
@@ -540,6 +556,13 @@
my %groups = ( '*' => [] );
+ if($events) {
+ $logger->info("trigger: grouped_events found ".scalar(@$events)." pending events to process");
+ } else {
+ $logger->warn("trigger: grouped_events timed out loading pending events");
+ return \%groups;
+ }
+
for my $e_id ( @$events ) {
$logger->info("trigger: processing event $e_id");
@@ -550,7 +573,7 @@
try {
$e = OpenILS::Application::Trigger::Event->new($e_id);
} catch Error with {
- $logger->error("Event creation failed with ".shift());
+ $logger->error("trigger: Event creation failed with ".shift());
};
next unless $e;
@@ -558,7 +581,7 @@
try {
$e->build_environment;
} catch Error with {
- $logger->error("Event environment building failed with ".shift());
+ $logger->error("trigger: Event environment building failed with ".shift());
};
if (my $group = $e->event->event_def->group_field) {
@@ -601,6 +624,7 @@
for my $def ( keys %$groups ) {
if ($def eq '*') {
+ $logger->info("trigger: run_all_events firing un-grouped events");
for my $event ( @{ $$groups{'*'} } ) {
try {
$client->respond(
@@ -609,11 +633,14 @@
->run($event)
);
} catch Error with {
- $logger->error("event firing failed with ".shift());
+ $logger->error("trigger: event firing failed with ".shift());
};
}
+ $logger->info("trigger: run_all_events completed firing un-grouped events");
+
} else {
my $defgroup = $$groups{$def};
+ $logger->info("trigger: run_all_events firing events for grouped event def=$def");
for my $ident ( keys %$defgroup ) {
try {
$client->respond(
@@ -622,9 +649,10 @@
->run($$defgroup{$ident})
);
} catch Error with {
- $logger->error("event firing failed with ".shift());
+ $logger->error("trigger: event firing failed with ".shift());
};
}
+ $logger->info("trigger: run_all_events completed firing events for grouped event def=$def");
}
}
Modified: branches/rel_1_6/Open-ILS/src/support-scripts/action_trigger_runner.pl
===================================================================
--- branches/rel_1_6/Open-ILS/src/support-scripts/action_trigger_runner.pl 2010-06-11 13:49:45 UTC (rev 16675)
+++ branches/rel_1_6/Open-ILS/src/support-scripts/action_trigger_runner.pl 2010-06-11 13:50:24 UTC (rev 16676)
@@ -19,8 +19,10 @@
use OpenSRF::System;
use OpenSRF::AppSession;
use OpenSRF::Utils::JSON;
+use OpenSRF::Utils::Logger qw/$logger/;
use OpenSRF::EX qw(:try);
use OpenILS::Utils::Fieldmapper;
+my $req_timeout = 10800;
my $opt_lockfile = '/tmp/action-trigger-LOCK';
my $opt_osrf_config = '/openils/conf/opensrf_core.xml';
@@ -135,11 +137,22 @@
$method =~ s/passive/active/ if $config->{active};
my $req = $ses->request($method, $hook, $config->{context_org}, $config->{filter});
- while(my $resp = $req->recv(timeout => 1800)) {
- if($opt_debug_stdout) {
- print OpenSRF::Utils::JSON->perl2JSON($resp->content) . "\n";
- }
+
+ my $debug_hook = "'$hook' and filter ".OpenSRF::Utils::JSON->perl2JSON($config->{filter});
+ $logger->info("at_runner: creating events for $debug_hook");
+
+ my @event_ids;
+ while (my $resp = $req->recv(timeout => $req_timeout)) {
+ push(@event_ids, $resp->content);
}
+
+ if(@event_ids) {
+ $logger->info("at_runner: created ".scalar(@event_ids)." events for $debug_hook");
+ } elsif($req->complete) {
+ $logger->info("at_runner: no events to create for $debug_hook");
+ } else {
+ $logger->warn("at_runner: timeout occurred during event creation for $debug_hook");
+ }
}
}
@@ -147,7 +160,7 @@
return unless $opt_run_pending;
my $ses = OpenSRF::AppSession->create('open-ils.trigger');
my $req = $ses->request('open-ils.trigger.event.run_all_pending');
- while(my $resp = $req->recv(timeout => 600)) {
+ while (my $resp = $req->recv(timeout => $req_timeout)) {
if($opt_debug_stdout) {
print OpenSRF::Utils::JSON->perl2JSON($resp->content) . "\n";
}
More information about the open-ils-commits
mailing list