A profiling and event collection framework built into the Oracle JDK. It gathers low level information about the JVM and application behavior without performance impact (less than 2%). With Java Flight Recorder system administrators and developers have a new way to diagnose production issues. JFR provides a way to collect events from a Java application from the OS layer, the JVM, and all the way up to the Java application. The collected events include thread latency events such as sleep, wait, lock contention, I/O, GC, and method profiling. JFR can be enabled by default and continuously collect low level data from Java applications in production environments. This will allow a much faster turnaround time for system administrators and developers when a production issue occurs. Rather than turning on data gathering after the fact, the continuously collected JFR data is simply written to disk and the analysis can be done on data collected from the application leading up to the issue, rather than data collected afterwards. We can use this JFR to do long run testing in effective way.
Here we will see using JFR to do long run testing to WSO2 products through JMC (JAVA Mission Control). Here I am taking WSO2 CEP as WSO2 Product.
- Go to <CEP_HOME>/bin and open wso2server.sh using gedit.
- In that you can see $JAVACMD. Below that add these to enable JFR
- -XX:+UnlockCommercialFeatures \
- -XX:+FlightRecorder \
- Start WSO2 CEP by using sh ./wso2server.sh in terminal.
- Then start JMC by clicking on that. You can see this org.wso2.carbon.bootstrap.Bootstrap in that UI like below.
- Right click on org.wso2.carbon.bootstrap.Bootstrap and click on start Flight Recording. Following window will be appear.
- Then go to next steps and do your relevant changes and click on Finish.
- After specific time you mentioned you will get a .jfr file you can see the memory growth, cpu usage..... in that.
- You can open this .jfr file anytime.
Thanks all :)