1 |
#!/usr/bin/perl |
2 |
|
3 |
use warnings; |
4 |
use strict; |
5 |
|
6 |
use Data::Dump qw(dump); |
7 |
use File::Slurp; |
8 |
|
9 |
use lib 'lib'; |
10 |
use Sack::From; |
11 |
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'; |
20 |
my $limit = 0; |
21 |
my $cloud; |
22 |
|
23 |
my $install = 0; |
24 |
|
25 |
|
26 |
GetOptions( |
27 |
'view=s' => \$view, |
28 |
'limit=i' => \$limit, |
29 |
'cloud=s' => \$cloud, |
30 |
|
31 |
'install+' => \$install, |
32 |
) or die $!; |
33 |
|
34 |
|
35 |
my $lorry = Sack::Lorry->new( view => $view, cloud => $cloud ); |
36 |
|
37 |
my $from = Sack::From->new( |
38 |
path => '/data/isi/full.txt', |
39 |
limit => $limit * $lorry->cloud_size, |
40 |
); |
41 |
|
42 |
duration 'pre-load finished'; |
43 |
|
44 |
$lorry->start_nodes; |
45 |
|
46 |
duration 'cloud up'; |
47 |
|
48 |
if ( $install ) { |
49 |
$lorry->update_node( $_ ) foreach $lorry->connected; |
50 |
duration 'install finished'; |
51 |
} |
52 |
|
53 |
$lorry->load_nodes( $from ); |
54 |
|
55 |
duration 'load finished'; |
56 |
|
57 |
|
58 |
our $out; |
59 |
our $cmd; |
60 |
|
61 |
do { |
62 |
print "sack> "; |
63 |
$cmd = <STDIN>; |
64 |
last unless defined $cmd; # CTRL+D |
65 |
chomp($cmd); |
66 |
} while $lorry->command($cmd); |
67 |
|
68 |
warn "exit all nodes\n"; |
69 |
$lorry->send_to_all( { exit => 1 } ); |
70 |
|
71 |
duration 'total usage'; |
72 |
|