We have a requirement where in we need to monitor remote JVM details via JMX using a simple servlet application. So things done till now in a standalone application is
1) Creat a JMX connector & get the Memory data --> done
2) We need to constantly monitor & get the records
(2.1 > which can be considered as scheduled task at constant delay & insert the records into DB Or 2.2> does the JMX gives the history if yes which MBean to access for the info?).
Here I am planning to use an interface to register the domain , followed to it. Have start & stop button from JSP. The functionality been when we click start the system will run the scheduler (ScheduledExecutorService ) & capture the records at background to give the history. When the uses clicks stop the scheduler has to stop the background process. The question is how can we control & get the object of a scheduler ?
1) In other words how can we start & stop a ScheduledExecutorService via servlets ? start a thread from one servlet & stop a thread from another servlet for a particular task ?
2) What if we have a clustered/load balanced environment ?
Currently am thinking of adding each ScheduledExecutorService into HashMap , key been the task object & value been the ScheduledExecutorService using SingleTon desgin pattern. Is there any default approach. The loop whole with SingleTon is in clustered/load balanced environment we may not be able to get the appropriate update objects.
Looking forward for your valuable suggestion.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…