[open-ils-commits] r18100 - in branches/rel_2_0/Open-ILS/src: perlmods/OpenILS/Application perlmods/OpenILS/Application/Trigger support-scripts (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 29 11:06:27 EDT 2010
Author: miker
Date: 2010-09-29 11:06:25 -0400 (Wed, 29 Sep 2010)
New Revision: 18100
Modified:
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
branches/rel_2_0/Open-ILS/src/support-scripts/action_trigger_runner.pl
Log:
Backport r18099 from trunk: support per-grunlarity parallelizing via flag and lock file
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm 2010-09-29 15:05:53 UTC (rev 18099)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm 2010-09-29 15:06:25 UTC (rev 18100)
@@ -352,6 +352,7 @@
$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) {
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2010-09-29 15:05:53 UTC (rev 18099)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2010-09-29 15:06:25 UTC (rev 18100)
@@ -593,11 +593,16 @@
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 @@
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 @@
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?
Modified: branches/rel_2_0/Open-ILS/src/support-scripts/action_trigger_runner.pl
===================================================================
--- branches/rel_2_0/Open-ILS/src/support-scripts/action_trigger_runner.pl 2010-09-29 15:05:53 UTC (rev 18099)
+++ branches/rel_2_0/Open-ILS/src/support-scripts/action_trigger_runner.pl 2010-09-29 15:06:25 UTC (rev 18100)
@@ -37,6 +37,7 @@
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 @@
'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 @@
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 @@
--granularity=<label>
Run events with {label} granularity setting, or no granularity setting
+ --granularity-only
+ Used in combination with --granularity, prevents the running of events with no granularity setting
+
--debug-stdout
Print server responses to stdout (as JSON) for debugging
@@ -169,10 +176,22 @@
sub run_pending {
$opt_verbose and print "run_pending: " .
- ($opt_run_pending ? ($opt_granularity || 'ALL granularity') : 'SKIPPING') . "\n";
+ ($opt_run_pending ?
+ ($opt_granularity ?
+ ( $opt_granularity . (
+ $opt_gran_only ?
+ ' ONLY' :
+ ' and NON-GRANULAR'
+ )
+ ) :
+ 'NON-GRANULAR'
+ ) :
+ 'SKIPPING'
+ ) . "\n";
+
return unless $opt_run_pending;
my $ses = OpenSRF::AppSession->create('open-ils.trigger');
- my $req = $ses->request('open-ils.trigger.event.run_all_pending' => $opt_granularity);
+ my $req = $ses->request('open-ils.trigger.event.run_all_pending' => $opt_granularity => $opt_gran_only);
my $check_lockfile = 1;
while (my $resp = $req->recv(timeout => $req_timeout)) {
More information about the open-ils-commits
mailing list