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");
}
}
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;
}
}
}
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);
}
}
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);
}
Aggregations