Upgrading dependency to Thrift 0.12.0

This commit is contained in:
Renan DelValle 2018-11-27 18:03:50 -08:00
parent 3e4590dcc0
commit 356978cb42
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
1302 changed files with 101701 additions and 26784 deletions

View file

@ -19,13 +19,15 @@
# under the License.
#
require 5.6.0;
use 5.10.0;
use strict;
use warnings;
use Data::Dumper;
use Getopt::Long qw(GetOptions);
use Time::HiRes qw(gettimeofday);
$SIG{INT} = \&sigint_handler;
use lib '../../lib/perl/lib';
use lib 'gen-perl';
@ -33,11 +35,13 @@ use Thrift;
use Thrift::BinaryProtocol;
use Thrift::BufferedTransport;
use Thrift::FramedTransport;
use Thrift::MultiplexedProcessor;
use Thrift::SSLServerSocket;
use Thrift::ServerSocket;
use Thrift::Server;
use Thrift::UnixServerSocket;
use ThriftTest::SecondService;
use ThriftTest::ThriftTest;
use ThriftTest::Types;
@ -50,7 +54,8 @@ Usage: $0 [OPTIONS]
Options: (default)
--ca Certificate authority file (optional).
--cert Certificate file.
Required if using --ssl.
Required if using --ssl.
--ciphers Acceptable cipher list.
--domain-socket <file> Use a unix domain socket.
--help Show usage.
--key Private key file for certificate.
@ -60,7 +65,7 @@ Options: (default)
--protocol {binary} binary Protocol to use.
--ssl If present, use SSL/TLS.
--transport {buffered|framed} buffered Transport to use.
EOF
}
@ -73,6 +78,7 @@ my %opts = (
GetOptions(\%opts, qw (
ca=s
cert=s
ciphers=s
domain-socket=s
help
host=s
@ -94,7 +100,9 @@ if ($opts{ssl} and not defined $opts{cert}) {
}
my $handler = new ThriftTestHandler();
my $handler2 = new SecondServiceHandler();
my $processor = new ThriftTest::ThriftTestProcessor($handler);
my $processor2 = new ThriftTest::SecondServiceProcessor($handler2);
my $serversocket;
if ($opts{"domain-socket"}) {
unlink($opts{"domain-socket"});
@ -114,13 +122,21 @@ if ($opts{transport} eq 'buffered') {
exit 1;
}
my $protocol;
if ($opts{protocol} eq 'binary') {
if ($opts{protocol} eq 'binary' || $opts{protocol} eq 'multi') {
$protocol = new Thrift::BinaryProtocolFactory();
} else {
usage();
exit 1;
}
if (index($opts{protocol}, 'multi') == 0) {
my $newProcessor = new Thrift::MultiplexedProcessor($protocol);
$newProcessor->defaultProcessor($processor);
$newProcessor->registerProcessor("ThriftTest", $processor);
$newProcessor->registerProcessor("SecondService", $processor2);
$processor = $newProcessor;
}
my $ssltag = '';
if ($opts{ssl}) {
$ssltag = "(SSL)";
@ -132,8 +148,14 @@ if ($opts{"domain-socket"}) {
my $server = new Thrift::SimpleServer($processor, $serversocket, $transport, $protocol);
print "Starting \"simple\" server ($opts{transport}/$opts{protocol}) listen on: $listening_on\n";
$server->serve();
print "done.\n";
###
sub sigint_handler {
print "received SIGINT, stopping...\n";
$server->stop();
}
###
### Test server implementation
###
@ -148,7 +170,7 @@ sub new {
}
sub testVoid() {
print("testVoid()\n");
print("testVoid()\n");
}
sub testString() {
@ -280,7 +302,7 @@ sub testSet() {
print(", ");
}
print("$key");
push($result, $key);
push(@arr, $key);
}
print("})\n");
return $result;
@ -320,7 +342,7 @@ sub testTypedef() {
sub testMapMap() {
my $self = shift;
my $hello = shift;
printf("testMapMap(%d)\n", $hello);
my $result = { 4 => { 1 => 1, 2 => 2, 3 => 3, 4 => 4 }, -4 => { -1 => -1, -2 => -2, -3 => -3, -4 => -4 } };
return $result;
@ -352,7 +374,7 @@ sub testMulti() {
my $arg3 = shift;
my $arg4 = shift;
my $arg5 = shift;
print("testMulti()\n");
return new ThriftTest::Xtruct({string_thing => "Hello2", byte_thing => $arg0, i32_thing => $arg1, i64_thing => $arg2});
}
@ -388,11 +410,29 @@ sub testMultiException() {
sub testOneway() {
my $self = shift;
my $sleepFor = shift;
print("testOneway($sleepFor): Sleeping...\n");
sleep $sleepFor;
print("testOneway($sleepFor): done sleeping!\n");
my $num = shift;
print("testOneway($num): received\n");
}
###
### Test server implementation
###
package SecondServiceHandler;
use base qw( ThriftTest::SecondServiceIf );
sub new {
my $classname = shift;
my $self = {};
return bless($self, $classname);
}
sub secondtestString() {
my $self = shift;
my $thing = shift;
print("testString($thing)\n");
return "testString(\"" . $thing . "\")";
}
1;