Committer: sbelyaev
LJSUP-14413: ESN line prioritizationU trunk/cgi-bin/LJ/ESN.pm U trunk/cgi-bin/LJ/Event/JournalNewComment.pm U trunk/cgi-bin/LJ/Event.pm U trunk/cgi-bin/LJ/NewWorker/TheSchwartz.pm
Modified: trunk/cgi-bin/LJ/ESN.pm =================================================================== --- trunk/cgi-bin/LJ/ESN.pm 2012-11-29 10:23:23 UTC (rev 23389) +++ trunk/cgi-bin/LJ/ESN.pm 2012-11-29 10:52:05 UTC (rev 23390) @@ -61,6 +61,7 @@ next if $has_done{$s->unique}++; push @subjobs, TheSchwartz::Job->new( funcname => 'LJ::Worker::ProcessSub', + priority => $evt->priority, arg => { 'userid' => $s->userid + 0, 'subdump' => $s->dump, Modified: trunk/cgi-bin/LJ/Event/JournalNewComment.pm =================================================================== --- trunk/cgi-bin/LJ/Event/JournalNewComment.pm 2012-11-29 10:23:23 UTC (rev 23389) +++ trunk/cgi-bin/LJ/Event/JournalNewComment.pm 2012-11-29 10:52:05 UTC (rev 23390) @@ -16,6 +16,7 @@ return $class->SUPER::new($comment->journal, $comment->jtalkid); } +sub priority { 5 } sub is_common { 1 } my @_ml_strings_en = ( Modified: trunk/cgi-bin/LJ/Event.pm =================================================================== --- trunk/cgi-bin/LJ/Event.pm 2012-11-29 10:23:23 UTC (rev 23389) +++ trunk/cgi-bin/LJ/Event.pm 2012-11-29 10:52:05 UTC (rev 23390) @@ -64,6 +64,10 @@ use LJ::Typemap; use LJ::Text; +use constant { + BASE_PRIORITY => 0, +}; + ### COMMON FUNCTIONS ### # create a new event structure based on its type, journal and arguments @@ -249,6 +253,10 @@ return $tm->all_classes; } +sub priority { + return BASE_PRIORITY; +} + # return string containing nicely-represented list of links to go with # the notification (the "now that you're receiving this notification, you # can" one) @@ -547,6 +555,8 @@ my $job = $self->fire_job or return 0; + $job->priority($self->priority); + my $h = $sclient->insert($job); return $h ? 1 : 0; } Modified: trunk/cgi-bin/LJ/NewWorker/TheSchwartz.pm =================================================================== --- trunk/cgi-bin/LJ/NewWorker/TheSchwartz.pm 2012-11-29 10:23:23 UTC (rev 23389) +++ trunk/cgi-bin/LJ/NewWorker/TheSchwartz.pm 2012-11-29 10:52:05 UTC (rev 23390) @@ -8,13 +8,17 @@ my $interval = 10; my $verbose = 0; +my $prioritize = 0; my $schwartz_role = $LJ::THESCHWARTZ_ROLE_WORKER; +my $priority_limit; sub options { my $self = shift; return ( 'interval|i=i' => \$interval, 'schwartz-role|r=s' => \$schwartz_role, + 'priority-level|l=i' => \$priority_limit, + 'prioritize|p' => \$prioritize, $self->SUPER::options(), ); } @@ -24,6 +28,8 @@ return $self->SUPER::help() . "-i | --interval=n set sleep interval to n secounds\n" . + "-l | --priority-level=n work only with this priority level\n" . + "-p | --prioritize use prioritization\n". "-r | --schwartz-role=role connect to db with specified role (defualt is '$schwartz_role')\n"; } @@ -47,6 +53,9 @@ warn "The Schwartz _init(): init with role '$schwartz_role'.\n" if $verbose; $sclient = LJ::theschwartz({ role => $schwartz_role }) or die "Could not get schwartz client"; + $sclient->set_prioritize($prioritize); + $sclient->set_priority_limit($priority_limit) if defined $priority_limit; + $sclient->set_verbose( $class->schwartz_verbose_handler || $class->verbose ); $sclient->set_find_job_limit( $class->find_job_limit ); foreach my $classname ($class->capabilities) {