About WebLogic server restart or log rotation cause server.log I node number change q

Source: Internet
Author: User

About WebLogic server reboot or log rotation causing server.log i node number change

A couple of days ago, my colleague asked me a question, that is, when the client was using Tivoli to analyze the WebLogic server log, when the server restarted, Tivoli went wrong, saying that Fileid is changed. It was suspected to be related to the Inodenumber of server log. The code for WebLogic server logging is not very well recognized because it has not been carefully read. With colleagues said, let the customer through the ls-i to confirm the corresponding inodenumber. Customer feedback said: Inodenumber did not change, crash, filename unchanged, inodenumber unchanged, Tivoli said Fileid what is it? Is there anything else in the filesystem that identifies files? I'm starting to wonder about this client, hehe. Simply, do a test yourself.

First look at the WebLogic code, log rotation, just call the File.renameto (), as follows:

Weblogic.loggin.FileStreamHandler.rotateLog ()

Logfile.renameto (Rotatedfile)

Damn it, rename's over. Inodenumber still have the same reason? Look at the JDK code again,

File.renameto ()

1     public boolean renameTo(File dest) {
2                 SecurityManager security = System.getSecurityManager();
3                 if (security != null) {
4                     security.checkWrite(path);
5                     security.checkWrite(dest.path);
6                 }
7                 return fs.rename(this,dest);
8     }

This guy, or rely on the filesystem, and then look, filesystem is an abstract class, rename specific implementation must be related to the specific subclass, can only see Win32filesystem bar,

Win32filesystem.java

1     public boolean rename(File f1,File f2) {
2         // Keep canonicalization caches in sync after file deletion
3         // and renaming operations. Could be more clever than this
4         // (i.e.,only remove/update affected entries) but probably
5         // not worth it since these entries expire after 30 seconds
6         // anyway.
7         cache.clear();
8         prefixCache.clear();
9         return rename0(f1,f2);
10     }
11     private native boolean rename0(File f1,File f2);

OK, now you see, RENAME0 () is a native operation, and it's related to the shared library (. dll or. so). , there is no local library code, also see what is implemented (but personally, the local implementation call should be the system function Rename:int rename (const char *old,const char *new)), can only do the implementation. wrote a small test program, as follows:

1 Package com.bea.cs.test.file
2
3 import java.io.File
4
5 public class Filetest {
6
7 Private File src = new file ("test");          
8
9 public static void Main (String args[])
Ten {
Filetest test = new Filetest ()
12 Test.run ();
13}
M
public void run ()
{
Rename ("Test1");
[}
'
' private b Oolean Rename (String name)
{
Boolean ret = false;
File Dest = new file (name);
ret = Src.renameto (dest);
/*
* as SRC is renamed to Dest,dest should hold the inodenumber of SRC
27 */< br> src = new File ("test");
Try
{
*/*
* As has been renamed to DEST,SRC should no T exist again
* So we should create a new src file,or it'll disappear when
EST exits.              As a new file,src shuold get a new Inodenumber
the different from it ' s original value
36  */
Notoginseng if (!src.exists ())
Src.createnewfile ();
}catch (Exception e)
{
E.printstacktrace ();
"
" return ret;
"

The results of the test are as follows:

Test Reustlslsol6% ls -il
total 8
6033508 drwxr-xr-x   3 fjin     staff       4096 Sep 26 23:48 com
6033514 -rw-r--r--   1 fjin     staff          0 Sep 26 23:56 test
slsol6% java com.bea.cs.test.file.FileTest
slsol6% ls -il
total 8
6033508 drwxr-xr-x   3 fjin     staff       4096 Sep 26 23:48 com
6033506 -rw-r--r--   1 fjin     staff          0 Sep 27 01:03 test
6033514 -rw-r--r--   1 fjin     staff          0 Sep 26 23:56 test1

Now that I can doubt the client, the Tivoli error should be normal (Work as design), but what's more puzzling is: Why does Tivoli refer to Fileid instead of filename? Start by changing WebLogic code to invoke a copy-like operation instead of a rename. The result is that file does not provide a similar API, and if you do so, emptying the original file content is a problem, so forget it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.