madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[TheSchwartz] r161: LJSUP-14413: ESN line prioritization

Committer: sbelyaev
LJSUP-14413: ESN line prioritization
U   trunk/lib/TheSchwartz.pm
Modified: trunk/lib/TheSchwartz.pm
===================================================================
--- trunk/lib/TheSchwartz.pm	2012-11-09 09:07:18 UTC (rev 160)
+++ trunk/lib/TheSchwartz.pm	2012-11-29 10:52:38 UTC (rev 161)
@@ -2,7 +2,7 @@
 
 package TheSchwartz;
 use strict;
-use fields qw( databases retry_seconds dead_dsns retry_at funcmap_cache verbose all_abilities current_abilities current_job cached_drivers driver_cache_expiration scoreboard prioritize delete_every_n_errors find_job_limit );
+use fields qw( databases retry_seconds dead_dsns retry_at funcmap_cache verbose all_abilities current_abilities current_job cached_drivers driver_cache_expiration scoreboard prioritize delete_every_n_errors find_job_limit priority_limit );
 
 our $VERSION = "1.07";
 
@@ -36,6 +36,7 @@
 
     $client->{retry_seconds} = delete $args{retry_seconds} || RETRY_DEFAULT;
     $client->set_prioritize(delete $args{prioritize});
+    $client->set_priority_limit(delete $args{priority_limit});
     $client->set_verbose(delete $args{verbose});
     $client->set_scoreboard(delete $args{scoreboard});
     $client->{driver_cache_expiration} = delete $args{driver_cache_expiration} || 0;
@@ -261,6 +262,7 @@
 
         my $driver = $client->driver_for($hashdsn);
         my $unixtime = $driver->dbd->sql_for_unixtime;
+        my $priority_limit = $client->priority_limit;
 
         my @jobs;
         eval {
@@ -271,13 +273,16 @@
             ##    in the past).
             my @ids = map { $client->funcname_to_id($driver, $hashdsn, $_) }
                       @$worker_classes;
-
+           
             @jobs = $driver->search(
                 'TheSchwartz::Job' =>
                 {
                     funcid        => \@ids,
                     run_after     => \ "<= $unixtime",
                     grabbed_until => \ "<= $unixtime",
+                    (defined $priority_limit ?
+                        ('priority' =>  \" = $priority_limit") : ()),
+
                 },
                 {
                     limit => $limit || $FIND_JOB_BATCH_SIZE,
@@ -770,6 +775,17 @@
     return $client->{verbose};
 }
 
+sub set_priority_limit {
+    my TheSchwartz $client = shift;
+    my $limit = shift;
+    $client->{priority_limit} = $limit;
+}
+
+sub priority_limit {
+    my TheSchwartz $client = shift;
+    return $client->{priority_limit};
+} 
+
 sub set_find_job_limit {
     my TheSchwartz $client = shift;
     my $limit = shift;

Tags: madeon, pm, sbelyaev, theschwartz
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments