/[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 101 - (show annotations)
Mon Oct 5 19:34:45 2009 UTC (14 years, 8 months ago) by dpavlin
File MIME type: text/plain
File size: 1271 byte(s)
test nodes with Net::Ping
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 Net::Ping;
13
14 my $view = 'views/00.demo.pl';
15 my $offset = 0;
16 my $limit = 5000;
17 my @cloud = ( 'localhost', 'localhost' );
18
19 push @cloud, ( '192.168.2.200', '192.168.2.200' ) if `hostname` =~ m{t61p};
20
21 my $lorry = Sack::Lorry->new;
22
23 my $from = Sack::From->new(
24 path => '/data/isi/full.txt',
25 limit => $limit * scalar @cloud,
26 );
27
28 my $info;
29
30 my $p = Net::Ping->new;
31
32 foreach my $host ( @cloud ) {
33
34 if ( ! $p->ping( $host ) ) {
35 warn "SKIP $host - doesn't respond to ping\n";
36 next;
37 }
38
39 if ( my $port = $lorry->start_node( $host ) ) {
40
41 warn "started [$port] on $host\n";
42
43 my $data = $from->shard( $limit );
44 $lorry->send_to( $port, { data => $data } ) || die "can't send to $port: $!";
45
46 $info->{$port} = {
47 host => $host,
48 offset => $offset,
49 limit => $limit,
50 };
51
52 $offset += $limit;
53
54 } else {
55 warn "[$port] skipped";
56 }
57 }
58
59 warn "info ",dump $info;
60
61 warn "load status ", dump( $lorry->get_from_all );
62
63 while ( $view ) {
64 warn dump( $lorry->view( $view ) );
65 print "sack> ";
66 my $cmd = <STDIN>;
67 last unless defined $cmd; # CTRL+D
68 chomp($cmd);
69 }
70
71 warn "exit all nodes\n";
72 $lorry->send_to_all( { exit => 1 } );
73

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26