From 19f2280bb1a83ff37b688a216a3eebb6cde54a99 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 29 Sep 2010 15:05:53 +0000 Subject: [PATCH] support per-grunlarity parallelizing via flag and lock file git-svn-id: svn://svn.open-ils.org/ILS/trunk@18099 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Trigger.pm | 13 +++++++++--- .../perlmods/OpenILS/Application/Trigger/Event.pm | 1 + .../src/support-scripts/action_trigger_runner.pl | 23 ++++++++++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm index 4a80255376..c73d29ed67 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm @@ -593,11 +593,16 @@ sub pending_events { my $self = shift; my $client = shift; my $granularity = shift; + my $granflag = shift; my $query = [{ state => 'pending', run_time => {'<' => 'now'} }, { order_by => { atev => [ qw/run_time add_time/] }, 'join' => 'atevdef' }]; if (defined $granularity) { - $query->[0]->{'+atevdef'} = {'-or' => [ {granularity => $granularity}, {granularity => undef} ] }; + if ($granflag) { + $query->[0]->{'+atevdef'} = {granularity => $granularity}; + } else { + $query->[0]->{'+atevdef'} = {'-or' => [ {granularity => $granularity}, {granularity => undef} ] }; + } } else { $query->[0]->{'+atevdef'} = {granularity => undef}; } @@ -616,8 +621,9 @@ sub grouped_events { my $self = shift; my $client = shift; my $granularity = shift; + my $granflag = shift; - my ($events) = $self->method_lookup('open-ils.trigger.event.find_pending')->run($granularity); + my ($events) = $self->method_lookup('open-ils.trigger.event.find_pending')->run($granularity, $granflag); my %groups = ( '*' => [] ); @@ -685,8 +691,9 @@ sub run_all_events { my $self = shift; my $client = shift; my $granularity = shift; + my $granflag = shift; - my ($groups) = $self->method_lookup('open-ils.trigger.event.find_pending_by_group')->run($granularity); + my ($groups) = $self->method_lookup('open-ils.trigger.event.find_pending_by_group')->run($granularity, $granflag); # Could report on how the "found" events were grouped, but who's going to # consume that information? diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm index 3a635ec3c9..fe70c5b024 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm @@ -352,6 +352,7 @@ sub update_state { $e->state( $state ); $e->clear_start_time() if ($e->state eq 'pending'); + $e->complete_time( 'now' ) if ($e->state eq 'complete'); my $ok = $self->editor->update_action_trigger_event( $e ); if (!$ok) { diff --git a/Open-ILS/src/support-scripts/action_trigger_runner.pl b/Open-ILS/src/support-scripts/action_trigger_runner.pl index 8013e576b6..eaddd45fb1 100755 --- a/Open-ILS/src/support-scripts/action_trigger_runner.pl +++ b/Open-ILS/src/support-scripts/action_trigger_runner.pl @@ -37,6 +37,7 @@ my $opt_verbose; my $opt_hooks; my $opt_process_hooks = 0; my $opt_granularity = undef; +my $opt_gran_only = undef; (-f $opt_custom_filter) or undef($opt_custom_filter); # discard default if no file exists @@ -46,6 +47,7 @@ GetOptions( 'run-pending' => \$opt_run_pending, 'hooks=s' => \$opt_hooks, 'granularity=s' => \$opt_granularity, + 'granularity-only' => \$opt_gran_only, 'process-hooks' => \$opt_process_hooks, 'debug-stdout' => \$opt_debug_stdout, 'custom-filters=s' => \$opt_custom_filter, @@ -56,6 +58,8 @@ GetOptions( my $max_sleep = $opt_max_sleep; +$opt_lockfile .= '.' . $opt_granularity if ($opt_granularity && $opt_gran_only); + # typical passive hook filters my $hook_handlers = { @@ -109,6 +113,9 @@ $0 : Create and process action/trigger events --granularity=