/[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 262 by dpavlin, Sun Jan 31 16:44:56 2010 UTC revision 263 by dpavlin, Sun Jan 31 18:18:38 2010 UTC
# Line 74  foreach my $host ( @cloud ) { Line 74  foreach my $host ( @cloud ) {
74    
75  my $session;  my $session;
76    
77    sub all_ports { keys %{ $session->{port} } }
78    
79  sub to_all {  sub to_all {
80          my $data = shift;          my $data = shift;
81          foreach my $port ( keys %{ $session->{port} } ) {          foreach my $port ( all_ports ) {
82                  warn ">>>> [$port]\n" if $debug;                  warn ">>>> [$port]\n" if $debug;
83                  Storable::store_fd( $data, $session->{port}->{$port} );                  Storable::store_fd( $data, $session->{port}->{$port} );
84          }          }
# Line 106  sub load_shard { Line 108  sub load_shard {
108                  warn "queued $s for loading\n";                  warn "queued $s for loading\n";
109          }          }
110          to_all { load => $shard };          to_all { load => $shard };
111            $info->{pending}->{$_} = 'load' foreach all_ports;
112  }  }
113    
114  sub run_view {  sub run_view {
# Line 119  sub run_view { Line 122  sub run_view {
122          delete( $info->{view} );          delete( $info->{view} );
123          delete( $info->{merge} );          delete( $info->{merge} );
124          delete( $info->{shard} );          delete( $info->{shard} );
125            $info->{pending}->{$_} = 'view' foreach all_ports;
126          to_all { code => $code, view => $path };          to_all { code => $code, view => $path };
127  };  };
128    
# Line 168  while (1) { Line 172  while (1) {
172                                          warn "ERROR: $@" if $@;                                          warn "ERROR: $@" if $@;
173                                  }                                  }
174    
175                                    my $refresh = $param->{refresh};
176                                    $refresh = 1 if keys %{ $info->{pending} };
177    
178                                  print $send "HTTP/1.0 200 OK\r\nContent-Type: text/html"                                  print $send "HTTP/1.0 200 OK\r\nContent-Type: text/html"
179                                          , ( $param->{refresh} ? "\r\nRefresh: " . $param->{refresh} : '' )                                          , ( $refresh ? "\r\nRefresh: $refresh" : '' )
180                                          , "\r\n\r\n"                                          , "\r\n\r\n"
181                                            , ( $refresh ? qq|<span style="color: #888; float:right">$refresh</span>| : '' )
182                                  ;                                  ;
183    
184                                  print $send qq|                                  print $send qq|
# Line 183  while (1) { Line 191  while (1) {
191    
192    
193  .forked {  .forked {
194          color: #f00;  //      text-decoration: line-through;
195  }  }
196    
197  .ping {  .ping {
198            color: #ff0;
199    }
200    
201    .load {
202            color: #f00;
203    }
204    
205    .view {
206            color: #00f;
207    }
208    
209    .ready {
210          color: #0f0;          color: #0f0;
211  }  }
212    
# Line 245  while (1) { Line 265  while (1) {
265                                          print $send qq|<h1>Results</h1><form method="get" target="gnuplot" action="/gnuplot/"><ul>$li</ul><input type=submit value="Show checked"></form><img src="/gnuplot/">\n|;                                          print $send qq|<h1>Results</h1><form method="get" target="gnuplot" action="/gnuplot/"><ul>$li</ul><input type=submit value="Show checked"></form><img src="/gnuplot/">\n|;
266                                  }                                  }
267    
268                                  print $send qq|<h1>Nodes</h1>                                  print $send qq|<h1>Nodes</h1>|;
269                                  |, join("\n", map {                                  foreach my $node ( keys %{ $info->{node} } ) {
270                                          my $class = join(' ', map { $_->[0] } @{ $info->{node}->{$_} });                                          my $class = join(' '
271                                          qq|<tt class="$class">$_</tt>|;                                                  , map { $_->[0] } @{ $info->{node}->{$node} }
272                                  } sort keys %{ $info->{node} } );                                          );
273                                            $class .= ' ' . ( $info->{pending}->{$node} || 'ready' );
274                                            print $send qq|<tt class="$class">$node</tt>\n|;
275                                    }
276    
277                                  print $send qq|<h1>Shards</h1><ul>|;                                  print $send qq|<h1>Shards</h1><ul>|;
278                                  foreach my $path ( glob '/tmp/sack/*' ) {                                  foreach my $path ( glob '/tmp/sack/*' ) {
# Line 328  while (1) { Line 351  while (1) {
351                                                  Storable::store_fd( { path => $path, shard => $shard }, $sock );                                                  Storable::store_fd( { path => $path, shard => $shard }, $sock );
352                                          } else {                                          } else {
353                                                  warn "no more shards for [", $data->{port}, "]\n";                                                  warn "no more shards for [", $data->{port}, "]\n";
354                                                    delete $info->{pending}->{ $data->{port} };
355                                          }                                          }
356                                  } elsif ( exists $data->{out} ) {                                  } elsif ( exists $data->{out} ) {
357                                          my $added = Sack::Merge->add( $data->{out} ) if defined $data->{out};                                          my $added = Sack::Merge->add( $data->{out} ) if defined $data->{out};
# Line 335  while (1) { Line 359  while (1) {
359                                          $info->{view }->{ $data->{view} }->{ $data->{port} } = $data->{on_shard};                                          $info->{view }->{ $data->{view} }->{ $data->{port} } = $data->{on_shard};
360                                          # refresh shard allocation                                          # refresh shard allocation
361                                          $info->{shard}->{ $_ } = $data->{port} foreach keys %{ $data->{on_shard} };                                          $info->{shard}->{ $_ } = $data->{port} foreach keys %{ $data->{on_shard} };
362                                            delete $info->{pending}->{ $data->{port} };
363                                  } elsif ( exists $data->{port} ) {                                  } elsif ( exists $data->{port} ) {
364                                          push @responses, $data;                                          push @responses, $data;
365                                          warn "# ",dump($data),$/;                                          warn "# ",dump($data),$/;

Legend:
Removed from v.262  
changed lines
  Added in v.263

  ViewVC Help
Powered by ViewVC 1.1.26