Author: spadkins
Date: Tue May  2 06:56:33 2006
New Revision: 6007

Modified:
   p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm
   p5ee/trunk/App-WorkQueue/lib/App/WorkQueue/Repository.pm
   p5ee/trunk/App-WorkQueue/t/queue-db.t

Log:
can now release() entries which are not yet acquire()d

Modified: p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm
==============================================================================
--- p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm       (original)
+++ p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm       Tue May  2 06:56:33 2006
@@ -273,8 +273,8 @@
                 $ent = $entries->[$i];
                 if ($self->_resource_key($ent) eq $resource_key) {
                     # IF not inserted yet AND new entry is lower or same 
priority THEN
-                    $cmp = $self->_compare_entries($entry, $ent);
-                    if (!$inserted && $cmp > -1) {
+                    $cmp = $self->_compare_entries($entry, $ent);  # a "-1" 
means higher priority
+                    if (!$inserted && $cmp > -1) {   # new $entry is *not* 
higher priority
                         if (!$removed) {   # "insert and remove self"
                             $inserted = 1;
                             $removed  = 1;
@@ -293,7 +293,7 @@
                     }
                 }
                 else {
-                    if (!$inserted && $self->_compare_entries($entry, $ent) > 
-1) {
+                    if ($removed && !$inserted && 
$self->_compare_entries($entry, $ent) > -1) {
                         
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
                         splice(@$entries, $i+1, 0, $entry);
                         $inserted = 1;
@@ -321,6 +321,7 @@
 }
 
 sub _analyze_sort_spec {
+    &App::sub_entry if ($App::trace);
     my ($self) = @_;
     my $sort_spec = $self->{sort_spec};
     if ($sort_spec) {
@@ -356,10 +357,18 @@
         $self->{direction}    = [];
         $self->{numeric}      = [];
     }
+    &App::sub_exit() if ($App::trace);
 }
 
+# for a sorting function, a $sign=-1 means the first entry ($a) is "smaller" 
so sorts earlier (higher priority)
+# for a sorting function, a $sign=1  means the first entry ($a) is "larger"  
so sorts later   (lower priority)
+# so (1 <=> 2) = -1
+#    (2 <=> 2) = 0
+#    (2 <=> 1) = 1
 sub _compare_entries {
+    &App::sub_entry if ($App::trace);
     my ($self, $a, $b) = @_;
+    my $verbose = $self->{verbose};
     my $sign = 0;
     my $columns   = $self->{sort_columns};
     my $sort_idx  = $self->{sort_idx};
@@ -375,11 +384,13 @@
                 $sign = ($a->[$sort_idx->[$c]] cmp $b->[$sort_idx->[$c]]) * 
$direction->[$c];
                 #print "C: $sign = ($a->[$sort_idx->[$c]] <=> 
$b->[$sort_idx->[$c]]) * $direction->[$c];\n";
             }
+            # print "$sign = ($a->[$sort_idx->[$c]] cmp $b->[$sort_idx->[$c]]) 
* $direction->[$c];\n";
             last if ($sign);
         }
-        #print "A: [", join("|",@$a), "]\n";
-        #print "B: [", join("|",@$b), "]\n";
-        #print " => $sign\n";
+        #if ($verbose) {
+        #    print "compare [$sign] [", join("|",@$a), "]\n";
+        #    print "            [", join("|",@$b), "]\n";
+        #}
     }
     else {
         for (my $c = 0; $c <= $#$columns; $c++) {
@@ -391,7 +402,12 @@
             }
             last if ($sign);
         }
+        #if ($verbose) {
+        #    print "compare [$sign] {", join("|",%$a), "}\n";
+        #    print "            {", join("|",%$b), "}\n";
+        #}
     }
+    &App::sub_exit($sign) if ($App::trace);
     return($sign);
 }
 
@@ -432,7 +448,7 @@
     my $status_attrib     = $self->{status_attrib};
     my $entries           = $self->{data};
 
