8295320: [BACKOUT] 8276687 Remove support for JDK 1.4.1 PerfData shared memory files
Reviewed-by: redestad, kevinw
This commit is contained in:
parent
2da079c64e
commit
dfcd9d538e
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,6 +44,7 @@ import java.io.*;
|
|||||||
public class LocalVmManager {
|
public class LocalVmManager {
|
||||||
private FilenameFilter userDirFilter;
|
private FilenameFilter userDirFilter;
|
||||||
private FilenameFilter userDirFileFilter;
|
private FilenameFilter userDirFileFilter;
|
||||||
|
private FilenameFilter oldtmpFileFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a LocalVmManager instance for the local system.
|
* Creates a LocalVmManager instance for the local system.
|
||||||
@ -52,7 +53,7 @@ public class LocalVmManager {
|
|||||||
* has appropriate permissions.
|
* has appropriate permissions.
|
||||||
*/
|
*/
|
||||||
public LocalVmManager() {
|
public LocalVmManager() {
|
||||||
// The files are in {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
|
// 1.4.2 and later: The files are in {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
|
||||||
Pattern userDirPattern = Pattern.compile(PerfDataFile.userDirNamePattern);
|
Pattern userDirPattern = Pattern.compile(PerfDataFile.userDirNamePattern);
|
||||||
userDirFilter = new FilenameFilter() {
|
userDirFilter = new FilenameFilter() {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
@ -66,6 +67,15 @@ public class LocalVmManager {
|
|||||||
return userDirFilePattern.matcher(name).matches();
|
return userDirFilePattern.matcher(name).matches();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 1.4.1 (or earlier?): the files are stored directly under {tmpdir}/ with
|
||||||
|
// the following pattern.
|
||||||
|
Pattern oldtmpFilePattern = Pattern.compile(PerfDataFile.tmpFileNamePattern);
|
||||||
|
oldtmpFileFilter = new FilenameFilter() {
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
return oldtmpFilePattern.matcher(name).matches();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +100,7 @@ public class LocalVmManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Look for the files {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
|
// 1.4.2 and later: Look for the files {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
|
||||||
// that are readable by the current user.
|
// that are readable by the current user.
|
||||||
File[] dirs = tmpdir.listFiles(userDirFilter);
|
File[] dirs = tmpdir.listFiles(userDirFilter);
|
||||||
for (File subDir : dirs) {
|
for (File subDir : dirs) {
|
||||||
@ -111,6 +121,20 @@ public class LocalVmManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// look for any 1.4.1 files that are readable by the current user.
|
||||||
|
File[] files = tmpdir.listFiles(oldtmpFileFilter);
|
||||||
|
if (files != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
if (file.isFile() && file.canRead()) {
|
||||||
|
int vmid = PerfDataFile.getLocalVmId(file);
|
||||||
|
if (vmid != -1) {
|
||||||
|
jvmSet.add(vmid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return jvmSet;
|
return jvmSet;
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,33 @@ public class PerfDataBuffer extends AbstractPerfDataBuffer {
|
|||||||
*/
|
*/
|
||||||
public PerfDataBuffer(VmIdentifier vmid) throws MonitorException {
|
public PerfDataBuffer(VmIdentifier vmid) throws MonitorException {
|
||||||
try {
|
try {
|
||||||
|
// Try 1.4.2 and later first
|
||||||
ByteBuffer bb = perf.attach(vmid.getLocalVmId());
|
ByteBuffer bb = perf.attach(vmid.getLocalVmId());
|
||||||
createPerfDataBuffer(bb, vmid.getLocalVmId());
|
createPerfDataBuffer(bb, vmid.getLocalVmId());
|
||||||
|
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// now try 1.4.1 by attempting to directly map the files.
|
||||||
|
try {
|
||||||
|
String filename = PerfDataFile.getTempDirectory()
|
||||||
|
+ PerfDataFile.dirNamePrefix
|
||||||
|
+ Integer.toString(vmid.getLocalVmId());
|
||||||
|
|
||||||
|
File f = new File(filename);
|
||||||
|
|
||||||
|
FileChannel fc = new RandomAccessFile(f, "r").getChannel();
|
||||||
|
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0L,
|
||||||
|
(int)fc.size());
|
||||||
|
fc.close();
|
||||||
|
createPerfDataBuffer(bb, vmid.getLocalVmId());
|
||||||
|
|
||||||
|
} catch (FileNotFoundException e2) {
|
||||||
|
// re-throw the exception from the 1.4.2 attach method
|
||||||
|
throw new MonitorException(vmid.getLocalVmId() + " not found",
|
||||||
|
e);
|
||||||
|
} catch (IOException e2) {
|
||||||
|
throw new MonitorException("Could not map 1.4.1 file for "
|
||||||
|
+ vmid.getLocalVmId(), e2);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new MonitorException("Could not attach to "
|
throw new MonitorException("Could not attach to "
|
||||||
+ vmid.getLocalVmId(), e);
|
+ vmid.getLocalVmId(), e);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -64,11 +64,20 @@ public class PerfDataFile {
|
|||||||
* The file name pattern for PerfData shared memory files.
|
* The file name pattern for PerfData shared memory files.
|
||||||
* <p>
|
* <p>
|
||||||
* This pattern must be kept in synch with the file name pattern
|
* This pattern must be kept in synch with the file name pattern
|
||||||
* used by the 1.4.2 and later HotSpot JVM. Earlier versions are
|
* used by the 1.4.2 and later HotSpot JVM.
|
||||||
* no longer supported.
|
|
||||||
*/
|
*/
|
||||||
public static final String fileNamePattern = "^[0-9]+$";
|
public static final String fileNamePattern = "^[0-9]+$";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The file name pattern for 1.4.1 PerfData shared memory files.
|
||||||
|
* <p>
|
||||||
|
* This pattern must be kept in synch with the file name pattern
|
||||||
|
* used by the 1.4.1 HotSpot JVM.
|
||||||
|
*/
|
||||||
|
public static final String tmpFileNamePattern =
|
||||||
|
"^hsperfdata_[0-9]+(_[1-2]+)?$";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform Specific methods for looking up temporary directories
|
* Platform Specific methods for looking up temporary directories
|
||||||
* and process IDs.
|
* and process IDs.
|
||||||
@ -88,10 +97,24 @@ public class PerfDataFile {
|
|||||||
*/
|
*/
|
||||||
public static int getLocalVmId(File file) {
|
public static int getLocalVmId(File file) {
|
||||||
try {
|
try {
|
||||||
|
// try 1.4.2 and later format first
|
||||||
return(platSupport.getLocalVmId(file));
|
return(platSupport.getLocalVmId(file));
|
||||||
} catch (NumberFormatException e) { }
|
} catch (NumberFormatException e) { }
|
||||||
|
|
||||||
throw new IllegalArgumentException("Cannot convert '" + file + "' to VM id");
|
// now try the 1.4.1 format
|
||||||
|
String name = file.getName();
|
||||||
|
if (name.startsWith(dirNamePrefix)) {
|
||||||
|
int first = name.indexOf('_');
|
||||||
|
int last = name.lastIndexOf('_');
|
||||||
|
try {
|
||||||
|
if (first == last) {
|
||||||
|
return Integer.parseInt(name.substring(first + 1));
|
||||||
|
} else {
|
||||||
|
return Integer.parseInt(name.substring(first + 1, last));
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) { }
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("file name does not match pattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user