Allow to execute SolrMeter without UI #94

GoogleCodeExporter opened this Issue Aug 15, 2015 · 34 comments


None yet
1 participant
This idea was discussed in the thread
The idea is to allow users to execute SolrMeter without the need to use the UI. 

Probably it can be implemented by letting SolrMeter run in a web server, like 
jetty which would allow to send commands remotely very easy.

This issue will involve
   - refactor to allow the UI and the web server to coexist reusing all of SolrMeter code.
   - create or use some libraries to export stats (or generate graphs and
   export in XLS or PDF) 

we should start by allowing to run SolrMeter using some configuration file, and 
add simple commands to start, stop, etc. Then we can incrementally add more and 
more features, like the generating PDF reports or even getting information 
through HTTP. 

This issue should be broken into smaller ones when we start to work in it

Original issue reported on by on 8 Dec 2011 at 11:00

If you could run it as a script type file, that would be awesome too.   
./run_solrmeter myconfig.xml > output.txt

Original comment by on 9 Jan 2012 at 7:42

Yes, non-ui version of Solrmeter would be indispensable. We can ssh into a 
remote machine and nohup the solrmeter in background.

Original comment by on 1 Feb 2013 at 10:03

Any news regarding this issue?
It would be Awesome to have Solrmeter running as a standalone Web Application 
and providing Rest Access to the main functionalities!

Original comment by on 6 Jun 2013 at 11:07

I also needed the ability to run Solrmeter from the command line for the work 
I'm doing on getting some automated regression tests in place.  I have a 
working patch that will allow you to do solrmeter 
-Dsolrmeter.configurationFile=solrmeter-config.smc.xml -DrunMode=headless.  The 
operations to perform are taken from the config file, and the realtime results 
from the tests are output to files on the file system.  This is a different 
direction than the jetty web server idea, but any interest in pursuing this 
implementation further?  If so, I'd be happy to perform the work necessary to 
get the patch where it needs to be.

Original comment by on 17 Jul 2013 at 5:42


I haven't tried Michael's patch yet but I really like the idea of it.  I think 
that the ability to run Solrmeter from the command line should be pursued and 
would be more useful to my use of Solrmeter than a webapp.

Original comment by on 17 Jul 2013 at 3:34

Hi Michael, first of all thanks for your work on this issue. This is one of the 
most requested features so I'll definitely going to add it. 
I could not apply your patch very cleanly, It doesn't seem wrong for me looking 
at it, but I couldn't apply it in a clean way from Eclipse or command line and 
I get lots of failed hunks. Could you generate a new patch?

Original comment by on 21 Jul 2013 at 7:31

  • Changed state: Started
Sure, I'd be happy to.  I'm just not sure what I need to do differently.  I 
just downloaded the patch from this ticket and successfully applied it to a 
fresh checkout of trunk.  I did this on both OSX and windows (thinking maybe it 
was an OS issue)  I wonder if it could be an svn client version 
incompatibility.  I used svn version 1.7.8 (r1419691) to create the patch.  To 
apply it, from the root of the repository I did: "svn patch 
~/solrmeter-R318-headless.patch".  Do you have any thoughts on what I 
can/should do differently this next time I generate the patch?  Thanks!   

Original comment by on 22 Jul 2013 at 2:19

It's strange what's going on, maybe it's something I'm doing wrong. If I apply 
the patch with:
svn patch --strip 1 ~/Downloads/solrmeter-R318-headless.patch .
I get the list of added and updated files as if it succeeds, but then the 
source code doesn't compile. I can see that many files are updated but don't 
get all the updates (in some cases, only the imports are updated, but lot's of 
hunks inside the class are not). The exact same thing I get if I apply the 
patch from Eclipse (Team->Apply Patch), seems to succeed but then get the same 
If I use the command: 
patch -p0 -i ~/Downloads/solrmeter-R318-headless.patch
I do get some errors on stdout, like: 

