Search in sources :

Example 1 with SolrServerConfiguration

use of org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration in project jackrabbit-oak by apache.

the class NodeStateSolrServerConfigurationProvider method getSolrServerConfiguration.

@Nonnull
@Override
public SolrServerConfiguration<SolrServerProvider> getSolrServerConfiguration() {
    String type = getStringValueFor(Properties.SERVER_TYPE, null);
    if ("embedded".equalsIgnoreCase(type)) {
        String solrHomePath = getStringValueFor(Properties.SOLRHOME_PATH, SolrServerConfigurationDefaults.SOLR_HOME_PATH);
        String coreName = getStringValueFor(Properties.CORE_NAME, SolrServerConfigurationDefaults.CORE_NAME);
        String context = getStringValueFor(Properties.CONTEXT, null);
        Integer httpPort = Integer.valueOf(getStringValueFor(Properties.HTTP_PORT, "0"));
        if (context != null && httpPort > 0) {
            return (SolrServerConfiguration) new EmbeddedSolrServerConfiguration(solrHomePath, coreName).withHttpConfiguration(context, httpPort);
        } else {
            return (SolrServerConfiguration) new EmbeddedSolrServerConfiguration(solrHomePath, coreName);
        }
    } else if ("remote".equalsIgnoreCase(type)) {
        String solrZkHost = getStringValueFor(Properties.ZK_HOST, null);
        String solrCollection = getStringValueFor(Properties.COLLECTION, SolrServerConfigurationDefaults.COLLECTION);
        int solrReplicationFactor = getIntValueFor(Properties.REPLICATION_FACTOR, SolrServerConfigurationDefaults.REPLICATION_FACTOR);
        String solrConfDir = getStringValueFor(Properties.CONFIGURATION_DIRECTORY, SolrServerConfigurationDefaults.CONFIGURATION_DIRECTORY);
        String solrHttpUrls = getStringValueFor(Properties.HTTP_URL, SolrServerConfigurationDefaults.HTTP_URL);
        int solrShardsNo = getIntValueFor(Properties.SHARDS_NO, SolrServerConfigurationDefaults.SHARDS_NO);
        return (SolrServerConfiguration) new RemoteSolrServerConfiguration(solrZkHost, solrCollection, solrShardsNo, solrReplicationFactor, solrConfDir, solrHttpUrls);
    } else {
        throw new RuntimeException("unexpected Solr server type: " + type);
    }
}
Also used : EmbeddedSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration) RemoteSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration) RemoteSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration) EmbeddedSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration) SolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)1 EmbeddedSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration)1 RemoteSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration)1 SolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration)1