Ignore:
Timestamp:
2012-06-28T17:47:07+12:00 (12 years ago)
Author:
ak19
Message:

Normal commit, before the first set of commits related to getting activate.pl working with solr. In this commit: fixed result of ping to no longer say 500 Failed when the GS3 library server is not running, as this is one of the expected results when pinging. Cleared up the code working out what the buildtype is, which is now simplified, since at the activate stage any change of indexers would already have been dealt with.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/activate.pl

    r25796 r25887  
    103103# and is-persistent (is-persistent only implemented for GS2).
    104104sub config {
    105     my ($library_url, $command, $check_message_against_regex, $site) = @_;
     105    my ($library_url, $command, $check_message_against_regex, $site, $expected_error_code) = @_;
    106106            # Gatherer.java's configGS3Server doesn't use the site variable
    107107            # so we don't have to either
     
    143143        }
    144144        elsif(LWP::Simple::is_error($response_code)) { # method exported by LWP::Simple, along with HTTP::Status constants
     145            # check the page content is as expected
     146            if(defined $expected_error_code && $response_code == $expected_error_code) {
     147            &print_msg(" Response status $response_code as expected.\n", 3);
     148            } else {
    145149            &print_msg("*** Command $library_url$command\n");
    146             &print_msg("*** HTTP Response Status: $response_code - Failed.\n");
    147             return 0;
     150            &print_msg("*** Unexpected error. HTTP Response Status: $response_code - Failed.\n");
     151            }
     152            return 0; # return false, since the response_code was an error, expected or not
    148153        }
    149154    }   
     
    182187sub ping {
    183188    my ($library_url, $command, $gs_mode, $site) = @_;
    184    
    185     # "Ping" ... "succeeded" expected on success. (Ping on a collection may "not succeed".)
    186     my $check_responsemsg_against_regex = q/succeeded/;
    187     return config($library_url, $command, $check_responsemsg_against_regex, $site);
     189
     190    # If the GS server is not running, we *expect* to see a "500" status code.
     191    # If the GS server is running, then "Ping" ... "succeeded" is expected on success.
     192    # When pinging an inactive collection, it will say it did "not succeed". This is
     193    # a message of interest to return.
     194    my $check_responsemsg_against_regex = q/(succeeded)/;
     195    my $expected_error_code = 500;
     196    return config($library_url, $command, $check_responsemsg_against_regex, $site, $expected_error_code);
    188197}
    189198
     
    482491   
    483492    # Read in the collection configuration file.
    484     # Beware: Only if $site is specified in the cmdline does collectionConfig.xml get
    485     # generated and does $gs_mode=gs3, else collect.cfg gets generated and $gs_mode=gs2
     493    # Beware: Only if $site is specified in the cmdline does collectionConfig.xml get
     494    # generated and does $gs_mode=gs3, else collect.cfg gets generated and $gs_mode=gs2
    486495    my ($collect_cfg_filename, $gs_mode) = &colcfg::get_collect_cfg_name(STDERR);
    487496    my $collectcfg = &colcfg::read_collection_cfg ($collect_cfg_filename,$gs_mode);
     
    498507    }
    499508   
    500     # We would like to know what the buildtype is
    501     # This will be useful for Solr.
    502     if (-e $build_cfg_filename) {
    503 
    504         # testing if there has been a change of indexer
    505         # (e.g. collect.cfg now says lucene, but build.cfg says mgpp)
    506         my $buildcfg = &colcfg::read_building_cfg ($build_cfg_filename, $gs_mode);
    507         if ($buildcfg->{'buildtype'} ne $collectcfg->{'buildtype'}) {
    508             ### do something? See incremental-buildcol.pl
    509         }
    510         else {
    511             ### do something? See incremental-buildcol.pl
    512         }
    513     }
    514     else { # build.cfg doesn't exist
    515         ### do something? See incremental-buildcol.pl
     509    # We need to know the buildtype for Solr.
     510    # Any change of indexers is already detected and handled by the calling code (buildcol or
     511    # full-rebuild), so that at this stage the config file's buildtype reflects the actual buildtype.
     512
     513    # From buildcol.pl we use searchtype for determining buildtype, but for old versions, use buildtype
     514    my $buildtype;
     515    if (defined $collectcfg->{'buildtype'}) {
     516    $buildtype = $collectcfg->{'buildtype'};
     517    } elsif (defined $collectcfg->{'searchtypes'} || defined $collectcfg->{'searchtype'}) {
     518    $buildtype = "mgpp";
     519    } else {
     520    $buildtype = "mg"; #mg is the default
    516521    }
    517522   
     
    567572   
    568573    if($removeold) {
    569        
     574       
    570575        if(&util::dir_exists($index_dir)) {
    571576            &print_task_msg("Removing \"index\"");
Note: See TracChangeset for help on using the changeset viewer.