In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "summing up the two pots that have happened online recently". In the daily operation, I believe many people have doubts in summarizing the problems of the two pots that occurred recently online. The editor consulted all kinds of data and sorted out the simple and useful operation methods. I hope it will be helpful for you to answer the doubts of "summing up the two pots that have occurred online recently". Next, please follow the editor to study!
= = and equals
With regard to the difference between = and equals, I believe that students who have been developing for a little bit for a year or two should know very well, however, this hole still occurs frequently in many development times, why? Because sometimes some students think that there is no difference, just use =, however, some accidents always come as expected.
Not long ago, we had a little problem due to the switching of online RPC frames.
Originally, the online interface is defined like this:
Then, an enumerated type is used in the interface query to get the enumerated value based on id, but here the = = sign is used to determine.
How to write the caller:
Originally, this code has been running online for two years, and there is no problem at all. How can it suddenly fail?
However, after switching the frame, this interface reported an error. At that time, I also looked at this place for a long time and guessed that it was the problem here, but I didn't seem to think about it.
Finally, it is found that valueOf is used in the transmission of the original RPC framework, and the judgment can be passed by taking values from the cache and automatically packing and unpacking. However, the new framework uses new Byte (), so the old code will never pass because it is a new object.
Look at the results of this test.
Later, we scanned all the code uniformly by installing the Alibaba Java Coding Guidelines plug-in, and found another gimmick.
This is written differently. This enumeration simply defines the code member variable as the byte base type, not the wrapper type. In this way, the code uses the = = judgment to OK again.
Fool the father 1
Imagine that, because it is the basic data type, the = = judgment is of course passed after unpacking.
There is a more bizarre way to write, the member variable is the Byte wrapper type, getEnumByCode (byte code) here is the base type, of course, this way of writing can also be judged.
Fool the father 2
So, my heart is tired.
Finally, I'd like to add a little more knowledge about basic data type caching. The reason why you can judge with = = is also dependent on the cache.
Data type wrapper type cache type cache value range byteByteByteCache-128~127shortShortShortCache-128~127intIntegerIntegerCache-128~127longLongLongCache-128~127charCharacterCharacterCache0~127
Finally, I would like to advise you to use equals to judge the basic data types in the project, because even if you are sure that this code is right now, you never know what will happen next! Don't take any chances.
The log is full.
Shortly after the technical transformation of the project was put online, it was found that the success rate of the interface directly dropped by 0 (the alarm monitoring that fell by 0 must be available, or you don't know how to die). Check for a long time, look at everything else is normal, and finally found that GC time-consuming soaring, log on to the server, it is unexpectedly that the hard disk is full.
Then decisively look at the log, because our hard drive is actually very small, first doubt the log, sure enough, the log exploded. View the file size through ls-lht.
After deleting through rm-rf, it was found that the hard disk space was not freed. This problem does not normally occur, but it will be a problem if the file is locked or if another process is writing data to the file.
In Linux, a file stored in the file system consists of two parts:
Pointer part: the pointer is located in the meta-data of the file system, and after the data is deleted, the pointer is removed from the meta-data.
Data part: while the data part is stored in disk.
As in the case above, although we removed the service.log, the pointer was not removed from the meta-data because the process was locked, so we can see that the storage space has not been freed.
There are two solutions:
Use lsof-n | grep delete to check what process is writing service.log. Through the command, it is found that our java process has been writing files, and then restart the application directly through the background tool. After restart, it is found that it has returned to normal.
Empty the log file and execute the command echo "> / service.log. This method frees up disk space immediately, and the process continues to write to the log without being affected.
At this point, the study on "summing up the two pots that have happened online recently" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.