Changeset 27532

Show
Ignore:
Timestamp:
04.06.2013 11:12:36 (6 years ago)
Author:
jmt12
Message:

Add the ability to configure the Thrift connector using a 'thrift.conf' file in the collections etc folder

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/parallel-building/trunk/src/perllib/FileUtils/HDThriftFS.pm

    r27525 r27532  
    4545  die "GEXTPARALLELBUILDING not set\n" unless defined $ENV{'GEXTPARALLELBUILDING'}; 
    4646  die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'}; 
     47  die "GSDLCOLLECTDIR not set\n" unless defined $ENV{'GSDLCOLLECTDIR'}; 
    4748  # We need the Perl version before continuing 
    4849  if (!defined $ENV{'PERL_VERSION'}) 
     
    7273 
    7374# Configuration 
    74 my $host = "medusa.local"; 
     75my $host = "localhost"; 
    7576my $port = 58660; 
    7677my $debug = 0; 
    7778my $debug_encoding = 0; 
     79# Testing shows 64k is pretty optimal 
    7880#my $buffer_length =    4 * 1024; # 4k blocks 
    7981#my $buffer_length =    8 * 1024; # 8k blocks 
     
    115117  if (!defined $thrift_client) 
    116118  { 
    117     ###rint "Create Thrift Client to $host:$port\n"; 
     119    # Look for a configuration file to override the default localhost:58660 
     120    # settings 
     121    my $conf_file_path = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, 'etc', 'thrift.conf'); 
     122    if (&FileUtils::fileExists($conf_file_path)) 
     123    { 
     124      print "Found Thrift configuration file:\n"; 
     125      my $conf_raw = &FileUtils::fileGetContents($conf_file_path); 
     126      if ($conf_raw =~ /^([^:]+):(\d+)/) 
     127      { 
     128        $host = $1; 
     129        print " - Host: " . $host . "\n"; 
     130        $port = $2; 
     131        print " - Port: " . $port . "\n"; 
     132      } 
     133    } 
     134 
     135    print "Establish Thrift client connecting to: $host:$port\n"; 
    118136    my $socket = Thrift::Socket->new($host, $port); 
    119137    $socket->setSendTimeout(10000);