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
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrSearch.java

    r25886 r25892  
    7474
    7575                String solr_home_str = GSFile.extHome(gsdl3_home, solr_ext_name);
    76                 File solr_home = new File(solr_home_str);
    77                 File solr_xml = new File(solr_home, "solr.xml");
    78 
    79                 all_solr_cores = new CoreContainer(solr_home_str, solr_xml);
     76
     77                all_solr_cores = new CoreContainer(solr_home_str);
    8078            }
    8179            catch (Exception e)
     
    9189    public boolean configure(Element info, Element extra_info)
    9290    {
    93         if (!super.configure(info, extra_info))
    94         {
    95             return false;
    96         }
    97 
     91        boolean success = super.configure(info, extra_info);
     92
     93        // 1. Make the CoreContainer reload solr.xml
     94        // This is particularly needed for when activate.pl is executed during
     95        // a running GS3 server. At that point, the solr collection is reactivated and
     96        // we need to tell Greenstone that the solr index has changed. This requires
     97        // the CoreContainer to reload the solr.xml file, and it all works again.
     98
     99        solr_core_cache.clear(); // clear the map of existing solr cores
     100       
     101        // Reload the updated solr.xml into the CoreContainer
     102        // (Doing an all_solr_cores.shutdown() first doesn't seem to be required)
     103        try {   
     104            String solr_home_str = all_solr_cores.getSolrHome();
     105            File solr_home = new File(solr_home_str);
     106            File solr_xml = new File( solr_home,"solr.xml" );
     107           
     108            all_solr_cores.load(solr_home_str,solr_xml);
     109        } catch (Exception e) {
     110            logger.error("Exception in GS2SolrSearch.configure(): " + e.getMessage());
     111            e.printStackTrace();
     112            return false;
     113        }
     114       
     115        if(!success) {
     116            return false;
     117        }
     118       
     119        // 2. Setting up facets
    98120        Element searchElem = (Element) GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM);
    99121        NodeList configIndexElems = searchElem.getElementsByTagName(GSXML.INDEX_ELEM);
Note: See TracChangeset for help on using the changeset viewer.