/[Sack]/trunk/lib/Sack/Server.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Sack/Server.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 232 by dpavlin, Mon Nov 23 23:15:31 2009 UTC revision 237 by dpavlin, Tue Nov 24 00:55:29 2009 UTC
# Line 110  sub run_view { Line 110  sub run_view {
110          my $code = read_file $path;          my $code = read_file $path;
111          Sack::Merge->clean;          Sack::Merge->clean;
112          delete( $info->{view} );          delete( $info->{view} );
113            delete( $info->{merge} );
114          to_all { code => $code, view => $path };          to_all { code => $code, view => $path };
115  };  };
116    
# Line 185  while (1) { Line 186  while (1) {
186                                                  if ( my $s = $info->{view}->{$view} ) {                                                  if ( my $s = $info->{view}->{$view} ) {
187                                                          my @nodes = sort keys %$s;                                                          my @nodes = sort keys %$s;
188                                                          my $total = 0;                                                          my $total = 0;
189                                                          $html .= qq|<table><tr><th>node</th><th>rows</th><th>shards</th><th>&sum;</th></tr>|;                                                          $html .= qq|<table><tr><th>node</th><th>rows</th><th>shards</th><th>&sum;</th><th>merge</th></tr>|;
190                                                          foreach my $node ( @nodes ) {                                                          foreach my $node ( @nodes ) {
191                                                                  my $h = '';                                                                  my $h = '';
192                                                                  my $shard = 0;                                                                  my $shard = 0;
193                                                                  foreach my $path ( sort keys %{ $s->{$node} } ) {                                                                  foreach my $path ( sort keys %{ $s->{$node} } ) {
194                                                                          my $affected = $s->{$node}->{$path};                                                                          my $affected = $s->{$node}->{$path};
195                                                                          $h .= qq|<span title="$affected $path">*</span>|;                                                                          my $n = '?';
196                                                                            $n = $1 if $path =~ m{/(\w)\w+/\d+};
197                                                                            my $class = $affected == 0 ? 'style="color: #888"' : '';
198                                                                            $h .= qq|<tt title="$affected $path"$class>$n</tt>|;
199                                                                          $shard += $affected;                                                                          $shard += $affected;
200                                                                          $total += $affected;                                                                          $total += $affected;
201                                                                  }                                                                  }
202                                                                  $html .= qq|<tr><td><tt>$node</tt></td><td>$shard</td><td>$h</td><td>$total</td></tr>\n|;                                                                  my $merge = $info->{merge}->{$view}->{$node};
203                                                                    $html .= qq|<tr><td><tt>$node</tt></td><td>$shard</td><td>$h</td><td>$total</td><td>$merge</td></tr>\n|;
204                                                          }                                                          }
205    
206                                                          $html .= qq|</table>|;                                                          $html .= qq|</table>|;
# Line 228  while (1) { Line 233  while (1) {
233                                  }                                  }
234                                  print $send qq|</ul>|;                                  print $send qq|</ul>|;
235    
236                                  print $send '<pre>', dump($info), '</pre>' if $param->{debug};                                  if ( $param->{info} ) {
237                                            print $send qq|<a href="?info=0">hide info</a>|;
238                                            print $send '<pre>', dump($info), '</pre>'
239                                    } else {
240                                            print $send qq|<a href="?info=1">show info</a>|;
241                                    }
242                                  return 1;                                  return 1;
243                          } );                          } );
244                  } else {                  } else {
# Line 288  while (1) { Line 297  while (1) {
297                                          } else {                                          } else {
298                                                  warn "no more shards for [", $data->{port}, "]\n";                                                  warn "no more shards for [", $data->{port}, "]\n";
299                                          }                                          }
300                                  } elsif ( defined $data->{out} ) {                                  } elsif ( exists $data->{out} ) {
301                                          Sack::Merge->add( $data->{out} );                                          my $added = Sack::Merge->add( $data->{out} ) if defined $data->{out};
302                                          $info->{view}->{ $data->{view} }->{ $data->{port} } = $data->{on_shard};                                          $info->{merge}->{ $data->{view} }->{ $data->{port} } = $added;
303                                            $info->{view }->{ $data->{view} }->{ $data->{port} } = $data->{on_shard};
304                                  } else {                                  } else {
305                                          warn "UNKNOWN ",dump($data);                                          warn "UNKNOWN ",dump($data);
306                                  }                                  }

Legend:
Removed from v.232  
changed lines
  Added in v.237

  ViewVC Help
Powered by ViewVC 1.1.26