use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.
the class AbstractFullDistribZkTestBase method createJetty.
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, Replica.Type replicaType) throws Exception {
// randomly test a relative solr.home path
if (random().nextBoolean()) {
solrHome = getRelativeSolrHomePath(solrHome);
}
JettyConfig jettyconfig = JettyConfig.builder().setContext(context).stopAtShutdown(false).withServlets(getExtraServlets()).withFilters(getExtraRequestFilters()).withSSLConfig(sslConfig).build();
Properties props = new Properties();
if (solrConfigOverride != null)
props.setProperty("solrconfig", solrConfigOverride);
if (schemaOverride != null)
props.setProperty("schema", schemaOverride);
if (shardList != null)
props.setProperty("shards", shardList);
if (dataDir != null)
props.setProperty("solr.data.dir", getDataDir(dataDir));
if (replicaType != null) {
props.setProperty("replicaType", replicaType.toString());
} else if (random().nextBoolean()) {
props.setProperty("replicaType", Replica.Type.NRT.toString());
}
props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), props, jettyconfig);
jetty.start();
return jetty;
}
use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.
the class SolrJettyTestBase method createJetty.
public static JettySolrRunner createJetty(String solrHome, String configFile, String schemaFile, String context, boolean stopAtShutdown, SortedMap<ServletHolder, String> extraServlets) throws Exception {
// creates the data dir
context = context == null ? "/solr" : context;
SolrJettyTestBase.context = context;
JettyConfig jettyConfig = JettyConfig.builder().setContext(context).stopAtShutdown(stopAtShutdown).withServlets(extraServlets).withSSLConfig(sslConfig).build();
Properties nodeProps = new Properties();
if (configFile != null)
nodeProps.setProperty("solrconfig", configFile);
if (schemaFile != null)
nodeProps.setProperty("schema", schemaFile);
if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
nodeProps.setProperty("solr.data.dir", createTempDir().toFile().getCanonicalPath());
}
return createJetty(solrHome, nodeProps, jettyConfig);
}
use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.
the class TestMiniSolrCloudClusterSSL method checkClusterWithNodeReplacement.
/**
* Constructs a cluster with the specified sslConfigs, runs {@link #checkClusterWithCollectionCreations},
* then verifies that if we modify the default SSLContext (mimicing <code>javax.net.ssl.*</code>
* sysprops set on JVM startup) and reset to the default HttpClientBuilder, new HttpSolrClient instances
* will still be able to talk to our servers.
*
* @see SSLContext#setDefault
* @see HttpClientUtil#resetHttpClientBuilder
* @see #checkClusterWithCollectionCreations
*/
private void checkClusterWithNodeReplacement(SSLTestConfig sslConfig) throws Exception {
final JettyConfig config = JettyConfig.builder().withSSLConfig(sslConfig).build();
final MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), config);
try {
checkClusterWithCollectionCreations(cluster, sslConfig);
// Change the defaul SSLContext to match our test config, or to match our original system default if
// our test config doesn't use SSL, and reset HttpClientUtil to it's defaults so it picks up our
// SSLContext that way.
SSLContext.setDefault(sslConfig.isSSLMode() ? sslConfig.buildClientSSLContext() : DEFAULT_SSL_CONTEXT);
HttpClientUtil.resetHttpClientBuilder();
// recheck that we can communicate with all the jetty instances in our cluster
checkClusterJettys(cluster, sslConfig);
} finally {
cluster.shutdown();
}
}
use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.
the class MiniSolrCloudCluster method startJettySolrRunner.
/**
* Start a new Solr instance on a particular servlet context
*
* @param name the instance name
* @param hostContext the context to run on
* @param config a JettyConfig for the instance's {@link org.apache.solr.client.solrj.embedded.JettySolrRunner}
*
* @return a JettySolrRunner
*/
public JettySolrRunner startJettySolrRunner(String name, String hostContext, JettyConfig config) throws Exception {
Path runnerPath = createInstancePath(name);
String context = getHostContextSuitableForServletContext(hostContext);
JettyConfig newConfig = JettyConfig.builder(config).setContext(context).build();
JettySolrRunner jetty = new JettySolrRunner(runnerPath.toString(), newConfig);
jetty.start();
jettys.add(jetty);
return jetty;
}
use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.
the class MiniSolrCloudClusterTest method testErrorsInStartup.
@Test
public void testErrorsInStartup() throws Exception {
AtomicInteger jettyIndex = new AtomicInteger();
MiniSolrCloudCluster cluster = null;
try {
cluster = new MiniSolrCloudCluster(3, createTempDir(), JettyConfig.builder().build()) {
@Override
public JettySolrRunner startJettySolrRunner(String name, String context, JettyConfig config) throws Exception {
if (jettyIndex.incrementAndGet() != 2)
return super.startJettySolrRunner(name, context, config);
throw new IOException("Fake exception on startup!");
}
};
fail("Expected an exception to be thrown from MiniSolrCloudCluster");
} catch (Exception e) {
assertEquals("Error starting up MiniSolrCloudCluster", e.getMessage());
assertEquals("Expected one suppressed exception", 1, e.getSuppressed().length);
assertEquals("Fake exception on startup!", e.getSuppressed()[0].getMessage());
} finally {
if (cluster != null)
cluster.shutdown();
}
}
Aggregations