Ignore:
Timestamp:
2012-07-03T19:53:05+12:00 (12 years ago)
Author:
ak19
Message:

First commit for allowing a SOLR collection to be activated without having to run ant restart to get Greenstone to allow searching the updated solr index.

File:
1 edited

Legend:

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

    r25889 r25892  
    430430    my $build_dir = undef;
    431431    my $index_dir = undef;
    432     my $site = undef;
     432    my $site = undef;
    433433   
    434434    my $removeold = 0;
    435435    my $keepold = 0;
    436    
     436    my $incremental = 0; # used by solr
     437
    437438    my $library_url = undef; # to be specified on the cmdline if not using a GS-included web server
    438439   
     
    455456        elsif ($arg eq "-keepold") {
    456457            $keepold = 1;
     458        }
     459        elsif ($arg eq "-incremental") {
     460            $incremental = 1;
    457461        }
    458462        elsif ($arg eq "-library_url") {
     
    595599    # If keepold: move building's contents into index, where only duplicates will get deleted.
    596600    # removeold and keepold can't both be on at the same time
    597     ($removeold, $keepold) = &scriptutil::check_removeold_and_keepold($removeold, $keepold,
    598                            0, # incremental is irrelevant to what activate.pl does, setting this = 0
     601        # incremental becomes relevant for solr, though it was irrelevant to what activate.pl does (moving building to index)
     602    my $incremental_mode;
     603    ($removeold, $keepold, $incremental, $incremental_mode) = &scriptutil::check_removeold_and_keepold($removeold, $keepold,
     604                           $incremental,
    599605                           $build_dir, # checkdir. Usually archives or export to be deleted. activate.pl deletes building
    600606                           $collectcfg);
     
    639645        }
    640646    }
    641     elsif ($keepold) {
    642             if ($buildtype eq "solr") { ### no building- prefix for keepold incremental case?
     647    elsif ($keepold || $incremental) {
     648            if ($buildtype eq "solr") {
    643649            # if solr, remove any cores that may be using the building_dir before moving this dir onto index
    644650            foreach my $corename (@corenames) {         
     
    652658        &util::mv_dir_contents($build_dir, $index_dir);
    653659    }
    654    
     660
    655661    if ($buildtype eq "solr") {
    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
     662    # Call CREATE action to get the old cores pointing to the index folder
    658663    foreach my $corename (@corenames) {
    659664        if($removeold) {
     665        # Call CREATE action to get all cores pointing to the index folder, since building is now index
    660666        $solr_server->admin_create_core($corename, $index_dir);
    661         } elsif ($keepold) {
    662         $solr_server->admin_reload_core($corename);
     667       
     668        } elsif ($keepold || $incremental) {
     669        # Call RELOAD core. Should already be using the index_dir directory for $keepold and $incremental case
     670       
     671        # Ping to see if corename exists, if it does, reload, else create
     672        if ($solr_server->admin_ping_core($corename)) {
     673            $solr_server->admin_reload_core($corename);
     674        } else {
     675            $solr_server->admin_create_core($corename, $index_dir);
     676        }
    663677        }
    664678    }
Note: See TracChangeset for help on using the changeset viewer.