In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to solve the problem of thread jam when the application calls the Libvirt library for control in Tomcat. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
In recent projects, the java package of libvirt is used to make remote command calls to libvirt for kvm management. Our testers tested out by chance that there may be a serious bug when controlling the connection status, because each time the flex application on the interface clicks on the virtual machine node, it will cause about 3-4 calls to the background remote service, and these remote service will use the structure of libvirt to obtain the results. We keep the libvirt link in order to improve efficiency. Instead of reconnecting every time to reduce the loss of performance.
There is such a situation, when the network is normal, the established connection always resides in memory, and if the network cable is unplugged, the link will not be broken. Because the value of the connection in memory is not empty, it is impossible to judge whether the link is broken, so when you click on the interface, if you call the interface of libvirt a little bit, it will always jam the interface and click a few more times, and all the service threads of tomcat will be stuck. Makes the entire interface unusable.
The solution is to start a thread to detect the disconnected state of the host in real time, and when the state is abnormal, throw an exception directly in the method of obtaining connection to prevent subsequent logic execution. But this can only solve the state problem, not the interface click problem in the gap between the state acquisition. Looking up the data, we found that the thread pool model of tomcat might be helpful, so we used the thread pool. After testing, we finally found that it was OK.
It is said that tomcat7 can detect which thread is stuck, but this is not available because the condition indicates that the tomcat6 environment in the product has not been upgraded to tomcat7.
Specific modification method:
The code is as follows:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.