/[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

Contents of /trunk/bin/lorry.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 107 - (show annotations)
Mon Oct 5 22:21:39 2009 UTC (14 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 1489 byte(s)
move ping to Sack::Lorry, display duration of operations and
implement new configuration in etc

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 Getopt::Long;
14 use Time::HiRes qw(time);
15
16
17 my $view = 'views/00.demo.pl';
18 my $offset = 0;
19 my $limit = 5000;
20 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
37
38 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(
44 path => '/data/isi/full.txt',
45 limit => $limit * scalar @cloud,
46 );
47
48 duration 'load finished';
49
50 my $info;
51
52 foreach my $host ( @cloud ) {
53
54 if ( my $port = $lorry->start_node( $host ) ) {
55
56 warn "started [$port] on $host\n";
57
58 my $data = $from->shard( $limit );
59 $lorry->send_to( $port, { data => $data } ) || die "can't send to $port: $!";
60
61 $info->{$port} = {
62 host => $host,
63 offset => $offset,
64 limit => $limit,
65 };
66
67 $offset += $limit;
68
69 }
70 }
71
72 duration 'cloud up';
73
74 warn "info ",dump $info;
75
76 warn "load status ", dump( $lorry->get_from_all );
77
78 while ( $view ) {
79 warn dump( $lorry->view( $view ) );
80 duration 'view';
81 print "sack> ";
82 my $cmd = <STDIN>;
83 last unless defined $cmd; # CTRL+D
84 chomp($cmd);
85 duration 'repl wait';
86 }
87
88 warn "exit all nodes\n";
89 $lorry->send_to_all( { exit => 1 } );
90
91 duration 'total usage';
92

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26