Changeset 29190


Ignore:
Timestamp:
08/14/14 14:54:59 (7 years ago)
Author:
ak19
Message:

Suppressing the ping collection 'did not succeed' message in silent mode. Using silent mode when the collection's been deactivated and we expect pinging a collection to return false.

File:
1 edited

Legend:

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

    r28953 r29190  
    143143# and is-persistent (is-persistent only implemented for GS2).
    144144sub config {
    145     my ($library_url, $command, $check_message_against_regex, $site, $expected_error_code) = @_;
     145    my ($library_url, $command, $check_message_against_regex, $site, $expected_error_code, $silent) = @_;
    146146            # Gatherer.java's configGS3Server doesn't use the site variable
    147147            # so we don't have to either
     
    177177                return 1;
    178178            } else {
     179                # if we expect the collection to be inactive, then we'd be in silent mode: if so,
     180                # don't print out the "ping did not succeed" response, but print out any other messages
     181
     182                # So we only suppress the ping col "did not succeed" response if we're in silent mode
     183                # But if any message other than ping "did not succeed" is returned, we always print it
     184                if($response_content !~ m/did not succeed/ || !$silent) {
    179185                &print_msg("\n\tBUT: command $library_url$command response UNEXPECTED.\n", 3);
    180186                &print_msg("*** Got message:\n$response_content.\n", 4);
    181                 return 0; # ping on a collection may "not succeed."
     187                }
     188                return 0; # ping on a collection may "not succeed."
    182189            }
    183190        }
     
    231238
    232239sub ping {
    233     my ($library_url, $command, $gs_mode, $site) = @_;
     240    my ($library_url, $command, $gs_mode, $site, $silent) = @_;
    234241
    235242    # If the GS server is not running, we *expect* to see a "500" status code.
     
    239246    my $check_responsemsg_against_regex = q/(succeeded)/;
    240247    my $expected_error_code = 500;
    241     return config($library_url, $command, $check_responsemsg_against_regex, $site, $expected_error_code);
     248    return config($library_url, $command, $check_responsemsg_against_regex, $site, $expected_error_code, $silent);
    242249}
    243250
     
    259266# send a pingaction to a collection in GS library to check if it's active
    260267sub ping_library_collection {
    261     my ($library_url, $gs_mode, $qualified_collection, $site) = @_;
     268    my ($library_url, $gs_mode, $qualified_collection, $site, $silent) = @_;
    262269   
    263270    my $command = "";
     
    268275        $command = "?a=s&sa=ping&st=collection&sn=$qualified_collection";       
    269276    }
    270     return &ping($library_url, $command, $gs_mode, $site);
     277    return &ping($library_url, $command, $gs_mode, $site, $silent);
    271278}
    272279
     
    764771
    765772                    &print_msg("Checking if the collection $qualified_collection is not already active\n");
    766                     my $collection_active = &ping_library_collection($library_url, $gs_mode, $qualified_collection, $site);
     773
     774                    # Since we could have deactivated the collection at this point,
     775                    # it is likely that it is not yet active. When pinging the collection
     776                    # a "ping did not succeed" message is expected, therefore tell the ping
     777                    # to proceed silently
     778                    my $silent = 1;
     779                    my $collection_active = &ping_library_collection($library_url, $gs_mode, $qualified_collection, $site, $silent);
    767780
    768781                    if (!$collection_active) {
     782                    &print_msg(" Collection is not active.\n");
    769783                    &print_msg("Activating collection $qualified_collection\n");
    770784                    &activate_collection($library_url, $gs_mode, $qualified_collection, $site);
    771785                   
    772786                    # unless an error occurred, the collection should now be active:
    773                     $collection_active = &ping_library_collection($library_url, $gs_mode, $qualified_collection, $site);
     787                    $collection_active = &ping_library_collection($library_url, $gs_mode, $qualified_collection, $site); # not silent if ping did not succeed
    774788                    if(!$collection_active) {
    775789                        &print_msg("ERROR: collection $qualified_collection did not get activated\n");
Note: See TracChangeset for help on using the changeset viewer.