Saturday, July 8, 2017

Solr 6: Solr Eclipse Project and Debugging

Creating a Solr Eclipse Project for Debugging
We can download the Solr source code and unpack it.  On my computer, I downloaded the source code under the Solr (binary) home directory.  This is the directory structure under the Solr 6.6 home directory on my computer.  By the way, Solr 6.6 requires a Java 8 or higher.
The build.xml under a 'solr-src' directory contains multiple targets such as "idea" and "eclipse".  I will run an ant command to create an Eclipse project.  You may need to install Apache Ant and Apache Ivy before running the command.
   ant eclipse

After completing the ant command, you can import the Solr project into your Eclipse as an Eclipse project.


Running Solr as a Standalone mode for Debugging
Solr provides a script to help users starting the Solr.  The -f parameter indicates a forward process, -m parameter defines the min and max heap size.  The -a parameter indicates the JVM parameters.  Since "suspend=y" is used, the start process will wait until the remote debugging starts (with a port number 8000 as specified).
bin/solr start -f -m 1g \
    -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
slkc:solr-6.6.0 jihwan$ pwd
/Users/jihwan/devTools/solr-6.6.0
slkc:solr-6.6.0 jihwan$ bin/solr start -f -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" -m 1g
Listening for transport dt_socket at address: 8000
2017-07-08 20:39:03.184 INFO  (main) [   ] o.e.j.s.Server jetty-9.3.14.v20161028
2017-07-08 20:39:03.545 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter  ___      _       Welcome to Apache Solr™ version 6.6.0
2017-07-08 20:39:03.545 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter / __| ___| |_ _   Starting in standalone mode on port 8983
2017-07-08 20:39:03.545 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter \__ \/ _ \ | '_|  Install dir: /Users/jihwan/devTools/solr-6.6.0
2017-07-08 20:39:03.558 INFO  (main) [   ] o.a.s.s.SolrDispatchFilter |___/\___/_|_|    Start time: 2017-07-08T20:39:03.546Z
2017-07-08 20:39:03.581 INFO  (main) [   ] o.a.s.c.SolrResourceLoader Using system property solr.solr.home: /Users/jihwan/devTools/solr-6.6.0/server/solr
2017-07-08 20:39:03.587 INFO  (main) [   ] o.a.s.c.SolrXmlConfig Loading container configuration from /Users/jihwan/devTools/solr-6.6.0/server/solr/solr.xml
2017-07-08 20:39:03.870 INFO  (main) [   ] o.a.s.u.UpdateShardHandler Creating UpdateShardHandler HTTP client with params: socketTimeout=600000&connTimeout=60000&retry=true
2017-07-08 20:39:04.229 INFO  (main) [   ] o.a.s.c.CorePropertiesLocator Found 0 core definitions underneath /Users/jihwan/devTools/solr-6.6.0/server/solr
2017-07-08 20:39:04.292 INFO  (main) [   ] o.e.j.s.Server Started @46112ms

As displayed, the SolrDispatchFilter is one of objects called during the start.  So, you can find this class in the Eclipse and may put a breakpoint at the beginning of an init method of this class.  Enjoy your debugging!


No comments:

Post a Comment

Java 9: Flow - Reactive Programming

Programming world has always been changed fast enough and many programming / design paradigms have been introduced such as object oriented p...