11 |
use Getopt::Long; |
use Getopt::Long; |
12 |
use IO::Socket::INET; |
use IO::Socket::INET; |
13 |
use Storable qw/freeze thaw/; |
use Storable qw/freeze thaw/; |
14 |
|
use Digest::MD5 qw/md5/; |
15 |
|
|
16 |
|
|
17 |
my $debug = 0; |
my $debug = 0; |
67 |
limit => $limit, |
limit => $limit, |
68 |
); |
); |
69 |
|
|
70 |
|
our $num_records = $input->size; |
71 |
|
|
72 |
sub report { |
sub report { |
73 |
my $description = shift; |
my $description = shift; |
130 |
sub send_sock { |
sub send_sock { |
131 |
my ( $sock, $data ) = @_; |
my ( $sock, $data ) = @_; |
132 |
my $size = length $data; |
my $size = length $data; |
133 |
warn ">>>> $listen ", $sock->peerhost, " $size bytes"; |
warn ">>>> $listen ", $sock->peerhost, " $size bytes\n"; |
134 |
print $sock "$size\n$data" || warn "can't send $size bytes to ", $sock->peerhost; |
print $sock "$size\n$data" || warn "can't send $size bytes to ", $sock->peerhost; |
135 |
} |
} |
136 |
|
|
256 |
|
|
257 |
while (1) { |
while (1) { |
258 |
|
|
259 |
warn "NODE $listen ready - wating for connection\n"; |
warn "NODE $listen ready - path: $path offset: $offset limit: $limit #recs: $num_records\n"; |
260 |
|
|
261 |
my $client = $sock->accept(); |
my $client = $sock->accept(); |
262 |
|
|
274 |
run_code $header[1] => $content; |
run_code $header[1] => $content; |
275 |
send_sock $client => freeze $out; |
send_sock $client => freeze $out; |
276 |
} elsif ( $header[0] eq 'info' ) { |
} elsif ( $header[0] eq 'info' ) { |
277 |
my $info = "$listen\t$offset\t$limit\t$path"; |
my $info = "$listen\t$offset\t$limit\t$num_records\t$path"; |
278 |
$info .= "\t" . eval $header[1] if $header[1]; |
$info .= "\t" . eval $header[1] if $header[1]; |
279 |
warn "info $info\n"; |
warn "info $info\n"; |
280 |
send_sock $client => $info; |
send_sock $client => $info; |
313 |
send_nodes 'info' => $2; |
send_nodes 'info' => $2; |
314 |
|
|
315 |
my @info = ( |
my @info = ( |
316 |
"node\toffset\tlimit\tpath", |
"node\toffset\tlimit\t#recs\tpath", |
317 |
"----\t------\t-----\t----", |
"----\t------\t-----\t-----\t----", |
318 |
"0\t$offset\t$limit\t$path", |
"0\t$offset\t$limit\t$num_records\t$path", |
319 |
); |
); |
320 |
|
|
321 |
push @info, get_node $_ foreach @nodes; |
push @info, get_node $_ foreach @nodes; |