Search in sources :

Example 1 with SolrServerConfigurationProvider

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

the class SolrIndexEditorProvider method getIndexEditor.

@Override
public Editor getIndexEditor(@Nonnull String type, @Nonnull NodeBuilder definition, @Nonnull NodeState root, @Nonnull IndexUpdateCallback callback) throws CommitFailedException {
    SolrIndexEditor editor = null;
    if (SolrQueryIndex.TYPE.equals(type)) {
        try {
            // if index definition contains a persisted configuration, use that
            if (isPersistedConfiguration(definition)) {
                NodeState nodeState = definition.getNodeState();
                OakSolrConfiguration configuration = new OakSolrNodeStateConfiguration(nodeState);
                SolrServerConfigurationProvider configurationProvider = new NodeStateSolrServerConfigurationProvider(definition.getChildNode("server").getNodeState());
                SolrServer solrServer = new OakSolrServer(configurationProvider);
                editor = getEditor(configuration, solrServer, callback);
            } else {
                // otherwise use the default configuration providers (e.g. defined via code or OSGi)
                OakSolrConfiguration configuration = oakSolrConfigurationProvider.getConfiguration();
                editor = getEditor(configuration, solrServerProvider.getIndexingSolrServer(), callback);
            }
        } catch (Exception e) {
            log.warn("could not get Solr index editor from {}", definition.getNodeState(), e);
        }
    }
    return editor;
}
Also used : NodeStateSolrServerConfigurationProvider(org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServerConfigurationProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NodeStateSolrServerConfigurationProvider(org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServerConfigurationProvider) SolrServerConfigurationProvider(org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider) OakSolrServer(org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer) OakSolrConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration) OakSolrNodeStateConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.OakSolrNodeStateConfiguration) SolrServer(org.apache.solr.client.solrj.SolrServer) OakSolrServer(org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Example 2 with SolrServerConfigurationProvider

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

the class SolrServerProviderService method getServer.

private SolrServer getServer() {
    SolrServer solrServer = null;
    if (serverType != null && !"none".equals(serverType)) {
        SolrServerConfigurationProvider solrServerConfigurationProvider = solrServerConfigurationProviders.get(serverType);
        if (solrServerConfigurationProvider != null) {
            try {
                solrServer = new OakSolrServer(solrServerConfigurationProvider);
                log.info("created new SolrServer {}", solrServer);
            } catch (Exception e) {
                log.error("could not get a SolrServerProvider of type {}", serverType, e);
            }
        }
    }
    return solrServer;
}
Also used : SolrServerConfigurationProvider(org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider) OakSolrServer(org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer) SolrServer(org.apache.solr.client.solrj.SolrServer) OakSolrServer(org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer) IOException(java.io.IOException)

Aggregations

SolrServerConfigurationProvider (org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider)2 OakSolrServer (org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer)2 SolrServer (org.apache.solr.client.solrj.SolrServer)2 IOException (java.io.IOException)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 OakSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration)1 NodeStateSolrServerConfigurationProvider (org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServerConfigurationProvider)1 OakSolrNodeStateConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.OakSolrNodeStateConfiguration)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1