Skip to content

Commit

Permalink
8244508: JFR: FlightRecorderOptions reset date format
Browse files Browse the repository at this point in the history
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed May 8, 2020
1 parent e544a6a commit f351901
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 13 deletions.
6 changes: 4 additions & 2 deletions src/hotspot/share/jfr/dcmd/jfrDcmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ JfrConfigureFlightRecorderDCmd::JfrConfigureFlightRecorderDCmd(outputStream* out
_thread_buffer_size("thread_buffer_size", "Size of a thread buffer", "MEMORY SIZE", false, "8k"),
_memory_size("memorysize", "Overall memory size, ", "MEMORY SIZE", false, "10m"),
_max_chunk_size("maxchunksize", "Size of an individual disk chunk", "MEMORY SIZE", false, "12m"),
_sample_threads("samplethreads", "Activate Thread sampling", "BOOLEAN", false, "true") {
_sample_threads("samplethreads", "Activate Thread sampling", "BOOLEAN", false, "true"),
_verbose(true) {
_dcmdparser.add_dcmd_option(&_repository_path);
_dcmdparser.add_dcmd_option(&_dump_path);
_dcmdparser.add_dcmd_option(&_stack_depth);
Expand Down Expand Up @@ -650,14 +651,15 @@ void JfrConfigureFlightRecorderDCmd::execute(DCmdSource source, TRAPS) {

static const char klass[] = "jdk/jfr/internal/dcmd/DCmdConfigure";
static const char method[] = "execute";
static const char signature[] = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;"
static const char signature[] = "(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/Integer;"
"Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;"
"Ljava/lang/Long;Ljava/lang/Boolean;)Ljava/lang/String;";

JfrJavaArguments execute_args(&result, klass, method, signature, CHECK);
execute_args.set_receiver(h_dcmd_instance);

// params
execute_args.push_int(_verbose ? 1 : 0);
execute_args.push_jobject(repository_path);
execute_args.push_jobject(dump_path);
execute_args.push_jobject(stack_depth);
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/jfr/dcmd/jfrDcmds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ class JfrConfigureFlightRecorderDCmd : public DCmdWithParser {
DCmdArgument<MemorySizeArgument> _memory_size;
DCmdArgument<MemorySizeArgument> _max_chunk_size;
DCmdArgument<bool> _sample_threads;
bool _verbose;

public:
JfrConfigureFlightRecorderDCmd(outputStream* output, bool heap);
void set_verbose(bool verbose) {
_verbose = verbose;
}
static const char* name() {
return "JFR.configure";
}
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ bool JfrOptionSet::configure(TRAPS) {
configure._sample_threads.set_is_set(_dcmd_sample_threads.is_set());
configure._sample_threads.set_value(_dcmd_sample_threads.value());

configure.set_verbose(false);
configure.execute(DCmd_Source_Internal, THREAD);

if (HAS_PENDING_EXCEPTION) {
Expand Down
42 changes: 31 additions & 11 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
import jdk.jfr.internal.Options;
import jdk.jfr.internal.PlatformRecorder;
import jdk.jfr.internal.PrivateAccess;
import jdk.jfr.internal.Repository;
import jdk.jfr.internal.SecuritySupport.SafePath;
Expand Down Expand Up @@ -62,6 +61,7 @@ final class DCmdConfigure extends AbstractDCmd {
*/
public String execute
(
boolean verbose,
String repositoryPath,
String dumpPath,
Integer stackDepth,
Expand Down Expand Up @@ -99,66 +99,86 @@ final class DCmdConfigure extends AbstractDCmd {
} catch (Exception e) {
throw new DCmdException("Could not use " + repositoryPath + " as repository. " + e.getMessage(), e);
}
printRepositoryPath();
if (verbose) {
printRepositoryPath();
}
updated = true;
}

if (dumpPath != null) {
Options.setDumpPath(new SafePath(dumpPath));
Logger.log(LogTag.JFR, LogLevel.INFO, "Emergency dump path set to " + dumpPath);
printDumpPath();
if (verbose) {
printDumpPath();
}
updated = true;
}

if (stackDepth != null) {
Options.setStackDepth(stackDepth);
Logger.log(LogTag.JFR, LogLevel.INFO, "Stack depth set to " + stackDepth);
printStackDepth();
if (verbose) {
printStackDepth();
}
updated = true;
}

if (globalBufferCount != null) {
Options.setGlobalBufferCount(globalBufferCount);
Logger.log(LogTag.JFR, LogLevel.INFO, "Global buffer count set to " + globalBufferCount);
printGlobalBufferCount();
if (verbose) {
printGlobalBufferCount();
}
updated = true;
}

if (globalBufferSize != null) {
Options.setGlobalBufferSize(globalBufferSize);
Logger.log(LogTag.JFR, LogLevel.INFO, "Global buffer size set to " + globalBufferSize);
printGlobalBufferSize();
if (verbose) {
printGlobalBufferSize();
}
updated = true;
}

if (threadBufferSize != null) {
Options.setThreadBufferSize(threadBufferSize);
Logger.log(LogTag.JFR, LogLevel.INFO, "Thread buffer size set to " + threadBufferSize);
printThreadBufferSize();
if (verbose) {
printThreadBufferSize();
}
updated = true;
}

if (memorySize != null) {
Options.setMemorySize(memorySize);
Logger.log(LogTag.JFR, LogLevel.INFO, "Memory size set to " + memorySize);
printMemorySize();
if (verbose) {
printMemorySize();
}
updated = true;
}

if (maxChunkSize != null) {
Options.setMaxChunkSize(maxChunkSize);
Logger.log(LogTag.JFR, LogLevel.INFO, "Max chunk size set to " + maxChunkSize);
printMaxChunkSize();
if (verbose) {
printMaxChunkSize();
}
updated = true;
}

if (sampleThreads != null) {
Options.setSampleThreads(sampleThreads);
Logger.log(LogTag.JFR, LogLevel.INFO, "Sample threads set to " + sampleThreads);
printSampleThreads();
if (verbose) {
printSampleThreads();
}
updated = true;
}

if (!verbose) {
return "";
}
if (!updated) {
println("Current configuration:");
println();
Expand Down
40 changes: 40 additions & 0 deletions test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package jdk.jfr.startupargs;

import java.io.IOException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

/**
* @test
* @summary Checks that locale is respected when using -XX:FlightRecorderOptions
* See JDK-8244508
* @key jfr
* @requires vm.hasJFR
* @modules jdk.jfr
* @library /test/lib
* @run main jdk.jfr.startupargs.TestOptionsWithLocale
*/
public class TestOptionsWithLocale {

public static class PrintDate {
public static void main(String... args) {
GregorianCalendar date = new GregorianCalendar(2020, Calendar.JANUARY, 1);
DateFormat formatter = DateFormat.getDateTimeInstance();
System.out.println(formatter.format(date.getTime()));
}
}

public static void main(String... args) throws IOException {
ProcessBuilder pb = ProcessTools.createTestJvm(
"-Duser.country=DE",
"-Duser.language=de",
"-XX:FlightRecorderOptions:stackdepth=128",
PrintDate.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("01.01.2020, 00:00:00");
}
}

0 comments on commit f351901

Please sign in to comment.