madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[TheSchwartz] r160: LJSUP-14210: TheSchwartz should be able ...

Committer: sbelyaev
LJSUP-14210: TheSchwartz should be able to use custom limit for jobs [internal]
U   trunk/lib/TheSchwartz.pm
Modified: trunk/lib/TheSchwartz.pm
===================================================================
--- trunk/lib/TheSchwartz.pm	2012-06-04 14:46:27 UTC (rev 159)
+++ trunk/lib/TheSchwartz.pm	2012-11-09 09:07:18 UTC (rev 160)
@@ -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 );
+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 );
 
 our $VERSION = "1.07";
 
@@ -251,8 +251,9 @@
 
 sub find_job_for_workers {
     my TheSchwartz $client = shift;
-    my($worker_classes) = @_;
+    my($worker_classes, $limit) = @_;
     $worker_classes ||= $client->{current_abilities};
+    $limit          ||= $client->{find_job_limit};
 
     for my $hashdsn ($client->shuffled_databases) {
         ## If the database is dead, skip it.
@@ -279,7 +280,7 @@
                     grabbed_until => \ "<= $unixtime",
                 },
                 {
-                    limit => $FIND_JOB_BATCH_SIZE,
+                    limit => $limit || $FIND_JOB_BATCH_SIZE,
                     (
                         $client->prioritize
                             ? (
@@ -769,6 +770,12 @@
     return $client->{verbose};
 }
 
+sub set_find_job_limit {
+    my TheSchwartz $client = shift;
+    my $limit = shift;
+    $client->{find_job_limit} = $limit;
+} 
+
 sub set_verbose {
     my TheSchwartz $client = shift;
     my $logger = shift;   # or non-coderef to just print to stderr

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