/[Sack]/trunk/bin/lorry.pl
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/bin/lorry.pl

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

revision 95 by dpavlin, Sun Oct 4 12:17:52 2009 UTC revision 150 by dpavlin, Fri Oct 9 17:10:54 2009 UTC
# Line 9  use File::Slurp; Line 9  use File::Slurp;
9  use lib 'lib';  use lib 'lib';
10  use Sack::From;  use Sack::From;
11  use Sack::Lorry;  use Sack::Lorry;
12    use Sack::Color;
13    use Sack;
14    
15    use Getopt::Long;
16    use Time::HiRes qw(time);
17    
18    
19  my $view   = 'views/00.demo.pl';  my $view   = 'views/00.demo.pl';
20  my $offset = 0;  my $limit  = 0;
21  my $limit  = 5;  my $cloud;
22  my @cloud  = ( 'localhost', 'localhost' );  
23    
24    GetOptions(
25            'view=s'  => \$view,
26            'limit=i' => \$limit,
27            'cloud=s' => \$cloud,
28    ) or die $!;
29    
30    
31  my $lorry = Sack::Lorry->new;  my $lorry = Sack::Lorry->new( view => $view, cloud => $cloud );
32    
33  my $from  = Sack::From->new(  my $from  = Sack::From->new(
34          path => '/data/isi/full.txt',          path => '/data/isi/full.txt',
35          limit => $limit * scalar @cloud,          limit => $limit * $lorry->cloud_size,
36  );  );
37    
38  my $info;  duration 'pre-load finished';
39    
40  foreach my $host ( @cloud ) {  $lorry->start_nodes;
         if ( my $port = $lorry->start_node( $host ) ) {  
41    
42                  warn "started [$port] on $host\n";  duration 'cloud up';
43    
44                  my $data = $from->shard( $limit );  $lorry->load_nodes( $from );
                 $lorry->send_to( $port, { data => $data } ) || die "can't send to $port: $!";  
45    
46                  $info->{$port} = {  duration 'load finished';
                         host => $host,  
                         offset => $offset,  
                         limit => $limit,  
                 };  
47    
                 $offset += $limit;  
48    
49          } else {  our $out;
50                  warn "[$port] skipped";  our $cmd;
         }  
 }  
51    
52  warn "info ",dump $info;  do {
53            print "sack> ";
54  warn "load status ", dump( $lorry->get_from_all );          $cmd = <STDIN>;
55            last unless defined $cmd; # CTRL+D
56  warn "run view $view ", -s $view, " bytes\n";          chomp($cmd);
57  my $view_code = read_file($view);  } while $lorry->command($cmd);
 $lorry->send_to_all({ view => $view_code });  
 warn "result ", dump( $lorry->get_from_all );  
58    
59  warn "exit all nodes\n";  warn "exit all nodes\n";
60  $lorry->send_to_all( { exit => 1 } );  $lorry->send_to_all( { exit => 1 } );
61    
62    duration 'total usage';
63    

Legend:
Removed from v.95  
changed lines
  Added in v.150

  ViewVC Help
Powered by ViewVC 1.1.26