Skip to content

Commit 98683de

Browse files
authored
Merge pull request #9 from smiklosovic/CASSANDRA-20854
few nits
2 parents 52c1ed0 + 4ba1c10 commit 98683de

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.attach_pid1466907

Whitespace-only changes.

src/java/org/apache/cassandra/service/AsyncProfilerService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static String parseEvents(String rawString)
9191

9292
public enum AsyncProfilerFormat
9393
{
94-
flat, traces, collapsed, flamegraph, tree, jfr, otlp;
94+
flat, traces, collapsed, flamegraph, tree, jfr;
9595

9696
public static String parseFormat(String rawFormat)
9797
{
@@ -148,10 +148,6 @@ public synchronized AsyncProfiler maybeInitialize()
148148
{
149149
profilerInstance = one.profiler.AsyncProfiler.getInstance();
150150
}
151-
catch (ConfigurationException ex)
152-
{
153-
throw ex;
154-
}
155151
catch (Throwable t)
156152
{
157153
throw new IllegalStateException("Unable to get an instance of Async-Profiler", t);

src/java/org/apache/cassandra/tools/nodetool/AsyncProfileCommandGroup.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import org.apache.cassandra.io.util.File;
2828
import org.apache.cassandra.io.util.FileUtils;
2929
import org.apache.cassandra.profiler.AsyncProfilerMBean;
30-
import org.apache.cassandra.tools.NodeProbe;
3130
import org.apache.cassandra.service.AsyncProfilerService.AsyncProfilerEvent;
3231
import org.apache.cassandra.service.AsyncProfilerService.AsyncProfilerFormat;
32+
import org.apache.cassandra.tools.NodeProbe;
3333
import org.apache.cassandra.utils.FBUtilities;
3434
import picocli.CommandLine.Command;
3535
import picocli.CommandLine.Option;
@@ -64,7 +64,7 @@ public void execute(NodeProbe probe)
6464
cmd.run();
6565
}
6666

67-
public static void doWithProfiler(NodeProbe probe, Consumer<AsyncProfilerMBean> consumer, boolean requiresEnabledProfiler)
67+
private static void doWithProfiler(NodeProbe probe, Consumer<AsyncProfilerMBean> consumer, boolean requiresEnabledProfiler)
6868
{
6969
AsyncProfilerMBean profiler = probe.getAsyncProfilerProxy();
7070

@@ -77,6 +77,19 @@ public static void doWithProfiler(NodeProbe probe, Consumer<AsyncProfilerMBean>
7777
consumer.accept(profiler);
7878
}
7979

80+
private static String getOutputFileName(AsyncProfilerFormat outputFormat)
81+
{
82+
String filename = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss")
83+
.withZone(ZoneId.systemDefault()).format(FBUtilities.now());
84+
85+
if (outputFormat == AsyncProfilerFormat.jfr)
86+
filename += ".jfr";
87+
else
88+
filename += ".html";
89+
90+
return filename;
91+
}
92+
8093
public static void doWithProfiler(NodeProbe probe, Consumer<AsyncProfilerMBean> consumer)
8194
{
8295
doWithProfiler(probe, consumer, true);
@@ -92,15 +105,14 @@ public static class AsyncProfileStartCommand extends AbstractCommand
92105

93106
@Option(names = { "-o", "--output" }, description = "File name to save profiling results into, defaults to a " +
94107
"file of name 'yyyy-MM-dd-HH-mm-ss.html'")
95-
public String filename = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss")
96-
.withZone(ZoneId.systemDefault()).format(FBUtilities.now()) + ".html";
108+
public String filename;
97109

98110
@Option(names = { "-d", "--duration" }, description = "Duration of profiling, defaults to '60s'. Accepts string values " +
99111
"in the form of '5m', '30s' and similar.")
100112
public String duration = "60s";
101113

102114
@Option(names = { "-f", "--format" },
103-
description = "Output format, one of 'flat', 'traces', 'collapsed', 'flamegraph', 'tree', 'jfr', 'otlp', defaults to 'flamegraph'")
115+
description = "Output format, one of 'flat', 'traces', 'collapsed', 'flamegraph', 'tree', 'jfr', defaults to 'flamegraph'")
104116
public AsyncProfilerFormat outputFormat = AsyncProfilerFormat.flamegraph;
105117

106118
@Override
@@ -109,6 +121,9 @@ public void execute(NodeProbe probe)
109121
// make sure it is valid
110122
parseDuration(duration);
111123

124+
if (filename == null)
125+
filename = AsyncProfileCommandGroup.getOutputFileName(outputFormat);
126+
112127
doWithProfiler(probe, profiler -> {
113128
if (!profiler.start(event.stream().map(Enum::name).collect(joining(",")),
114129
outputFormat.name(),

0 commit comments

Comments
 (0)