view release on metacpan or search on metacpan
lib/AC/MrGamoo/Client.pm view on Meta::CPAN
@serverlist = @$list if $list && @$list;
};
last if @serverlist;
}
# sort+filter list
@serverlist = sort { ($a->{sort_metric} <=> $b->{sort_metric}) || int(rand(3)) - 1 }
grep { $_->{status} == 200 } @serverlist;
# try all addresses
# RSN - sort addresslist in a Peers::pick_best_addr_for_peer() like manner?
my @addrlist = map { @{$_->{ip}} } @serverlist;
for my $ip (@addrlist){
my $addr = inet_itoa($ip->{ipv4});
my $res;
eval {
alarm(30);
$res = $me->_submit_to( $addr, $ip->{port}, $req );
alarm(0);
lib/AC/MrGamoo/Job/Plan.pm view on Meta::CPAN
my $servers = shift;
my %filemap;
my %bytes;
my @copies;
my $load = _plan_map_these_servers( $job, $servers );
# divy files up among servers
for my $f (sort { $b->{size} <=> $a->{size} } @$files){
my($best_wgt, $best_loc);
for my $loc ( @{$f->{location}} ){
next unless exists $load->{$loc}; # down?
next unless $load->{$loc}{use};
my $w = (1 + $bytes{$loc}) * (1 + $load->{$loc}{metric});
if( !$best_loc || $w < $best_wgt ){
$best_wgt = $w;
$best_loc = $loc;
}
}
if( $best_loc ){
# a server has the file. process it there.
push @{$filemap{$best_loc}}, $f;
$bytes{$best_loc} += $f->{size};
next;
}
# pick best 2 servers
my($sa, $sb) =
map { $_->[1] }
sort{ $a->[0] <=> $b->[0] }
map { [(1 + $bytes{$_}) * (1 + $load->{$_}{metric}), $_] }
grep { $load->{$_}{use} }
(keys %$load);
# copy the file
my @loc = $sa;
push @loc, $sb if $sb;
lib/AC/MrGamoo/Kibitz/Peers.pm view on Meta::CPAN
use AC::MrGamoo::Debug 'kibitz_peers';
use AC::MrGamoo::About;
use AC::MrGamoo::MySelf;
use AC::MrGamoo::Config;
use AC::DC::Sched;
use AC::Misc;
use AC::Import;
use JSON;
use strict;
our @EXPORT = qw(pick_best_addr_for_peer peer_list_all get_peer_by_id);
my $KEEPDOWN = 300; # keep data about down servers for how long?
my $KEEPLOST = 600; # keep data about servers we have not heard about for how long?
my %SCEPTICAL;
my %ALLPEER;
my %MAYBEDOWN;
my $natdom;
my $natinit;
lib/AC/MrGamoo/Kibitz/Peers.pm view on Meta::CPAN
my $d = $ALLPEER{$id};
if( ($^T - $d->{lastup} > $KEEPDOWN) || ($^T - $d->{timestamp} > $KEEPLOST) ){
_remove($id);
}
}
################################################################
# pick best ip addr from array (ACPIPPort)
sub pick_best_addr_for_peer {
my $ipinfo = shift;
_nat_init() unless $natinit;
my $public;
my $private;
for my $i ( @$ipinfo ){
$public = $i unless $i->{natdom};
$private = $i if $i->{natdom} eq $natdom;
lib/AC/MrGamoo/Kibitz/Peers.pm view on Meta::CPAN
# known peer
unless(@peer){
@peer = values %ALLPEER;
# sometimes, randomly, use the seed peers
@peer = () unless int rand(@peer+1);
}
if( @peer ){
my $p = $peer[ rand(@peer) ];
debug("using peer $p->{server_id}");
return ($p->{server_id}, pick_best_addr_for_peer($p->{ip}));
}
# seed peer
my $seed = conf_value('seedpeer');
my $p = $seed->[ rand(@$seed) ];
my ($ip, $port) = split /:/, $p;
$port ||= my_port();
# don't talk to self. any of my addrs.
my $ipinfo = my_network_info();
lib/AC/MrGamoo/PeerList.pm view on Meta::CPAN
metric => $_->{sort_metric},
}
} grep { $_->{status} == 200 } @$s ];
}
sub get_peer_addr_from_id {
my $id = shift;
my $s = get_peer_by_id($id);
return unless $id;
return pick_best_addr_for_peer( $s->{ip} );
}
sub get_peer_status_from_id {
my $id = shift;
my $s = get_peer_by_id($id);
return unless $id;
return $s->{status};
}
lib/AC/protobuf/heartbeat.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'server_id', 10, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_INT32(),
'process_id', 11, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
}
1;
lib/AC/protobuf/mrgamoo.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'jobid', 1, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'taskid', 2, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMJobAbort->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMJobAbort',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'jobid', 1, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMFileDel->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMFileDel',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'filename', 1, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMDiagMsg->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMDiagMsg',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
lib/AC/protobuf/mrgamoo.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'msg', 3, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'server_id', 4, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMFileXfer->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMFileXfer',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
lib/AC/protobuf/mrgamoo.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'master', 6, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'console', 7, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMXferStatus->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMXferStatus',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
lib/AC/protobuf/mrgamoo.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_INT32(),
'status_code', 3, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'status_message', 4, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMTaskCreate->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMTaskCreate',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
lib/AC/protobuf/mrgamoo.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'master', 9, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'console', 10, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMJobCreate->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMJobCreate',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
lib/AC/protobuf/mrgamoo.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'console', 5, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'traceinfo', 6, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMTaskStatus->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMTaskStatus',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
lib/AC/protobuf/mrgamoo.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'phase', 3, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_FLOAT(),
'progress', 4, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
}
1;
lib/AC/protobuf/mrgamoo_status.pl view on Meta::CPAN
Google::ProtocolBuffers->create_message(
'ACPMRMStatusReply',
[
[
Google::ProtocolBuffers::Constants::LABEL_REPEATED(),
'ACPMRMStatus',
'status', 1, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMStatusRequest->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMStatusRequest',
[
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
'ACPMRMStatus',
'myself', 1, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPMRMStatus->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPMRMStatus',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
lib/AC/protobuf/mrgamoo_status.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'server_id', 13, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'path', 15, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPIPPort->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPIPPort',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_FIXED32(),
lib/AC/protobuf/mrgamoo_status.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_INT32(),
'port', 2, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'natdom', 3, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
}
1;
lib/AC/protobuf/scrible.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'filename', 1, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'hash_sha1', 2, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
unless (ACPScriblReply->can('_pb_fields_list')) {
Google::ProtocolBuffers->create_message(
'ACPScriblReply',
[
[
Google::ProtocolBuffers::Constants::LABEL_REQUIRED(),
Google::ProtocolBuffers::Constants::TYPE_INT32(),
lib/AC/protobuf/scrible.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'status_message', 2, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'hash_sha1', 3, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
}
1;
lib/AC/protobuf/std_ipport.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_INT32(),
'port', 2, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'natdom', 3, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
}
1;
lib/AC/protobuf/std_reply.pl view on Meta::CPAN
Google::ProtocolBuffers::Constants::TYPE_INT32(),
'status_code', 1, undef
],
[
Google::ProtocolBuffers::Constants::LABEL_OPTIONAL(),
Google::ProtocolBuffers::Constants::TYPE_STRING(),
'status_message', 2, undef
],
],
{ 'create_accessors' => 1, 'follow_best_practice' => 1, }
);
}
}
1;