Changeset 25889


Ignore:
Timestamp:
2012-06-28T21:25:18+12:00 (12 years ago)
Author:
ak19
Message:

Second set of commits for getting activate.pl to deal with solr cores when moving building to index. This time it uses the building- prefix and things still work. However, if the GS3 server is already running, an ant restart is required before searches return results and not sure about whether the incremental case is covered properly. The index reason is still being created for some reason when building.

Files:
3 edited

Legend:

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

    r25846 r25889  
    116116    my $core_prefix = (defined $site) ? "$site-$collect" : $collect;
    117117    my $core        = $core_prefix; # unused in this call to solr_passes
     118
     119    $core = "building-".$core unless $self->{'incremental'}; # core points to building only for force_removeold
    118120
    119121        print STDERR "Executable:    $solr_passes_exe\n";
     
    397399    if ($force_removeold) {
    398400        print $outhandle "\n-removeold set (new index will be created)\n";
     401
     402        # create cores under temporary core names, corresponding to building directory
     403        $core = "building-".$core;
    399404
    400405        my $full_index_dir = &util::filename_cat($build_dir,$index_dir);
     
    516521    my $core        = "$core_prefix-$ds_idx";
    517522
     523    $core = "building-".$core unless $self->{'incremental'}; # core points to building only for force_removeold
     524
    518525    print STDERR "Cmd: $solr_passes_exe $core index \"$build_dir\" \"$indexdir\"   $osextra\n";
    519526    if (!open($handle, "| $solr_passes_exe $core index \"$build_dir\" \"$indexdir\"   $osextra")) {
  • gs3-extensions/solr/trunk/src/perllib/solrserver.pm

    r25888 r25889  
    276276{
    277277    my $self = shift @_;
    278     my ($core) = @_;
     278    my ($core, $delete) = @_;
    279279
    280280    my $cgi_get_args = "action=UNLOAD&core=$core"; # &deleteIndex=true from Solr3.3
     281    if(defined $delete && $delete == 1) {
     282    $cgi_get_args = $cgi_get_args."&deleteIndex=true";
     283    }
    281284
    282285    $self->_admin_service($cgi_get_args);
  • main/trunk/greenstone2/bin/script/activate.pl

    r25888 r25889  
    601601   
    602602    if($removeold) {
    603 
    604         if ($buildtype eq "solr") {
    605         # if solr, remove any cores using the index_dir before deleting this dir
    606         foreach my $corename (@corenames) {
    607             $solr_server->admin_unload_core($corename);
    608         }
    609         }   
    610603       
    611604        if(&util::dir_exists($index_dir)) {
    612605            &print_task_msg("Removing \"index\"");
     606
     607            if ($buildtype eq "solr") {
     608                # if solr, remove any cores that are using the index_dir before deleting this dir
     609                foreach my $corename (@corenames) {
     610                $solr_server->admin_unload_core($corename);
     611                }
     612            }   
     613
    613614            &util::rm_r($index_dir);
    614615           
     
    624625        # the collection at this point since activate.pl lives on the server side
    625626       
     627        if ($buildtype eq "solr") {
     628            # if solr, remove any cores that are using the building_dir before moving this dir onto index
     629            foreach my $corename (@corenames) {
     630            $solr_server->admin_unload_core("building-$corename");
     631            }
     632        }
     633
    626634        # Move the building directory to become the new index directory
    627635        &print_task_msg("Moving \"building\" -> \"index\"");
     
    632640    }
    633641    elsif ($keepold) {
    634             if ($buildtype eq "solr") {
    635             # if solr, remove any cores using the index_dir before deleting this dir
     642            if ($buildtype eq "solr") { ### no building- prefix for keepold incremental case?
     643            # if solr, remove any cores that may be using the building_dir before moving this dir onto index
    636644            foreach my $corename (@corenames) {         
    637             $solr_server->admin_unload_core($corename);
     645            $solr_server->admin_unload_core("building-$corename") if $solr_server->admin_ping_core("building-$corename");
    638646            }
    639647        }
     
    646654   
    647655    if ($buildtype eq "solr") {
    648     # Call CREATE action to get the old cores pointing to the index folder
     656    # Call CREATE action to get all cores pointing to the index folder, since building is now index
     657    ### Should already be using the index_dir directory for $keepold (incremental) case? Then call RELOAD CORE
    649658    foreach my $corename (@corenames) {
    650         $solr_server->admin_create_core($corename, $index_dir);
     659        if($removeold) {
     660        $solr_server->admin_create_core($corename, $index_dir);
     661        } elsif ($keepold) {
     662        $solr_server->admin_reload_core($corename);
     663        }
    651664    }
    652665
Note: See TracChangeset for help on using the changeset viewer.