/** * 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; }
@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); }
/** * Start a new Solr instance * * @param hostContext context path of Solr servers used by Jetty * @param extraServlets Extra servlets to be started by Jetty * @param extraRequestFilters extra filters to be started by Jetty * @param sslConfig SSL configuration * @return new Solr instance */ public JettySolrRunner startJettySolrRunner( String name, String hostContext, SortedMap<ServletHolder, String> extraServlets, SortedMap<Class<? extends Filter>, String> extraRequestFilters, SSLConfig sslConfig) throws Exception { return startJettySolrRunner( name, hostContext, JettyConfig.builder() .withServlets(extraServlets) .withFilters(extraRequestFilters) .withSSLConfig(sslConfig) .build()); }
/** * Create a MiniSolrCloudCluster * * @param numServers number of Solr servers to start * @param hostContext context path of Solr servers used by Jetty * @param baseDir base directory that the mini cluster should be run from * @param solrXml solr.xml file to be uploaded to ZooKeeper * @param extraServlets Extra servlets to be started by Jetty * @param extraRequestFilters extra filters to be started by Jetty * @param sslConfig SSL configuration * @throws Exception if there was an error starting the cluster */ public MiniSolrCloudCluster( int numServers, String hostContext, Path baseDir, String solrXml, SortedMap<ServletHolder, String> extraServlets, SortedMap<Class<? extends Filter>, String> extraRequestFilters, SSLConfig sslConfig) throws Exception { this( numServers, baseDir, solrXml, JettyConfig.builder() .setContext(hostContext) .withSSLConfig(sslConfig) .withFilters(extraRequestFilters) .withServlets(extraServlets) .build()); }