patching file 
patching file 
Hunk #1 FAILED at 17.
Hunk #2 FAILED at 40.
Hunk #3 FAILED at 71.
Hunk #4 FAILED at 107.
4 out of 4 hunks FAILED -- saving rejects to file 
patching file 
patching file 
Hunk #1 FAILED at 23.
Hunk #2 FAILED at 83.
Hunk #3 FAILED at 127.

Could you generate the patch using 

svn diff > solrmeter-R318-headless.patch

... or if you see that I'm doing something wrong, let me know ;)
(I did tried with a fresh checkout too)

Original comment by on 22 Jul 2013 at 1:39

I had the same errors at first too.  I was able to apply the patch using:

patch --ignore-whitespace -Np1 -d sources/ < solrmeter-R318-headless.patch 

Once the patch was applied, it didn't seem like 
solrmeter -Dsolrmeter.configurationFile=solrmeter-config.smc.xml 
worked to run in headless mode.  I would just get the regular gui.

 java -jar target/solrmeter-0.3.1-SNAPSHOT-jar-with-dependencies.jar -Dsolrmeter.configurationFile=solrmeter-config.smc.xml -DrunMode=headless
[main]| INFO|[boot]|09:34:02,109 | Adding plugins from ./plugins
[main]| WARN|[boot]|09:34:02,110 | No plugins directory found. No pluggin added
[main]| INFO|[boot]|09:34:02,220 | Loading Default configuration
[main]| INFO|[boot]|09:34:02,220 | Loading Configuration with file
[main]| INFO|[com.plugtree.solrmeter.SolrMeterMain]|09:34:02,224 | Using 
module: com.plugtree.solrmeter.StatisticsModule
[main]| INFO|[org.exolab.castor.mapping.Mapping]|09:34:02,367 | Loading mapping 
descriptors from 
[main]| INFO|[com.plugtree.solrmeter.SolrMeterMain]|09:34:02,832 | Using 
module: com.plugtree.solrmeter.ModelModule
[main]| INFO|[com.plugtree.solrmeter.SolrMeterMain]|09:34:02,833 | Using 
module: com.plugtree.solrmeter.StandalonePresentationModule
[main]| INFO|[com.plugtree.solrmeter.SolrMeterMain]|09:34:02,833 | Using 
module: com.plugtree.solrmeter.SolrMeterRunModeModule
[main]|ERROR|[com.plugtree.solrmeter.model.FileUtils]|09:34:03,494 | File could not be found on standard locations
[main]| INFO|[com.plugtree.solrmeter.view.I18n]|09:34:03,530 | Using Locale 
[main]| INFO|[com.plugtree.solrmeter.model.SolrServerRegistry]|09:34:03,668 | 
Connecting to Solr: http://localhost:8983/solr
[main]| INFO|[boot]|09:34:03,915 | Adding Statistic histogram
[main]| INFO|[boot]|09:34:04,241 | Adding Statistic timeRange
[main]| INFO|[boot]|09:34:04,276 | Adding Statistic queryHistory
[main]| INFO|[boot]|09:34:04,280 | Adding Statistic operationHistory
[main]| INFO|[boot]|09:34:04,287 | Adding Statistic fullQueryStatistic
[main]| INFO|[boot]|09:34:04,629 | Adding Statistic errorLog
[main]| INFO|[boot]|09:34:04,631 | Adding Statistic CacheStatistic
[main]| INFO|[boot]|09:34:04,639 | Adding Statistic QueryLogStatistic
[main]| INFO|[boot]|09:34:04,639 | Adding Statistic CommitHistoryStatistic
[main]| INFO|[boot]|09:34:04,639 | Adding Statistic SimpleOptimizeStatistic
[main]| INFO|[boot]|09:34:04,639 | Adding Statistic SimpleQueryStatistic
[main]| INFO|[boot]|09:34:04,639 | Adding Statistic OperationRateStatistic

<at this point the gui is available>

Original comment by on 22 Jul 2013 at 3:35

