Search in sources :

Example 11 with JettyConfig

use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.

the class JettySolrRunnerTest method testRestartPorts.

@Test
public void testRestartPorts() throws Exception {
    Path solrHome = createTempDir();
    Files.write(solrHome.resolve("solr.xml"), MiniSolrCloudCluster.DEFAULT_CLOUD_SOLR_XML.getBytes(Charset.defaultCharset()));
    JettyConfig config = JettyConfig.builder().build();
    JettySolrRunner jetty = new JettySolrRunner(solrHome.toString(), config);
    try {
        jetty.start();
        URL url = jetty.getBaseUrl();
        int usedPort = url.getPort();
        jetty.stop();
        jetty.start();
        assertEquals("After restart, jetty port should be the same", usedPort, jetty.getBaseUrl().getPort());
        jetty.stop();
        jetty.start(false);
        assertThat("After restart, jetty port should be different", jetty.getBaseUrl().getPort(), not(usedPort));
    } finally {
        if (jetty.isRunning())
            jetty.stop();
    }
}
Also used : Path(java.nio.file.Path) JettyConfig(org.apache.solr.client.solrj.embedded.JettyConfig) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) URL(java.net.URL) Test(org.junit.Test)

Example 12 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(String dataDir, String ulogDir, String shardList, String solrConfigOverride) throws Exception {
    JettyConfig jettyconfig = JettyConfig.builder().setContext(context).stopAtShutdown(false).withServlets(getExtraServlets()).withFilters(getExtraRequestFilters()).withSSLConfig(sslConfig).build();
    Properties props = new Properties();
    props.setProperty("solr.data.dir", getDataDir(dataDir));
    props.setProperty("shards", shardList);
    props.setProperty("solr.ulog.dir", ulogDir);
    props.setProperty("solrconfig", solrConfigOverride);
    JettySolrRunner jetty = new JettySolrRunner(getSolrHome(), 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 13 with JettyConfig

use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.

the class BasicHttpSolrClientTest method beforeTest.

@BeforeClass
public static void beforeTest() throws Exception {
    JettyConfig jettyConfig = JettyConfig.builder().withServlet(new ServletHolder(RedirectServlet.class), "/redirect/*").withServlet(new ServletHolder(SlowServlet.class), "/slow/*").withServlet(new ServletHolder(DebugServlet.class), "/debug/*").withSSLConfig(sslConfig).build();
    createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
}
Also used : JettyConfig(org.apache.solr.client.solrj.embedded.JettyConfig) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) BeforeClass(org.junit.BeforeClass)

Example 14 with JettyConfig

use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.

the class SSLMigrationTest method testMigrateSSL.

public void testMigrateSSL(SSLTestConfig sslConfig) throws Exception {
    String urlScheme = sslConfig.isSSLMode() ? "https" : "http";
    setUrlScheme(urlScheme);
    for (JettySolrRunner runner : jettys) {
        runner.stop();
    }
    HttpClientUtil.setSchemaRegistryProvider(sslConfig.buildClientSchemaRegistryProvider());
    for (int i = 0; i < this.jettys.size(); i++) {
        JettySolrRunner runner = jettys.get(i);
        JettyConfig config = JettyConfig.builder().setContext(context).setPort(runner.getLocalPort()).stopAtShutdown(false).withServlets(getExtraServlets()).withFilters(getExtraRequestFilters()).withSSLConfig(sslConfig).build();
        Properties props = new Properties();
        if (getSolrConfigFile() != null)
            props.setProperty("solrconfig", getSolrConfigFile());
        if (getSchemaFile() != null)
            props.setProperty("schema", getSchemaFile());
        props.setProperty("solr.data.dir", getDataDir(testDir + "/shard" + i + "/data"));
        JettySolrRunner newRunner = new JettySolrRunner(runner.getSolrHome(), props, config);
        newRunner.start();
        jettys.set(i, newRunner);
    }
    assertReplicaInformation(urlScheme);
}
Also used : JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) JettyConfig(org.apache.solr.client.solrj.embedded.JettyConfig) Properties(java.util.Properties)

Example 15 with JettyConfig

use of org.apache.solr.client.solrj.embedded.JettyConfig in project lucene-solr by apache.

the class TestReplicationHandlerBackup method createJetty.

private static JettySolrRunner createJetty(TestReplicationHandler.SolrInstance instance) throws Exception {
    FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(instance.getHomeDir(), "solr.xml"));
    Properties nodeProperties = new Properties();
    nodeProperties.setProperty("solr.data.dir", instance.getDataDir());
    JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").setPort(0).build();
    JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), nodeProperties, 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) File(java.io.File)

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