Ignore:
Timestamp:
2017-03-10T22:03:47+13:00 (7 years ago)
Author:
ak19
Message:
  1. Fix to issue of a tomcat host/port change not propagating to solr host/port change when rebuilding a solr collection after tomcat host/port change. The change to tomcat server props need to be made after gs3-setup.sh was already run in the terminal earlier, to encouner the problem upon solr build. The bug was reproduced on Linux, and the fix for it also tested on Linux. Still need to test fix out on Windows. 2. Simultaneously made http protocol used in solr more robust to whether it's http or https.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/perllib/solrserver.pm

    r30534 r31490  
    4343    $self->{'server_explicitly_started'} = undef;
    4444
    45     my $server_port = $ENV{'SOLR_PORT'};
    46     my $server_host = $ENV{'SOLR_HOST'};
    47     my $base_url = "http://$server_host:$server_port/solr/";
    48     my $admin_url = "http://$server_host:$server_port/solr/admin/cores";
    49    
    50     $self->{'base-url'} = $base_url;
    51     $self->{'admin-url'} = $admin_url;
     45    # set SOLR_HOST and SOLR_PORT env vars (tomcat host and port, if not using jetty)
     46    # by calling ant get-default-solr-servlet if possible. Else fallback on whatever the existing env vars are.
     47    # tomcat host and port would have been set up in the env as SOLR_HOST and SOLR_PORT
     48    # In case someone changed the tomcat host/port, we want to update the solr server variables too
     49    my $solr_url = &solrutil::get_solr_servlet_url();   
     50    # get the url parts, though we won't be using most of them
     51    my ($protocol, $server_host, $server_port, $servlet_name) = &solrutil::get_solr_url_parts($solr_url);
     52   
     53    # set the solr server env vars to what was discovered, so that any other old perl code
     54    # dependent on these env vars will have any changes propagated.
     55    # (All perl code referencing these env vars should already be updated, but still...)
     56    $ENV{'SOLR_HOST'} = $server_host;
     57    $ENV{'SOLR_PORT'} = $server_port;
     58   
     59    $self->{'base-url'} = $solr_url; # e.g. of the form http://localhost:8383/solr
     60    $self->{'admin-url'} = "$solr_url/admin/cores";
    5261
    5362    return bless $self, $class;
     63}
     64
     65sub get_solr_base_url {
     66    my $self = shift (@_);
     67    return $self->{'base-url'};
    5468}
    5569
Note: See TracChangeset for help on using the changeset viewer.