Thanks for giving this a try! I apologize for the trouble with the patch.  I'll 
work on this a bit later tonight and see if I can get you a better one.  With 
the extra bit of magic it sounds like you were able to get the patch to apply 
but that it wasn't running in headless mode.  In my original comment, I wrote 
that the property name was runMode, but in fact I see now that the correct 
property name is solrmeter.runMode. So with that change, you should be able to 
get it to run in headless mode.  What I did was first was run it in gui mode, 
export the config file, and then edit that to set the correct url for query and 
update operations.  After that the following command should work for you:

java -Dsolrmeter.runMode=headless 
-Dsolrmeter.configurationFile=<path_to_your_config> -jar 

by default there will be a directory named solrmeter-headless created in the 
current directory that contains the output from the query/update operations.  
You can change the output directory to something else by setting the 
headless.outputDirectory property in the config file.

Thanks again.  I'll post a new patch hopefully in a few hours or so.

Original comment by on 23 Jul 2013 at 12:44

OK, here's a new and hopefully better patch that I created with "diff" instead 
of "svn diff".  Hopefully this one works as it should.  I tested it on a clean 
checkout from the repo, and it compiled and ran.  Here's how I applied the 

Michael-Allens-MacBook-Pro:solrmeter-read-only mallen$ ls
solrmeter-R318-headless-v2.patch sources
Michael-Allens-MacBook-Pro:solrmeter-read-only mallen$ patch -p1 < 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file 
patching file sources/solrmeter/src/main/resources/
patching file sources/solrmeter/src/main/resources/statistics-config.xml
patching file 
Michael-Allens-MacBook-Pro:solrmeter-read-only mallen$

Original comment by on 23 Jul 2013 at 8:35


I could apply the new patch with no problems. Thanks!
I'll take a better look at it, hopefully later today or tomorrow

Original comment by on 23 Jul 2013 at 11:26

Cool!  That worked for me with -Dsolrmeter.runMode=headless.  Is there a way to 
set it to run for a fixed number of queries or a certain time duration?

Original comment by on 23 Jul 2013 at 6:34

Nice!  Yes, there is.  You can use headless.numQueries and headless.numUpdates 
for that.  Those both default to 100, which I know is quite low, so we'll 
probably want to change it to a more appropriate default.

Original comment by on 23 Jul 2013 at 9:08

Excellent.  Is there a way to exit the process when it has completed numQueries 
and numUpdates?

Original comment by on 23 Jul 2013 at 10:38

It's supposed to do that automatically.  I'll take a look at it.  There could 
be a bug there.

Original comment by on 23 Jul 2013 at 11:51

Maybe the problem is in the schedule you added on the 

Original comment by on 24 Jul 2013 at 11:10

It seems to be working for me.  If I set numQueries to 100 and numUpdates to 
200, it will perform the queries and finish those, but keep going until 
numUpdates updates have been performed.  After that the process exits.  On your 
box, does the process hang around even after the queries and updates have been 

Original comment by on 27 Jul 2013 at 2:36

[deleted comment]
[deleted comment]
If I set numQueries to 1 and numUpdates to 0, it will perform the query and 
then continue to print that same statistic over and over again.  The only way I 
can see to exit is CTRL+C. Maybe there's something I need to change in the 
config file.  The configuration I'm using is the unchanged output (except to 
reduce the number of queries and updates for illustrative purposes) of the 
default config for the gui.

Attached is the output over 5 mins of waiting and the scm.xml file that I'm 
using, invoked using cygwin on Windows 7 Enterprise edition with the example 
solr running in the background:

cd ~/solr-4.1.0/example
java -jar start.jar >solr.log 2>&1 &
cd ~/solrmeter/sources
java -Dsolrmeter.runMode=headless 
-Dsolrmeter.configurationFile=../solrmeter-config-raw.smc.xml -jar 
solrmeter/target/solrmeter-0.3.1-SNAPSHOT-jar-with-dependencies.jar > 

Original comment by on 29 Jul 2013 at 3:28


