Project

General

Profile

« Previous | Next » 

Revision 7593

Added by Jing Tao over 11 years ago

Read the solr configuration file name and collection name from the property file.

View differences:

metacat-index/src/test/java/edu/ucsb/nceas/metacat/index/SolrIndexIT.java
48 48
        List<SolrIndex> list = controller.getSolrIndexes();
49 49
        SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]);
50 50
        SolrIndex index = solrIndexesarray[0];
51
        SolrServer solrServer = SolrServerFactory.createSolrServer();
52
        index.setSolrServer(solrServer);
51
        //SolrServer solrServer = SolrServerFactory.createSolrServer();
52
        //index.setSolrServer(solrServer);
53 53
        return index;
54 54
    }
55 55
    
metacat-index/src/test/resources/org/dataone/configuration/test.properties
1 1
dataone.hazelcast.configFilePath=../lib/hazelcast.xml
2
solr.homeDir=target/classes/solr-home
2
#Embedded (default):
3
 solr.server.classname=org.apache.solr.client.solrj.embedded.EmbeddedSolrServer
4
 solr.homeDir=target/classes/solr-home
5
 solr.configFileName=solr.xml
6
 solr.collectionName=collection1
7
  
8
#HTTP:
9
 #solr.server.classname=org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
10
 solr.endpoint=http://endpoint/to/solr/service
metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrServerFactory.java
54 54
public class SolrServerFactory {
55 55
	
56 56
    public static final String SOLR_HOME_PROPERTY_NAME = "solr.homeDir";
57
    public static final String SOLR_CONFIG_FILE_NAME_PROPERTY_NAME = "solr.configFileName";
58
    public static final String SOLR_COLLECTION_NAME_PROPERTY_NAME = "solr.collectionName";
59
    public static final String SOLR_SERVER_CLASSNAME_PROPERTY_NAME = "solr.server.classname";
60
    private static final String EMBEDDEDSERVERCLASS = "org.apache.solr.client.solrj.embedded.EmbeddedSolrServer";
61
    private static final String HTTPSERVERCLASS = "org.apache.solr.client.solrj.impl.CommonsHttpSolrServer";
57 62

  
58 63
	public static Log log = LogFactory.getLog(SolrServerFactory.class);
59 64
	
......
64 69
		
65 70
		String solrHomeDir = Settings.getConfiguration().getString(SOLR_HOME_PROPERTY_NAME);
66 71
        log.info("The configured solr home from properties is " + solrHomeDir);
67
        File configFile = new File(solrHomeDir, "solr.xml");
72
        String configFileName = Settings.getConfiguration().getString(SOLR_CONFIG_FILE_NAME_PROPERTY_NAME);
73
        File configFile = new File(solrHomeDir, configFileName);
68 74
        coreContainer = new CoreContainer(solrHomeDir, configFile);
69 75
        coreContainer.load(solrHomeDir, configFile);
70
        solrServer = new EmbeddedSolrServer(coreContainer, "collection1");
76
        String collectioname = Settings.getConfiguration().getString(SOLR_COLLECTION_NAME_PROPERTY_NAME);
77
        solrServer = new EmbeddedSolrServer(coreContainer, collectioname);
71 78
        
72 79
        return solrServer;
73 80
	}

Also available in: Unified diff