Search in sources :

Example 1 with RemoteSolrServerConfiguration

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

the class FullTextSolrSearchTest method initializeProvider.

private void initializeProvider() throws Exception {
    if (server == null || "default".equals(server)) {
        log.info("spawning Solr locally");
        serverProvider = createEmbeddedSolrServerProvider(true);
    } else if (server != null && "embedded".equals(server)) {
        log.info("using embedded Solr");
        serverProvider = createEmbeddedSolrServerProvider(false);
    } else if (server != null && (server.startsWith("http") || server.matches("\\w+\\:\\d{3,5}"))) {
        log.info("using remote Solr {}", server);
        RemoteSolrServerConfiguration remoteSolrServerConfiguration = new RemoteSolrServerConfiguration(server, "oak", 2, 2, null, server);
        serverProvider = remoteSolrServerConfiguration.getProvider();
    } else {
        throw new IllegalArgumentException("server parameter value must be either 'embedded', 'default', an URL or an host:port String");
    }
}
Also used : RemoteSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration)

Example 2 with RemoteSolrServerConfiguration

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

the class RemoteSolrServerProviderIT method testCloudRemoteServerCreation.

@Test
public void testCloudRemoteServerCreation() throws Exception {
    // do this test only if a Solr Cloud server is available
    for (String host : zkHosts) {
        boolean cloudServerAvailable = false;
        try {
            cloudServerAvailable = canCreateCollections(host);
        } catch (Exception e) {
        // do nothing
        }
        if (cloudServerAvailable) {
            String collection = "sample_" + System.nanoTime();
            RemoteSolrServerProvider remoteSolrServerProvider = new RemoteSolrServerProvider(new RemoteSolrServerConfiguration(host, collection, 2, 2, null));
            SolrServer solrServer = remoteSolrServerProvider.getSolrServer();
            assertNotNull(solrServer);
            solrServer.shutdown();
            break;
        }
    }
}
Also used : RemoteSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration) SolrServer(org.apache.solr.client.solrj.SolrServer) CloudSolrServer(org.apache.solr.client.solrj.impl.CloudSolrServer) Test(org.junit.Test)

Example 3 with RemoteSolrServerConfiguration

use of org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration 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)

Example 4 with RemoteSolrServerConfiguration

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

the class RemoteSolrServerConfigurationProvider method activate.

@Activate
protected void activate(ComponentContext componentContext) throws Exception {
    solrHttpUrl = String.valueOf(componentContext.getProperties().get(SOLR_HTTP_URL));
    solrZkHost = String.valueOf(componentContext.getProperties().get(SOLR_ZK_HOST));
    solrCollection = String.valueOf(componentContext.getProperties().get(SOLR_COLLECTION));
    solrShardsNo = Integer.valueOf(componentContext.getProperties().get(SOLR_SHARDS_NO).toString());
    solrReplicationFactor = Integer.valueOf(componentContext.getProperties().get(SOLR_REPLICATION_FACTOR).toString());
    solrConfDir = String.valueOf(componentContext.getProperties().get(SOLR_CONF_DIR));
    remoteSolrServerConfiguration = new RemoteSolrServerConfiguration(solrZkHost, solrCollection, solrShardsNo, solrReplicationFactor, solrConfDir, solrHttpUrl);
}
Also used : RemoteSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration) Activate(org.apache.felix.scr.annotations.Activate)

Aggregations

RemoteSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration)4 Nonnull (javax.annotation.Nonnull)1 Activate (org.apache.felix.scr.annotations.Activate)1 EmbeddedSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration)1 SolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration)1 SolrServer (org.apache.solr.client.solrj.SolrServer)1 CloudSolrServer (org.apache.solr.client.solrj.impl.CloudSolrServer)1 Test (org.junit.Test)1