Ignore:
Timestamp:
2023-06-21T09:44:36+12:00 (10 months ago)
Author:
kjdon
Message:

added admin_unload_all_cores_for_prefix - when we are rebuilding a collection, we don't know what cores were previously there. eg if had subcollections, and now they have changed/gone. So we just unload all existing cores for that collection

File:
1 edited

Legend:

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

    r35684 r37786  
    183183}
    184184
     185sub admin_unload_all_cores_for_prefix
     186{
     187    my $self = shift @_;
     188    my ($coreprefix) = @_;
     189
     190    my $cgi_get_args = "action=STATUS&indexInfo=false";
     191    my $output = $self->_admin_service($cgi_get_args);
     192
     193    if (defined $output->{'error'}) {
     194    # severe error, such as failing to connect to the server
     195    $self->print_error($output);
     196    return;
     197    }
     198
     199    my $xml_output = $output->{'output'};
     200   
     201    my $matching_element="<lst\\s+name=\"($coreprefix-[a-z]+)\">";
     202    my @matches = ($xml_output =~ m/$matching_element/g);
     203
     204    foreach my $core (@matches) {
     205    print STDERR "unloading solr core $core\n";
     206    $self->admin_unload_core_explicitly_retaining_index($core);
     207    }
     208}
     209
     210sub print_error {
     211    my $self = shift @_;
     212    my ($output) = @_;
     213
     214    my $url      = $output->{'url'};
     215    my $preamble = $output->{'preamble'};
     216    my $error    = $output->{'error'};
     217   
     218    print STDERR "----\n";
     219    print STDERR "Error: Failed to get XML response from:\n";
     220    print STDERR "         $url\n";
     221    print STDERR "Output was:\n";
     222    print STDERR $preamble if ($preamble ne "");
     223    print STDERR "$error\n";
     224    print STDERR "----\n";
     225}
    185226
    186227sub admin_ping_core
     
    198239    # severe error, such as failing to connect to the server
    199240    $ping_status = 0;
    200 
    201     my $url      = $output->{'url'};
    202     my $preamble = $output->{'preamble'};
    203     my $error    = $output->{'error'};
    204    
    205     print STDERR "----\n";
    206     print STDERR "Error: Failed to get XML response from:\n";
    207     print STDERR "         $url\n";
    208     print STDERR "Output was:\n";
    209     print STDERR $preamble if ($preamble ne "");
    210     print STDERR "$error\n";
    211     print STDERR "----\n";
     241    $self->print_error($output);
     242
    212243    }
    213244    else {
Note: See TracChangeset for help on using the changeset viewer.