Java Code Examples for jdk.jfr.internal.SecuritySupport.SafePath#toString()
The following examples show how to use
jdk.jfr.internal.SecuritySupport.SafePath#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Repository.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static SafePath createRealBasePath(SafePath safePath) throws Exception { if (SecuritySupport.exists(safePath)) { if (!SecuritySupport.isWritable(safePath)) { throw new IOException("JFR repository directory (" + safePath.toString() + ") exists, but isn't writable"); } return SecuritySupport.toRealPath(safePath); } SafePath p = SecuritySupport.createDirectories(safePath); return SecuritySupport.toRealPath(p); }
Example 2
Source File: Repository.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static SafePath createRealBasePath(SafePath safePath) throws Exception { if (SecuritySupport.exists(safePath)) { if (!SecuritySupport.isWritable(safePath)) { throw new IOException("JFR repository directory (" + safePath.toString() + ") exists, but isn't writable"); } return SecuritySupport.toRealPath(safePath); } SafePath p = SecuritySupport.createDirectories(safePath); return SecuritySupport.toRealPath(p); }
Example 3
Source File: Repository.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static SafePath createRealBasePath(SafePath safePath) throws Exception { if (SecuritySupport.exists(safePath)) { if (!SecuritySupport.isWritable(safePath)) { throw new IOException("JFR repository directory (" + safePath.toString() + ") exists, but isn't writable"); } return SecuritySupport.toRealPath(safePath); } SafePath p = SecuritySupport.createDirectories(safePath); return SecuritySupport.toRealPath(p); }
Example 4
Source File: TestReconstruct.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("resource") public static void main(String[] args) throws Exception { // Create some disk recordings Recording[] recordings = new Recording[5]; for (int i = 0; i < RECORDING_COUNT; i++) { Recording r = new Recording(); r.setToDisk(true); r.start(); CorrelationEvent ce = new CorrelationEvent(); ce.id = i; ce.commit(); r.stop(); recordings[i] = r; } Path dir = Paths.get("reconstruction-parts"); Files.createDirectories(dir); long expectedCount = 0; for (int i = 0; i < RECORDING_COUNT; i++) { Path tmp = dir.resolve("chunk-part-" + i + ".jfr"); recordings[i].dump(tmp); expectedCount += countEventInRecording(tmp); } SafePath repository = Repository.getRepository().getRepositoryPath(); Path destinationPath = Paths.get("reconstructed.jfr"); String directory = repository.toString(); String destination = destinationPath.toAbsolutePath().toString(); // Test failure OutputAnalyzer output = ExecuteHelper.run("reconstruct"); output.shouldContain("Too few arguments"); output = ExecuteHelper.run("reconstruct", directory); output.shouldContain("Too few arguments"); output = ExecuteHelper.run("reconstruct", "not-a-directory", destination); output.shouldContain("Could not find disk repository at"); output = ExecuteHelper.run("reconstruct", directory, "not-a-destination"); output.shouldContain("Filename must end with .jfr"); output = ExecuteHelper.run("reconstruct", "--wrongOption", directory, destination); output.shouldContain("Too many arguments"); FileWriter fw = new FileWriter(destination); fw.write('d'); fw.close(); output = ExecuteHelper.run("reconstruct", directory, destination); output.shouldContain("already exists"); Files.delete(destinationPath); // test success output = ExecuteHelper.run("reconstruct", directory, destination); System.out.println(output.getOutput()); output.shouldContain("Reconstruction complete"); long reconstructedCount = countEventInRecording(destinationPath); Asserts.assertEquals(expectedCount, reconstructedCount); // Cleanup for (int i = 0; i < RECORDING_COUNT; i++) { recordings[i].close(); } }
Example 5
Source File: TestAssemble.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("resource") public static void main(String[] args) throws Throwable { // Create some disk recordings Recording[] recordings = new Recording[5]; for (int i = 0; i < RECORDING_COUNT; i++) { Recording r = new Recording(); r.setToDisk(true); r.start(); CorrelationEvent ce = new CorrelationEvent(); ce.id = i; ce.commit(); r.stop(); recordings[i] = r; } Path dir = Paths.get("reconstruction-parts"); Files.createDirectories(dir); long expectedCount = 0; for (int i = 0; i < RECORDING_COUNT; i++) { Path tmp = dir.resolve("chunk-part-" + i + ".jfr"); recordings[i].dump(tmp); expectedCount += countEventInRecording(tmp); } SafePath repository = Repository.getRepository().getRepositoryPath(); Path destinationPath = Paths.get("reconstructed.jfr"); String directory = repository.toString(); String destination = destinationPath.toAbsolutePath().toString(); // Test failure OutputAnalyzer output = ExecuteHelper.jfr("assemble"); output.shouldContain("too few arguments"); output = ExecuteHelper.jfr("assemble", directory); output.shouldContain("too few arguments"); output = ExecuteHelper.jfr("assemble", "not-a-directory", destination); output.shouldContain("directory does not exist, not-a-directory"); output = ExecuteHelper.jfr("assemble", directory, "not-a-destination"); output.shouldContain("filename must end with '.jfr'"); output = ExecuteHelper.jfr("assemble", "--wrongOption", directory, destination); output.shouldContain("too many arguments"); FileWriter fw = new FileWriter(destination); fw.write('d'); fw.close(); output = ExecuteHelper.jfr("assemble", directory, destination); output.shouldContain("already exists"); Files.delete(destinationPath); // test success output = ExecuteHelper.jfr("assemble", directory, destination); System.out.println(output.getOutput()); output.shouldContain("Finished."); long reconstructedCount = countEventInRecording(destinationPath); Asserts.assertEquals(expectedCount, reconstructedCount); // Cleanup for (int i = 0; i < RECORDING_COUNT; i++) { recordings[i].close(); } }
Example 6
Source File: TestAssemble.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("resource") public static void main(String[] args) throws Throwable { // Create some disk recordings Recording[] recordings = new Recording[5]; for (int i = 0; i < RECORDING_COUNT; i++) { Recording r = new Recording(); r.setToDisk(true); r.start(); CorrelationEvent ce = new CorrelationEvent(); ce.id = i; ce.commit(); r.stop(); recordings[i] = r; } Path dir = Paths.get("reconstruction-parts"); Files.createDirectories(dir); long expectedCount = 0; for (int i = 0; i < RECORDING_COUNT; i++) { Path tmp = dir.resolve("chunk-part-" + i + ".jfr"); recordings[i].dump(tmp); expectedCount += countEventInRecording(tmp); } SafePath repository = Repository.getRepository().getRepositoryPath(); Path destinationPath = Paths.get("reconstructed.jfr"); String directory = repository.toString(); String destination = destinationPath.toAbsolutePath().toString(); // Test failure OutputAnalyzer output = ExecuteHelper.jfr("assemble"); output.shouldContain("too few arguments"); output = ExecuteHelper.jfr("assemble", directory); output.shouldContain("too few arguments"); output = ExecuteHelper.jfr("assemble", "not-a-directory", destination); output.shouldContain("directory does not exist, not-a-directory"); output = ExecuteHelper.jfr("assemble", directory, "not-a-destination"); output.shouldContain("filename must end with '.jfr'"); output = ExecuteHelper.jfr("assemble", "--wrongOption", directory, destination); output.shouldContain("too many arguments"); FileWriter fw = new FileWriter(destination); fw.write('d'); fw.close(); output = ExecuteHelper.jfr("assemble", directory, destination); output.shouldContain("already exists"); Files.delete(destinationPath); // test success output = ExecuteHelper.jfr("assemble", directory, destination); System.out.println(output.getOutput()); output.shouldContain("Finished."); long reconstructedCount = countEventInRecording(destinationPath); Asserts.assertEquals(expectedCount, reconstructedCount); // Cleanup for (int i = 0; i < RECORDING_COUNT; i++) { recordings[i].close(); } }