Package org.apache.solr.embedded
Class JettySolrRunner
java.lang.Object
org.apache.solr.embedded.JettySolrRunner
- Direct Known Subclasses:
MiniSolrCloudCluster.JettySolrRunnerWithMetrics
Run solr using jetty
- Since:
- solr 1.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classThis is a stupid hack to give jetty something to attach to -
Constructor Summary
ConstructorsConstructorDescriptionJettySolrRunner(String solrHome, int port) Create a new JettySolrRunner.JettySolrRunner(String solrHome, Properties nodeProperties, JettyConfig config) Construct a JettySolrRunnerJettySolrRunner(String solrHome, Properties nodeProperties, JettyConfig config, boolean enableProxy) Construct a JettySolrRunnerJettySolrRunner(String solrHome, JettyConfig config) Construct a JettySolrRunner -
Method Summary
Modifier and TypeMethodDescriptionvoidReturns a base URL likehttp://localhost:8983/solrorg.apache.solr.core.CoreContainerintReturns the Local Port of the jetty Server.intgetLocalPort(boolean internalPort) Returns the Local Port of the jetty Server.getProxy()Returns a base URL consisting of the protocol, host, and port for a Connector in use by the Jetty Server contained in this runner.org.apache.solr.servlet.SolrDispatchFilterprotected org.eclipse.jetty.server.Handler.WrapperinjectJettyHandlers(org.eclipse.jetty.server.Handler.Wrapper chain) descendants may inject own handler chaining it to the given root and then returning that own onebooleanbooleanstatic voidA main class that starts jetty+solr This is useful for debuggingorg.apache.solr.client.solrj.SolrClientorg.apache.solr.client.solrj.SolrClientnewClient(int connectionTimeoutMillis, int socketTimeoutMillis) voidoutputMetrics(Path outputDirectory, String fileName) voidsetProxyPort(int proxyPort) Sets the port of a local socket proxy that sits infront of this server; if set then all client traffic will flow through the proxy, giving us the ability to simulate network partitions very easily.voidstart()Start the Jetty servervoidstart(boolean reusePort) Start the Jetty servervoidstop()Stop the Jetty server
-
Constructor Details
-
JettySolrRunner
Create a new JettySolrRunner.After construction, you must start the jetty with
start()- Parameters:
solrHome- the solr home directory to useport- the port to run on
-
JettySolrRunner
Construct a JettySolrRunnerAfter construction, you must start the jetty with
start()- Parameters:
solrHome- the base path to run fromconfig- the configuration
-
JettySolrRunner
Construct a JettySolrRunnerAfter construction, you must start the jetty with
start()- Parameters:
solrHome- the solrHome to usenodeProperties- the container propertiesconfig- the configuration
-
JettySolrRunner
public JettySolrRunner(String solrHome, Properties nodeProperties, JettyConfig config, boolean enableProxy) Construct a JettySolrRunnerAfter construction, you must start the jetty with
start()- Parameters:
solrHome- the solrHome to usenodeProperties- the container propertiesconfig- the configurationenableProxy- enables proxy feature to disable connections
-
-
Method Details
-
injectJettyHandlers
protected org.eclipse.jetty.server.Handler.Wrapper injectJettyHandlers(org.eclipse.jetty.server.Handler.Wrapper chain) descendants may inject own handler chaining it to the given root and then returning that own one -
getSolrDispatchFilter
public org.apache.solr.servlet.SolrDispatchFilter getSolrDispatchFilter()- Returns:
- the
SolrDispatchFilterfor this node
-
getCoreContainer
public org.apache.solr.core.CoreContainer getCoreContainer()- Returns:
- the
CoreContainerfor this node
-
getNodeName
-
isRunning
public boolean isRunning() -
isStopped
public boolean isStopped() -
start
Start the Jetty serverIf the server has been started before, it will restart using the same port
- Throws:
Exception- if an error occurs on startup
-
start
Start the Jetty server- Parameters:
reusePort- when true, will start up on the same port as used by any previous runs of this JettySolrRunner. If false, will use the port specified by the server's JettyConfig.- Throws:
Exception- if an error occurs on startup
-
stop
Stop the Jetty server- Throws:
Exception- if an error occurs on shutdown
-
outputMetrics
- Throws:
IOException
-
dumpCoresInfo
- Throws:
IOException
-
getLocalPort
public int getLocalPort()Returns the Local Port of the jetty Server.- Throws:
RuntimeException- if there is no Connector
-
getLocalPort
public int getLocalPort(boolean internalPort) Returns the Local Port of the jetty Server.- Parameters:
internalPort- pass true to get the true jetty port rather than the proxy port if configured- Throws:
RuntimeException- if there is no Connector
-
setProxyPort
public void setProxyPort(int proxyPort) Sets the port of a local socket proxy that sits infront of this server; if set then all client traffic will flow through the proxy, giving us the ability to simulate network partitions very easily. -
getBaseUrl
Returns a base URL likehttp://localhost:8983/solr -
getBaseURLV2
-
getProxyBaseUrl
Returns a base URL consisting of the protocol, host, and port for a Connector in use by the Jetty Server contained in this runner. -
newClient
public org.apache.solr.client.solrj.SolrClient newClient() -
newClient
public org.apache.solr.client.solrj.SolrClient newClient(int connectionTimeoutMillis, int socketTimeoutMillis) -
getDebugFilter
-
main
A main class that starts jetty+solr This is useful for debugging- Throws:
Exception
-
getSolrHome
- Returns:
- the Solr home directory of this JettySolrRunner
-
getNodeProperties
- Returns:
- this node's properties
-
getProxy
-