Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

stopping a multithreaded, multi-machine standalone app  RSS feed

 
BV Boose
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I recently modified a multithreaded application so that it can run concurrently on multiple machines(linux and/or solaris). It's pretty much a while loop that creates threads as long as a value in the prop file is true.
I use a shell script to start the app.
Currently to stop the app you have to alter the value in the prop file,it waits for any running threads to complete and then shuts down, while inconvenient, it worked well enough, but since there's only one property file for all instances you stop one, you stop them all. I want to change it so you can stop any or all instances from the commandline, using the startup script with a switch.

So far I have:

create a thread to listen at a port for a shut down message

change the app to use mbeans and somehow use jmx to stop it(I don't know much about this approach, it's an idea from a colleague)

maybe use a setenv to set a property that will be checked in the while loop.

Anybody have any ideas about any of these approaches? Or maybe even something that would work better?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"gebuh", please check your private messages for an important administrative matter.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Anybody have any ideas about any of these approaches? Or maybe even something that would work better?


JMX will help you start/stop the thread while the system is running.
With properties file/system property, you will set once on startup and never change it.

So, you need to decide what is it that you want to do.

If you want to learn about JMX, here is the tutorial trail
 
BV Boose
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently this app continuously polls the prop file last update time, when you want to shut it down you open the prop file, change the start property and save it, this will reload the file.

I have decided what I want to do- I want to be able to shut down any or all instances of the application, currently you can only shut down them all, and editing a file to accomplish this is kinda awkward.

Originally posted by Nitesh Kant:


JMX will help you start/stop the thread while the system is running.
With properties file/system property, you will set once on startup and never change it.

So, you need to decide what is it that you want to do.

If you want to learn about JMX, here is the tutorial trail
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!