|
From: Jonathan L. <le...@us...> - 2007-01-02 21:41:37
|
Update of /cvsroot/pyxida/Pyxida/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25332/bin Modified Files: query.pl Log Message: stuck with passing arguments via XML/RPC Index: query.pl =================================================================== RCS file: /cvsroot/pyxida/Pyxida/bin/query.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** query.pl 31 Dec 2006 14:54:51 -0000 1.9 --- query.pl 2 Jan 2007 21:41:34 -0000 1.10 *************** *** 6,15 **** use Data::Dumper; ! my $DEFAULT_PYXIDA_PORT=55504; ! my $DEFAULT_PYXIDA_API_PORT=55501; my $USE_HEIGHT = 1; my $usage = "query.pl [options] url\n"; $usage .= " -l: get local coordinate of node running at url\n"; $usage .= " -r remote-node: get remote overlay node coordinate\n"; $usage .= " -p proxy-node: get proxy coord that is stored on contacted node\n"; --- 6,16 ---- use Data::Dumper; ! my $PORT=55500; ! my $API_PORT=55501; my $USE_HEIGHT = 1; my $usage = "query.pl [options] url\n"; $usage .= " -l: get local coordinate of node running at url\n"; + $usage .= " -s subset.dat: file containing list of remote nodes, one per line\n"; $usage .= " -r remote-node: get remote overlay node coordinate\n"; $usage .= " -p proxy-node: get proxy coord that is stored on contacted node\n"; *************** *** 21,25 **** $usage .= "Default port numbers can be overridden with \":port\" syntax\n"; my %para = (); ! getopts('lr:a:b:', \%para); ############################################################ --- 22,26 ---- $usage .= "Default port numbers can be overridden with \":port\" syntax\n"; my %para = (); ! getopts('lr:a:b:s:', \%para); ############################################################ *************** *** 30,35 **** my $url = $ARGV[0]; if ($url =~ /^http:\/\/[\w+\.]+$/) { ! $url .= ":$DEFAULT_PYXIDA_API_PORT/xmlrpc" } --- 31,40 ---- my $url = $ARGV[0]; + if ($url !~ /^http:\/\//) { + $url = 'http://'.$url; + } + if ($url =~ /^http:\/\/[\w+\.]+$/) { ! $url .= ":$API_PORT/xmlrpc" } *************** *** 39,43 **** ############################################################ ! warn "url $url\n"; my $server = Frontier::Client->new(url=>"$url"); --- 44,48 ---- ############################################################ ! #warn "url $url\n"; my $server = Frontier::Client->new(url=>"$url"); *************** *** 50,65 **** my $coord = &parse_coord ($coordArray); print "$coord\n"; } elsif (defined($para{'r'})) { ! my $remoteNode = &addPort ($para{'r'}); ! my $coordArray = $server->call("pyxida.getRemoteCoord", $remoteNode); ! print Dumper($coordArray); ! #my $coord = &parse_coord ($coordArray); ! #print "$coord\n"; } elsif (defined($para{'a'}) && defined($para{'b'})) { ! my $nodeA = &addPort($para{'a'}); ! my $nodeB = &addPort($para{'b'}); my $distance = $server->call("pyxida.estimateRTT", $nodeA, $nodeB); ! $distance = sprintf ("%.3f", $distance); ! print "$distance\n"; } else { die ("Missing arguments\n$usage"); --- 55,95 ---- my $coord = &parse_coord ($coordArray); print "$coord\n"; + } elsif (defined($para{'s'})) { + my %remoteNodes = (); + open IN, "$para{'s'}" or die ("Cannot open file $para{'s'}\n"); + while (my $line = <IN>) { + $line =~ s/\s//g; + next if ($line =~ /\#/); + if ($line =~ /\w+/) { + $remoteNodes{$line} = 1; + } + } + close IN; + my $node2coord = $server->call("pyxida.getRemoteCoords", %remoteNodes); + print Dumper($node2coord); } elsif (defined($para{'r'})) { ! my $remoteNode = &addPort ($para{'r'},$PORT); ! my $resHash = $server->call("pyxida.getRemoteCoord", $remoteNode); ! if (defined($resHash->{'result'})) { ! if (($resHash->{'result'} eq 'Success') && ! (defined($resHash->{'coord'}))) { ! my $coord = &parse_coord ($resHash->{'coord'}); ! print "$coord\n"; ! } else { ! print "Failure: $resHash->{'result'}\n"; ! } ! } else { ! print "Failure: cause unknown\n"; ! } } elsif (defined($para{'a'}) && defined($para{'b'})) { ! my $nodeA = &addPort($para{'a'},$PORT); ! my $nodeB = &addPort($para{'b'},$PORT); ! my $distance = $server->call("pyxida.estimateRTT", $nodeA, $nodeB); ! #print Dumper($distance); ! if (defined($distance)) { ! $distance = sprintf ("%.3f", $distance); ! print "$distance\n"; ! } } else { die ("Missing arguments\n$usage"); *************** *** 84,90 **** sub addPort { ! my ($host) = @_; if ($host !~ /[\w]+:\d+/) { ! $host .= ":$DEFAULT_PYXIDA_PORT"; } return $host; --- 114,120 ---- sub addPort { ! my ($host,$port) = @_; if ($host !~ /[\w]+:\d+/) { ! $host .= ":$port"; } return $host; |