/[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 102 by dpavlin, Mon Oct 5 20:31:28 2009 UTC revision 107 by dpavlin, Mon Oct 5 22:21:39 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;
 use Net::Ping;  
12  use Sack::Color;  use Sack::Color;
13    use Getopt::Long;
14    use Time::HiRes qw(time);
15    
16    
17  my $view   = 'views/00.demo.pl';  my $view   = 'views/00.demo.pl';
18  my $offset = 0;  my $offset = 0;
19  my $limit  = 5000;  my $limit  = 5000;
20  my @cloud  = ( 'localhost', 'localhost' );  my $cloud_file = 'etc/lib';
21    
22    
23    GetOptions(
24            'view=s'  => \$view,
25            'limit=i' => \$limit,
26            'cloud=s' => \$cloud_file,
27    ) or die $!;
28    
29    my $t = time;
30    sub duration {
31            my $now = time;
32            my $d = $now - $t;
33            warn sprintf "%.4fs %s\n", $d, join(' ',@_);
34            $t = $now;
35    }
36    
 push @cloud, ( '192.168.2.200', '192.168.2.200' ) if `hostname` =~ m{t61p};  
37    
38  my $lorry = Sack::Lorry->new;  my $lorry = Sack::Lorry->new;
39    
40    my @cloud = read_file $cloud_file;
41    warn "bring up cloud ",dump @cloud;
42    
43  my $from  = Sack::From->new(  my $from  = Sack::From->new(
44          path => '/data/isi/full.txt',          path => '/data/isi/full.txt',
45          limit => $limit * scalar @cloud,          limit => $limit * scalar @cloud,
46  );  );
47    
48  my $info;  duration 'load finished';
49    
50  my $p = Net::Ping->new;  my $info;
51    
52  foreach my $host ( @cloud ) {  foreach my $host ( @cloud ) {
53    
         if ( ! $p->ping( $host ) ) {  
                 warn "SKIP $host - doesn't respond to ping\n";  
                 next;  
         }  
   
54          if ( my $port = $lorry->start_node( $host ) ) {          if ( my $port = $lorry->start_node( $host ) ) {
55    
56                  warn "started [$port] on $host\n";                  warn "started [$port] on $host\n";
# Line 52  foreach my $host ( @cloud ) { Line 66  foreach my $host ( @cloud ) {
66    
67                  $offset += $limit;                  $offset += $limit;
68    
         } else {  
                 warn "[$port] skipped";  
69          }          }
70  }  }
71    
72    duration 'cloud up';
73    
74  warn "info ",dump $info;  warn "info ",dump $info;
75    
76  warn "load status ", dump( $lorry->get_from_all );  warn "load status ", dump( $lorry->get_from_all );
77    
78  while ( $view ) {  while ( $view ) {
79          warn dump( $lorry->view( $view ) );          warn dump( $lorry->view( $view ) );
80            duration 'view';
81          print "sack> ";          print "sack> ";
82          my $cmd = <STDIN>;          my $cmd = <STDIN>;
83          last unless defined $cmd; # CTRL+D          last unless defined $cmd; # CTRL+D
84          chomp($cmd);          chomp($cmd);
85            duration 'repl wait';
86  }  }
87    
88  warn "exit all nodes\n";  warn "exit all nodes\n";
89  $lorry->send_to_all( { exit => 1 } );  $lorry->send_to_all( { exit => 1 } );
90    
91    duration 'total usage';
92    

Legend:
Removed from v.102  
changed lines
  Added in v.107

  ViewVC Help
Powered by ViewVC 1.1.26