-    if ($self->_global_resources_exist()) {
+    if ($self->num_entries() > 0 && $self->_global_resources_exist()) {
         if ($self->{type} eq "ARRAY") {
             my $colidx = $self->_colidx();
             my $status_idx = $colidx->{$status_attrib};
@@ -567,6 +583,7 @@
         CORE::push(@values,  @$values);
     }
 
+    my $released = 0;
     if ($self->{type} eq "ARRAY") {
         my $colidx = $self->_colidx();
         my $status_idx = $colidx->{$status_attrib};
@@ -581,6 +598,7 @@
                 $self->update($ent,[EMAIL PROTECTED],[EMAIL PROTECTED]);
                 splice(@$data, $e, 1);
                 print "RELEASED[M]: [", join("|",@$entry), "]\n" if ($verbose);
+                $released = 1;
                 last;
             }
         }
@@ -596,12 +614,14 @@
                 $self->update($ent,[EMAIL PROTECTED],[EMAIL PROTECTED]);
                 splice(@$data, $e, 1);
                 print "RELEASED[M]: {", join("|",%$entry), "}\n" if ($verbose);
+                $released = 1;
                 last;
             }
         }
     }
 
-    &App::sub_exit() if ($App::trace);
+    &App::sub_exit($released) if ($App::trace);
+    return($released);
 }
 
 sub _array_to_key {
@@ -626,9 +646,9 @@
 sub _hash_to_key {
     my ($self, $entry) = @_;
     my ($key);
-    my $auto_id_idx = $self->{auto_id_idx};
-    if (defined $auto_id_idx) {
-        $key = $entry->[$auto_id_idx];
+    my $auto_id_attrib = $self->{auto_id_attrib};
+    if (defined $auto_id_attrib) {
+        $key = $entry->{$auto_id_attrib};
     }
     else {
         my $id_attribs = $self->{id_attribs};
@@ -890,9 +910,32 @@
     my $self = shift;
     my %event = @_;
     $self->{acquisition_event} = \%event;
+    my $context = $self->{context};
+    $context->extend_event_loop($self, "dispatch_events", [1]);
     &App::sub_exit() if ($App::trace);
 }
 
+sub dispatch_events {
+    &App::sub_entry if ($App::trace);
+    my ($self, $max_events) = @_;
+    $max_events = 1 if (!$max_events);
+    my $num_events = 0;
+    if ($self->{acquisition_event}) {
+        my $context = $self->{context};
+        my ($entry, %event);
+        while ($num_events < $max_events) {
+            $entry = $self->acquire();
+            last if (!$entry);
+            $num_events++;
+            %event = %{$self->{acquisition_event}};
+            $event{args} = [ $entry ];
+            $context->send_event(\%event);
+        }
+    }
+    &App::sub_exit($num_events) if ($App::trace);
+    return($num_events);
+}
+
 #############################################################################
 # print()
 #############################################################################
@@ -1631,7 +1674,7 @@
 =head2 _maintain_queue_buffers()
 
     * Signature: $q->_maintain_queue_buffers($add, $entry);
-    * Param:     $add               [-1,0,1]
+    * Param:     $op                [push,acquire,release,unacquire]
     * Param:     $entry             ARRAY/HASH
     * Return:    undef
     * Throws:    App::Exception::WorkQueue

Modified: p5ee/trunk/App-WorkQueue/lib/App/WorkQueue/Repository.pm
==============================================================================
--- p5ee/trunk/App-WorkQueue/lib/App/WorkQueue/Repository.pm    (original)
+++ p5ee/trunk/App-WorkQueue/lib/App/WorkQueue/Repository.pm    Tue May  2 
06:56:33 2006
@@ -71,7 +71,7 @@
         name          => $self->{name},
         method        => "_heartbeat",
         time          => time(),
-        interval      => $options->{sleep_time} || 60,
+        interval      => $self->{heartbeat} || 60,
         scheduled     => 1,
     );
 
@@ -81,7 +81,7 @@
 sub _init_db {
     &App::sub_entry if ($App::trace);
     my ($self, $args) = @_;
-    die "STATUS_UNBUFFERED [$self->{STATUS_UNBUFFERED}] != STATUS_UNACQUIRED 
[$self->{STATUS_UNACQUIRED}] on queue"
+    die "STATUS_UNBUFFERED [$self->{STATUS_UNBUFFERED}] != STATUS_UNACQUIRED 
[$self->{STATUS_UNACQUIRED}] on queue[$self->{name}]"
         if ($self->{STATUS_UNBUFFERED} ne $self->{STATUS_UNACQUIRED});
     $self->_refresh_queue();
     &App::sub_exit() if ($App::trace);
@@ -91,7 +91,7 @@
     &App::sub_entry if ($App::trace);
     my ($self) = @_;
     my $context = $self->{context};
-    $context->log("[$self->{name}] _heartbeat\n");
+    $context->log({level=>4}, "[$self->{name}] _heartbeat\n");
     $self->_refresh_queue();
     &App::sub_exit() if ($App::trace);
 }
@@ -100,20 +100,10 @@
     &App::sub_entry if ($App::trace);
     my ($self) = @_;
     my $context = $self->{context};
-    $context->log("[$self->{name}] _refresh_queue\n");
+    $context->log({level=>3},"[$self->{name}] _refresh_queue\n");
     $self->_refresh_status_counts();
     $self->_refresh_resource_counts();
     $self->_maintain_queue_buffers();
-    if ($self->{acquisition_event}) {
-        my ($entry, %event);
-        while (1) {
-            $entry = $self->acquire();
-            last if (!$entry);
-            %event = %{$self->{acquisition_event}};
-            $event{args} = [ $entry ];
-            $context->send_event(\%event);
-        }
-    }
     &App::sub_exit() if ($App::trace);
 }
 
@@ -123,7 +113,7 @@
     my $status_attrib = $self->{status_attrib};
     my (%counts, $count_all);
     $self->_count_entries_by_attrib_in_db($status_attrib, \%counts, undef,
-        
"$self->{STATUS_UNBUFFERED},$self->{STATUS_UNACQUIRED},$self->{STATUS_ACQUIRED}");
+        
$self->unique_list($self->{STATUS_UNBUFFERED},$self->{STATUS_UNACQUIRED},$self->{STATUS_ACQUIRED}));
     $count_all = 0;
     foreach my $key (keys %counts) {
         $count_all += $counts{$key};
@@ -140,11 +130,10 @@
     # --------------
     my $STATUS_UNBUFFERED = $self->{STATUS_UNBUFFERED};
     my $STATUS_UNACQUIRED = $self->{STATUS_UNACQUIRED};
-    my $STATUS_ACQUIRED   = $self->{STATUS_ACQUIRED};
     my $status_attrib     = $self->{status_attrib};
     my $db = $self->_db();
     my $count_expr = "count(1)";
-    my $status = "$STATUS_UNBUFFERED,$STATUS_UNACQUIRED";
+    my $status = ($STATUS_UNBUFFERED ne $STATUS_UNACQUIRED) ? 
"$STATUS_UNBUFFERED,$STATUS_UNACQUIRED" : $STATUS_UNBUFFERED;
     my $params = { $status_attrib => $status };
     if ($self->{multiple_queues} && $self->{client_id_attrib} && 
$self->{client_id}) {
         $params->{$self->{client_id_attrib}} = $self->{client_id};
@@ -305,9 +294,53 @@
 sub release {
     &App::sub_entry if ($App::trace);
     my ($self, $entry, $columns, $values) = @_;
-    $self->_maintain_queue_buffers("release",$entry,$columns,$values);
+    my $status_attrib = $self->{status_attrib};
+    my $STATUS_ACQUIRED = $self->{STATUS_ACQUIRED};
+    my ($resource_counts, $resource_key, $release_without_acquire);
+    if ($self->{type} eq "ARRAY") {
+        my $colidx = $self->_colidx();
+        my $status_idx = $colidx->{$status_attrib};
+        if ($entry->[$status_idx] ne $STATUS_ACQUIRED) {
+            $release_without_acquire = 1;
+        }
+    }
+    else {
+        if ($entry->{$status_attrib} ne $STATUS_ACQUIRED) {
+            $release_without_acquire = 1;
+        }
+    }
+    if ($release_without_acquire) {
+        $resource_counts = $self->_resource_counts();
+        $resource_key = $self->_resource_key($entry);
+        $resource_counts->{total}{$resource_key}--;
+    }
+    my $released = $self->_release_in_mem($entry, $columns, $values);
+    if ($released) {
+        $resource_counts->{buffer}{$resource_key}-- if 
($release_without_acquire);
+        $self->_maintain_queue_buffers(undef,$entry,$columns,$values);
+    }
+    else {
+        $released = $self->_release_in_db($entry,$columns,$values);
+    }
     $self->print() if ($self->{verbose});
-    &App::sub_exit() if ($App::trace);
+    &App::sub_exit($released) if ($App::trace);
+    return($released);
+}
+
+sub _release_in_db {
+    &App::sub_entry if ($App::trace);
+    my ($self, $entry, $columns, $values) = @_;
+
+    my @columns = ( $self->{status_attrib} );
+    my @values  = ( $self->{STATUS_RELEASED} );
+    if ($columns) {
+        CORE::push(@columns, @$columns);
+        CORE::push(@values,  @$values);
+    }
+    my $released = $self->update($entry,[EMAIL PROTECTED],[EMAIL PROTECTED]);
+
+    &App::sub_exit($released) if ($App::trace);
+    return($released);
 }
 
 sub _refill_buffer {
@@ -405,7 +438,7 @@
     my $STATUS_UNACQUIRED = $self->{STATUS_UNACQUIRED};
     my $STATUS_ACQUIRED   = $self->{STATUS_ACQUIRED};
     my $status_attrib     = $self->{status_attrib};
-    $params{$status_attrib} = 
"$STATUS_UNBUFFERED,$STATUS_UNACQUIRED,$STATUS_ACQUIRED";
+    $params{$status_attrib} = 
$self->unique_list($STATUS_UNBUFFERED,$STATUS_UNACQUIRED,$STATUS_ACQUIRED);
     if ($self->{multiple_queues} && $self->{client_id_attrib} && 
$self->{client_id}) {
         $params{$self->{client_id_attrib}} = $self->{client_id};
     }
@@ -544,12 +577,13 @@
     my ($self, $key_attrib, $counts, $count_attrib, $status) = @_;
     my $STATUS_UNBUFFERED = $self->{STATUS_UNBUFFERED};
     my $STATUS_UNACQUIRED = $self->{STATUS_UNACQUIRED};
-    my $STATUS_ACQUIRED   = $self->{STATUS_ACQUIRED};
     my $status_attrib     = $self->{status_attrib};
     my $db = $self->_db();
     my $count_expr = "count(1)";
     $count_expr = "sum($count_attrib)" if ($count_attrib);
-    $status = "$STATUS_UNBUFFERED,$STATUS_UNACQUIRED" if (!$status);
+    if (!$status) {
+        $status = ($STATUS_UNBUFFERED ne $STATUS_UNACQUIRED) ? 
"$STATUS_UNBUFFERED,$STATUS_UNACQUIRED" : $STATUS_UNBUFFERED;
+    }
     my $params = { $status_attrib => $status };
     if ($self->{multiple_queues} && $self->{client_id_attrib} && 
$self->{client_id}) {
         $params->{$self->{client_id_attrib}} = $self->{client_id};
@@ -604,7 +638,7 @@
     my (%options);
     $self->_sort_spec_to_options(\%options);
     my $params = {
-        $self->{status_attrib} => 
"$self->{STATUS_UNBUFFERED},$self->{STATUS_UNACQUIRED},$self->{STATUS_ACQUIRED}",
+        $self->{status_attrib} => 
$self->unique_list($self->{STATUS_UNBUFFERED},$self->{STATUS_UNACQUIRED},$self->{STATUS_ACQUIRED}),
     };
     if ($self->{multiple_queues} && $self->{client_id_attrib} && 
$self->{client_id}) {
         $params->{$self->{client_id_attrib}} = $self->{client_id};
@@ -627,6 +661,20 @@
     &App::sub_exit() if ($App::trace);
 }
 
+sub unique_list {
+    my ($self, @list) = @_;
+    my (%seen);
+    my $list = "";
+    foreach my $elem (@list) {
+        if (!$seen{$elem}) {
+            $seen{$elem} = 1;
+            $list .= "," if ($list);
+            $list .= $elem;
+        }
+    }
+    return($list);
+}
+
 =head1 ACKNOWLEDGEMENTS
 
  * Author:  Stephen Adkins <[EMAIL PROTECTED]>

Modified: p5ee/trunk/App-WorkQueue/t/queue-db.t
==============================================================================
--- p5ee/trunk/App-WorkQueue/t/queue-db.t       (original)
+++ p5ee/trunk/App-WorkQueue/t/queue-db.t       Tue May  2 06:56:33 2006
@@ -25,10 +25,12 @@
 use App::Repository;
 use strict;
 
+my $t_dir = (-d "t") ? "t" : ".";
+
 use App::WorkQueue::Repository;
 
-if (!$App::options{dbuser}) {
-    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy 
to app.conf in 't' directory)");
+if (! -f "$t_dir/app.conf") {
+    ok(1, "No dbuser given. Tests assumed OK. (add dbname=abc, dbuser=xxx, and 
dbpass=yyy to app.conf in 't' directory)");
     exit(0);
 }
 
@@ -253,10 +255,10 @@
     }
     else {
         ok(!$@, "No error on $qname->push(array) [EMAIL PROTECTED]");
-        ($shop_request_id,$request_status,$shop_host)= 
$db->get($table,{shop_request_id=>6},["shop_request_id","request_status","shop_host"]);
-        is($shop_request_id, 6, "push(6) made it to the table");
-        is($request_status, "N", "push(6) is N");
-        #is($shop_host, $App::options{host}, "push(6) is $App::options{host}");
+        ($shop_request_id,$request_status,$shop_host)= 
$db->get($table,{shop_request_id=>8},["shop_request_id","request_status","shop_host"]);
+        is($shop_request_id, 8, "push(8) made it to the table");
+        is($request_status, "N", "push(8) is N");
+        #is($shop_host, $App::options{host}, "push(8) is $App::options{host}");
         &test_status_counts($q, 2, 0, 1, 0);
         &test_resource_buffer_counts($q, "TRV:trv", 1, 1);
     }
@@ -297,6 +299,49 @@
     &test_status_counts($q, 4, 0, 0, 0);
     &test_resource_buffer_counts($q, "EXP:exp", 1, 2);
 
+    
###############################################################################
+    # Test release() for unacquired
+    
###############################################################################
+    my $entry = [ 
6,1,128,"TRV","USD","US",1,1,"2006-04-01","2006-04-30","1,2,3,4,5,6,7",129,"1",
+        "2006-01-04 12:00:00", "2006-01-04 12:00:00", "2006-01-04 12:00:00", 
"2006-01-04 12:00:00", 
+        "W", "spadkins", "MV", "MV", 90, 0, undef, "[EMAIL PROTECTED]", 
"ShopReport", 90, "default",
+        0, 0, "x", 4, 1800, "trv", undef, 0, undef, "compare.detail.html", 
"None", undef, 2, ];
+    $q->push($entry);
+    ($shop_request_id,$request_status,$shop_host)= 
$db->get($table,{shop_request_id=>6},["shop_request_id","request_status","shop_host"]);
+    is($shop_request_id, 6, "push(6) made it to the table");
+    is($request_status, "N", "push(6) is N");
+    #is($shop_host, $App::options{host}, "push(6) is $App::options{host}");
+    &test_status_counts($q, 5, 0, 0, 0);
+    &test_resource_buffer_counts($q, "TRV:trv", 1, 3);
+
+    my $entry2 = [ 
7,1,128,"TRV","USD","US",1,1,"2006-04-01","2006-04-30","1,2,3,4,5,6,7",129,"1",
+        "2006-01-04 12:00:00", "2006-01-04 12:00:00", "2006-01-04 12:00:00", 
"2006-01-04 12:00:00", 
+        "W", "spadkins", "MV", "MV", 90, 0, undef, "[EMAIL PROTECTED]", 
"ShopReport", 90, "default",
+        0, 0, "x", 2, 1800, "trv", undef, 0, undef, "compare.detail.html", 
"None", undef, 2, ];
+    $q->push($entry2);
+    ($shop_request_id,$request_status,$shop_host)= 
$db->get($table,{shop_request_id=>6},["shop_request_id","request_status","shop_host"]);
+    is($shop_request_id, 6, "push(6) made it to the table");
+    is($request_status, "N", "push(6) is N");
+    #is($shop_host, $App::options{host}, "push(6) is $App::options{host}");
+    &test_status_counts($q, 6, 0, 0, 0);
+    &test_resource_buffer_counts($q, "TRV:trv", 1, 4);
+
+    $q->release($entry);
+    ($shop_request_id,$request_status,$shop_host)= 
$db->get($table,{shop_request_id=>6},["shop_request_id","request_status","shop_host"]);
+    is($request_status, "S", "release(6) is S");
+    &test_status_counts($q, 5, 0, 0, 1);
+    &test_resource_buffer_counts($q, "TRV:trv", 1, 3);
+
+    $q->release($entry2);
+    ($shop_request_id,$request_status,$shop_host)= 
$db->get($table,{shop_request_id=>7},["shop_request_id","request_status","shop_host"]);
+    is($request_status, "S", "release(7) is S");
+    &test_status_counts($q, 4, 0, 0, 2);
+    &test_resource_buffer_counts($q, "TRV:trv", 1, 2);
+
+    
###############################################################################
+    # End of Test fo release() for unacquired
+    
###############################################################################
+
     # locate()
     my @entries = $q->locate({shop_request_id => 1});
     is($#entries, 0, "locate(): got 1 entry with shop_request_id = 1");
@@ -319,14 +364,14 @@
     is($num_workers_ds{TRV},  1, "Entry 1: num_workers_ds{TRV} = 1");
     #is($num_workers_ads{trv}, 1, "Entry 1: num_workers_ads{TRV} = undef");
     is($state{num_workers},   1, "Entry 1: state{num_workers} = 1");
-    &test_status_counts($q, 3, 0, 1, 0);
+    &test_status_counts($q, 3, 0, 1, 2);
     &test_resource_buffer_counts($q, "TRV:trv", 1, 1);
 
     $max_workers_ds{EXP} = 0;
     $e3 = $q->acquire();
     is($e3, undef, "No entries to acquire (EXP constraint)");
     delete $max_workers_ds{EXP};
-    &test_status_counts($q, 3, 0, 1, 0);
+    &test_status_counts($q, 3, 0, 1, 2);
     &test_resource_buffer_counts($q, "EXP:exp", 1, 2);
 
     $e2 = $q->acquire();
@@ -335,14 +380,14 @@
     is($num_workers_ds{EXP},  1,     "Entry 3: num_workers_ds{EXP} = 1");
     is($num_workers_ads{EXP}, undef, "Entry 3: num_workers_ads{EXP} = undef");
     is($state{num_workers},   2,     "Entry 3: state{num_workers} = 2");
-    &test_status_counts($q, 2, 0, 2, 0);
+    &test_status_counts($q, 2, 0, 2, 2);
     &test_resource_buffer_counts($q, "EXP:exp", 1, 1);
 
     $q->release($e1);
     is($num_workers_ds{TRV},  0,     "Release 1: num_workers_ds{TRV} = 0");
     is($e1->[$colidx{request_status}], "S", "Entry 1 released: request_status 
= S");
     is($state{num_workers},   1,     "Release 1: state{num_workers} = 1");
-    &test_status_counts($q, 2, 0, 1, 1);
+    &test_status_counts($q, 2, 0, 1, 3);
     &test_resource_buffer_counts($q, "TRV:trv", 1, 1);
 
     {
@@ -378,12 +423,12 @@
     is($num_workers_ds{TRV},  1,     "Entry 2: num_workers_ds{TRV} = 1");
     is($num_workers_ads{TRV}, undef, "Entry 2: num_workers_ads{TRV} = undef");
     is($state{num_workers},   2,     "Entry 2: state{num_workers} = 2");
-    &test_status_counts($q, 1, 0, 2, 1);
+    &test_status_counts($q, 1, 0, 2, 3);
     &test_resource_buffer_counts($q, "TRV:trv", 0, 0);
 
     $e3 = $q->acquire();
     is($e3, undef, "No entries to acquire (global constraint)");
-    &test_status_counts($q, 1, 0, 2, 1);
+    &test_status_counts($q, 1, 0, 2, 3);
     &test_resource_buffer_counts($q, "TRV:trv", 0, 0);
     &test_resource_buffer_counts($q, "EXP:exp", 1, 1);
 
@@ -397,7 +442,7 @@
 
     is($num_workers_ds{EXP},  1,     "Entry 3: num_workers_ds{EXP} = 1 
(still)");
     $q->unacquire($e2);
-    &test_status_counts($q, 2, 0, 1, 1);
+    &test_status_counts($q, 2, 0, 1, 3);
     &test_resource_buffer_counts($q, "EXP:exp", 2, 2);
 
     is($num_workers_ds{EXP},  0,     "Entry 3 unacquired: num_workers_ds{EXP} 
= 0");
@@ -408,7 +453,7 @@
         "W", "spadkins", "MV", "MV", 90, 0, undef, "[EMAIL PROTECTED]", 
"ShopReport", 90, "default",
         0, 0, "pompeii", 4, 1800, "vhh", undef, 0, undef, 
"compare.detail.html", "None", undef, 2, ]);
     is($q->{data}[0][0], 5, "Entry 5 sorted to top: high priority");
-    &test_status_counts($q, 3, 0, 1, 1);
+    &test_status_counts($q, 3, 0, 1, 3);
     &test_resource_buffer_counts($q, "WEB:vhh", 1, 1);
 
     #my $rows = $db->get_rows($table, {}, $columns, {order_by => 
["shop_request_id"]});
@@ -422,22 +467,22 @@
     is($num_workers_ds{WEB},  1,     "Entry 5: num_workers_ds{WEB} = 1");
     is($num_workers_ads{vhh}, 1,     "Entry 5: num_workers_ads{vhh} = 1");
     is($state{num_workers},   2,     "Entry 5: state{num_workers} = 2");
-    &test_status_counts($q, 2, 0, 2, 1);
+    &test_status_counts($q, 2, 0, 2, 3);
     &test_resource_buffer_counts($q, "WEB:vhh", 0, 0);
 
     $q->release($e4);
     is($num_workers_ds{WEB},  0,     "Entry 5: num_workers_ds{WEB} = 0");
     is($num_workers_ads{vhh}, 0,     "Entry 5: num_workers_ads{vhh} = 0");
     is($state{num_workers},   1,     "Entry 5: state{num_workers} = 1");
-    &test_status_counts($q, 2, 0, 1, 2);
+    &test_status_counts($q, 2, 0, 1, 4);
     &test_resource_buffer_counts($q, "WEB:vhh", 0, 0);
 
     $e4 = $q->acquire();
-    &test_status_counts($q, 1, 0, 2, 2);
+    &test_status_counts($q, 1, 0, 2, 4);
     &test_resource_buffer_counts($q, "TRV:trv", 0, 0);
 
     $q->release($e4);
-    &test_status_counts($q, 1, 0, 1, 3);
+    &test_status_counts($q, 1, 0, 1, 5);
     &test_resource_buffer_counts($q, "TRV:trv", 0, 0);
 }
 

Reply via email to