In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Preface
Arthas is a JVM online debugging and analysis tool similar to Btrace. For more information, please refer to my previous blog: troubleshooting online problems with JVM online debugging tool. This article shares a problem that the author has just encountered. It is not complicated, but it is typical.
Problem and analysis process
We encountered a problem when we went online yesterday. We sent data asynchronously to big data platform after the transaction, but they said that they did not receive the data, because we did not log it, so there was no direct evidence to prove that it was their problem, not ours.
The principle of sending numbers is roughly as follows: the main thread of the transaction puts the data into the queue, and then the asynchronous thread takes the data out of the queue and sends it to the background.
Queue: BlockingQueue queue = new BlockingQueue (); synchronous thread: void sendMsg (Message msg) {queue.offer (msg);} Asynchronous thread: void consume () {Message msg = queue.take (); while (msg! = null) {HttpClient.post (msg); msg = queue.take ();}}
The code for the specific number of delivery is as follows (with the number of lines added):
38 public void consume (Map msg) {39 HttpClient httpClient = new HttpClient (cm); 40 PostMethod method = new PostMethod (uri); 41 method.addRequestHeader ("context-type", "application/x-www-form-urlencoded"); 42 JSONObject json = new JSONObject (msg); 43 NameValuePair [] params = new NameValuePair [2]; 44 params [0] = new NameValuePair ("topic", topic) 45 params [1] = new NameValuePair ("value", json.toJSONString ()); 46 / / System.out.println (msg.toString ()); 47 logger.info ("BigDataHttp Send Json:" + json.toJSONString ()); 48 method.addParameters (params); 49 try {5051 httpClient.executeMethod (method) 52 if (method.getStatusCode () = 200) {53 logger.info ("BigDataHttp response (Success):" + method.getResponseBodyAsString ()); 54} else {55 logger.info ("BigDataHttp Response (error):" + method.getResponseBodyAsString ()); 56} 57} catch (Exception e) {58 logger.error (e.getMessage (), e); 59} finally {60 method.releaseConnection () 61} 62}
No anomalies in try are found in the log, but unfortunately, although our log is at the info level, because the log volume is too large, only the log of sending and sending messages is opened, and all other logs are closed.
Now that the log level cannot be adjusted, is there any way to determine whether the request returned 200 or other values?
You can use the online debugging tool Arthas, and we use the trace function of Arthas to see the detailed steps that this class performs.
First connect to the JVM process, where pid is the process number.
Java-jar arthas-boot.jar pid
And then execute the command.
Trace xxx.util.bigDataUtil.BigDataHttpConsumer consume
The left and right side of this command is to track the execution of the consume method in the xxx.util.bigDataUtil.BigDataHttpConsumer class.
The result of the execution is as follows, the last line of each line is the number of lines of code, which we can see corresponds to the above code one by one.
As you can see from the code, if the return code is 200, it will execute line 52, and if the return code is not 200, it will execute 55 lines, so we can determine which statement was executed through the trace function, we can know whether 200 is returned or not, and from the result, it is determined that the return is not 200.
In this way, we have conclusive evidence that a non-200 is returned when it is sent to the backend, and the background colleagues check their configuration and find that the configuration is wrong, which is their own fault.
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.