--- trunk/bin/lorry.pl 2009/10/05 22:38:58 108 +++ trunk/bin/lorry.pl 2009/10/09 17:10:54 150 @@ -10,80 +10,51 @@ use Sack::From; use Sack::Lorry; use Sack::Color; +use Sack; + use Getopt::Long; use Time::HiRes qw(time); my $view = 'views/00.demo.pl'; -my $offset = 0; -my $limit = 5000; -my $cloud_file; +my $limit = 0; +my $cloud; GetOptions( 'view=s' => \$view, 'limit=i' => \$limit, - 'cloud=s' => \$cloud_file, + 'cloud=s' => \$cloud, ) or die $!; -my $t = time; -sub duration { - my $now = time; - my $d = $now - $t; - warn sprintf "%.4fs %s\n", $d, join(' ',@_); - $t = $now; -} - - -my $lorry = Sack::Lorry->new; -my @cloud = -e $cloud_file ? read_file $cloud_file : ( 'localhost' ); -warn "bring up cloud ",dump @cloud; +my $lorry = Sack::Lorry->new( view => $view, cloud => $cloud ); my $from = Sack::From->new( path => '/data/isi/full.txt', - limit => $limit * scalar @cloud, + limit => $limit * $lorry->cloud_size, ); -duration 'load finished'; - -my $info; - -foreach my $host ( @cloud ) { +duration 'pre-load finished'; - if ( my $port = $lorry->start_node( $host ) ) { +$lorry->start_nodes; - warn "started [$port] on $host\n"; - - my $data = $from->shard( $limit ); - $lorry->send_to( $port, { data => $data } ) || die "can't send to $port: $!"; - - $info->{$port} = { - host => $host, - offset => $offset, - limit => $limit, - }; - - $offset += $limit; +duration 'cloud up'; - } -} +$lorry->load_nodes( $from ); -duration 'cloud up'; +duration 'load finished'; -warn "info ",dump $info; -warn "load status ", dump( $lorry->get_from_all ); +our $out; +our $cmd; -while ( $view ) { - warn dump( $lorry->view( $view ) ); - duration 'view'; +do { print "sack> "; - my $cmd = ; + $cmd = ; last unless defined $cmd; # CTRL+D chomp($cmd); - duration 'repl wait'; -} +} while $lorry->command($cmd); warn "exit all nodes\n"; $lorry->send_to_all( { exit => 1 } );