Search in sources :

Example 6 with JettyConfig

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;
}
Also used : JettyConfig(org.apache.solr.client.solrj.embedded.JettyConfig) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) Properties(java.util.Properties)

Example 7 with JettyConfig

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);
}
Also used : JettyConfig(org.apache.solr.client.solrj.embedded.JettyConfig) Properties(java.util.Properties)

Example 8 with 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();
    }
}
Also used : JettyConfig(org.apache.solr.client.solrj.embedded.JettyConfig)

Example 9 with JettyConfig

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;
}
Also used : Path(java.nio.file.Path) JettyConfig(org.apache.solr.client.solrj.embedded.JettyConfig) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner)

Example 10 with JettyConfig

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();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JettyConfig(org.apache.solr.client.solrj.embedded.JettyConfig) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) IOException(java.io.IOException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

JettyConfig (org.apache.solr.client.solrj.embedded.JettyConfig)15 JettySolrRunner (org.apache.solr.client.solrj.embedded.JettySolrRunner)10 Properties (java.util.Properties)8 File (java.io.File)4 Path (java.nio.file.Path)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 BeforeClass (org.junit.BeforeClass)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 URL (java.net.URL)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MiniSolrCloudCluster (org.apache.solr.cloud.MiniSolrCloudCluster)1