8276687: Remove support for JDK 1.4.1 PerfData shared memory files
Reviewed-by: dholmes, kevinw, redestad
This commit is contained in:
parent
b30d922009
commit
67046ae49a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,7 +44,6 @@ import java.io.*;
|
||||
public class LocalVmManager {
|
||||
private FilenameFilter userDirFilter;
|
||||
private FilenameFilter userDirFileFilter;
|
||||
private FilenameFilter oldtmpFileFilter;
|
||||
|
||||
/**
|
||||
* Creates a LocalVmManager instance for the local system.
|
||||
@ -53,7 +52,7 @@ public class LocalVmManager {
|
||||
* has appropriate permissions.
|
||||
*/
|
||||
public LocalVmManager() {
|
||||
// 1.4.2 and later: The files are in {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
|
||||
// The files are in {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
|
||||
Pattern userDirPattern = Pattern.compile(PerfDataFile.userDirNamePattern);
|
||||
userDirFilter = new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
@ -67,15 +66,6 @@ public class LocalVmManager {
|
||||
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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,7 +90,7 @@ public class LocalVmManager {
|
||||
}
|
||||
|
||||
|
||||
// 1.4.2 and later: Look for the files {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
|
||||
// Look for the files {tmpdir}/hsperfdata_{any_user_name}/[0-9]+
|
||||
// that are readable by the current user.
|
||||
File[] dirs = tmpdir.listFiles(userDirFilter);
|
||||
for (File subDir : dirs) {
|
||||
@ -121,20 +111,6 @@ 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;
|
||||
}
|
||||
|
@ -61,33 +61,8 @@ public class PerfDataBuffer extends AbstractPerfDataBuffer {
|
||||
*/
|
||||
public PerfDataBuffer(VmIdentifier vmid) throws MonitorException {
|
||||
try {
|
||||
// Try 1.4.2 and later first
|
||||
ByteBuffer bb = perf.attach(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) {
|
||||
throw new MonitorException("Could not attach to "
|
||||
+ vmid.getLocalVmId(), e);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -64,20 +64,11 @@ public class PerfDataFile {
|
||||
* The file name pattern for PerfData shared memory files.
|
||||
* <p>
|
||||
* This pattern must be kept in synch with the file name pattern
|
||||
* used by the 1.4.2 and later HotSpot JVM.
|
||||
* used by the 1.4.2 and later HotSpot JVM. Earlier versions are
|
||||
* no longer supported.
|
||||
*/
|
||||
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
|
||||
* and process IDs.
|
||||
@ -97,24 +88,10 @@ public class PerfDataFile {
|
||||
*/
|
||||
public static int getLocalVmId(File file) {
|
||||
try {
|
||||
// try 1.4.2 and later format first
|
||||
return(platSupport.getLocalVmId(file));
|
||||
} catch (NumberFormatException e) { }
|
||||
|
||||
// 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");
|
||||
throw new IllegalArgumentException("Cannot convert '" + file + "' to VM id");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user