OK, here's version 3 of the patch which should fix that bug.  I had a thought 
that numQueries and numUpdates should maybe change to maxQueries and 
maxUpdates, since the numbers are approximate.  Right now whenever the view is 
refreshed it checks to see if that limit has been reached or exceeded and if so 
signal the controller to stop.  If we want to only perform exactly numQueries 
or numUpdates, I should go a different route.  Possibly modify the controller 
to start the executor with an exact number of queries to perform. 

Original comment by on 30 Jul 2013 at 6:49


Looks like the bug I'm experiencing is still present in the v3 patch.  I didn't 
go deep into how solrmeter functions but adding stopped() to the 
HeadlessUpdateConsolePanel and HeadlessQueryConsolePanel constructors seems to 
resolve my issue of the headless solrmeter not ending the process.

Original comment by on 31 Jul 2013 at 7:40

Yes, I found another issue last night while working on my regression harness 
for this where if I set headless.performUpdateOperations to false and 
headless.performQueryOperations to true (or the inverse of that), the process 
would hang like you're describing.  So here is v4 of the patch with the fix for 

Original comment by on 31 Jul 2013 at 8:01


Fantastic!  v4 patch works for me.

Original comment by on 31 Jul 2013 at 9:44

I'm noticing that the headless version of Solrmeter leaves TCP connections open 
in the CLOSE_WAIT state.  This is undesirable because CPU use increases and 
Solr slows to a crawl.  I have to reboot the machine I run solrmeter from and 
restart Solr in order to recover.  I couldn't reproduce this performing similar 
tests with the Solrmeter GUI.  Any ideas Michael?

Original comment by on 6 Sep 2013 at 6:04

I'll spend some time today to see if I can reproduce this.  Off hand, I can't 
think of anything different in headless that would cause this, but I'll 
investigate and let you know what I find out.

Original comment by on 8 Sep 2013 at 4:38

I wasn't able to reproduce the issue you were seeing with the network 
connections getting left open in the CLOSE_WAIT state.  Could you perhaps 
provide some more detail on what types of tests you were running when that 
occurred?  I tried to reproduce it with queries only, updates only, and then a 
mix of the two.  

Original comment by on 9 Sep 2013 at 9:47

Today I'm not able to reproduce the issue I was seeing either.  I spent the 
whole day last Thursday trying to track down why this was occurring.  The only 
thing I could identify as making a difference was headless vs GUI.  Thanks for 
taking the time to look at this.  Many apologies for asking the impossible.

If it comes up again: I run an ant script which starts 
solrmeter-0.3.1-SNAPSHOT-jar-with-dependencies.jar with the 
solrmeter.runMode=headless.  It does two things, runs load testing which I've 
set to 60 queries/min for ten minutes and then runs stress testing which I've 
set to 660 queries/min for 10 minutes.  No updates are performed during these 
tests.  On the occasions where I observed the CLOSE_WAIT state 
"" was also observed in the Solr logs.  
The Solr mailing list suggests that this is caused by the client not closing 
the connection.

Original comment by on 10 Sep 2013 at 4:32

OK, thanks for the additional information.  If you do see it again, please let 
me know and I'll take another stab at reproducing it.

Original comment by on 11 Sep 2013 at 5:44

This issue was closed by revision r319.

Original comment by on 31 Oct 2013 at 3:23

  • Changed state: Fixed
Committed. Thanks Michael for the code, and Tricia for the testing. 

Original comment by on 31 Oct 2013 at 3:24

  • Changed state: Resolved
Any chance we can get an 0.3.1 build?  This feature seems useful enough to 
warrent another public release!

Original comment by on 11 Jan 2014 at 8:44

Fortunately, I have some spare time this week. I will go over the issues list 
to see if there is any low-hanging fruit that I can take (if you have anything 
in mind, let me know), and then I will work to get the new release out. Is this 
feature stable enough to be released?

Original comment by on 14 Jan 2014 at 12:07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment