Changeset 15917
- Timestamp:
- 07/17/08 13:29:13 (5 years ago)
- Location:
- lang/perl/Mvalve/trunk
- Files:
-
- 3 modified
-
lib/Mvalve/Reader.pm (modified) (4 diffs)
-
lib/Mvalve/Writer.pm (modified) (1 diff)
-
t/05_log.t (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Mvalve/trunk/lib/Mvalve/Reader.pm
r15891 r15917 54 54 } 55 55 56 my $destination = $message->header( &Mvalve::Const::DESTINATION_HEADER ); 57 56 58 if (&Mvalve::Const::MVALVE_TRACE && $table eq 'q_timed') { 57 59 Mvalve::trace( "we should have dispatched at " . … … 62 64 # service name. this /could/ be used by the queue consumer, but it 63 65 # is *not* a 64 my $destination = $message->header( &Mvalve::Const::DESTINATION_HEADER );65 66 66 67 if ( $qs->is_emergency( $table ) || $qs->is_timed( $table ) ) { … … 73 74 $self->try_push( key => $destination ); 74 75 75 return $message; 76 # XXX - This is bad practive, but oh well 77 goto RETURN_MESSAGE; 76 78 } 77 79 … … 90 92 } 91 93 94 RETURN_MESSAGE: 92 95 # if we got here, we can just return the data 93 96 Mvalve::trace( "message", $message->id, "being returned") if &Mvalve::Const::MVALVE_TRACE; 97 $self->log( 98 action => "dequeue", 99 destination => $destination, 100 ); 94 101 return $message; 95 102 } -
lang/perl/Mvalve/trunk/lib/Mvalve/Writer.pm
r15914 r15917 26 26 27 27 $self->log( 28 action => " insert",28 action => "enqueue", 29 29 destination => $data{destination}, 30 30 ); -
lang/perl/Mvalve/trunk/t/05_log.t
r15914 r15917 12 12 } else { 13 13 $messages = $ENV{MVALVE_MESSAGE_COUNT} || 32; 14 plan(tests => 5+ 3 * $messages);14 plan(tests => 6 + 3 * $messages); 15 15 } 16 16 … … 37 37 ); 38 38 39 my $logger = Mvalve::Logger::Stats->new( 40 q4mlog => { 41 connect_info => $q_config{args}->{connect_info} 42 } 43 ); 44 45 { # XXX Hack: remove everything from stats log first 46 $logger->logger->q4m->dbh->do("DELETE FROM q_statslog"); 47 } 48 39 49 my $writer = Mvalve::Writer->new( 40 50 queue => \%q_config, 41 logger => Mvalve::Logger::Stats->new( 42 q4mlog => { 43 connect_info => $q_config{args}->{connect_info} 44 } 45 ) 51 logger => $logger, 46 52 ); 47 53 my $reader = Mvalve::Reader->new( 48 54 timeout => 1, 55 logger => $logger, 49 56 throttler => { 50 57 module => 'Data::Valve', … … 82 89 83 90 { # check the statslog 84 my $queue = Queue::Q4M->new( 85 connect_info => $q_config{args}->{connect_info} 86 ); 87 my $log_count = 0; 88 while ($queue->next('q_statslog')) { 89 $log_count++; 90 last if $log_count == $count; 91 } 91 # XXX - HACK: get the database handle from stats logger 92 my $dbh = $logger->logger->q4m->dbh; 93 my $sth = $dbh->prepare("SELECT COUNT(*) FROM q_statslog WHERE action = ?"); 94 $sth->execute('enqueue'); 95 my ($log_count) = $sth->fetchrow_array(); 96 92 97 is($log_count, $count, "log matches insert count"); 98 $dbh->do("DELETE FROM q_statslog"); 93 99 } 94 100 … … 122 128 is (keys %messages, 0, "consumed all messages"); 123 129 } 130 131 { # check the statslog 132 # XXX - HACK: get the database handle from stats logger 133 my $dbh = $logger->logger->q4m->dbh; 134 my $sth = $dbh->prepare("SELECT COUNT(*) FROM q_statslog WHERE action = ?"); 135 $sth->execute('dequeue'); 136 my ($log_count) = $sth->fetchrow_array(); 137 138 is($log_count, $count + 1, "log matches insert count"); 139 $dbh->do("DELETE FROM q_statslog"); 140 } 124 141 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)