1 package org
.lttng
.ust
.agent
.jul
.benchmarks
.utils
;
3 import java
.io
.IOException
;
4 import java
.lang
.ProcessBuilder
.Redirect
;
6 public final class LttngSessionControl
{
8 private LttngSessionControl() {}
10 public static boolean setupJulSessionNoEvents() {
11 return executeCommands(new String
[][] {
12 { "lttng", "create" },
14 * We have to enable a channel for 'lttng start' to work.
15 * However, we cannot enable a channel directly, see
16 * https://bugs.lttng.org/issues/894 . Instead we will enable an
17 * event we know does not exist
19 { "lttng", "enable-event", "-j", "non-event" },
24 public static boolean setupJulSessionAllEvents() {
25 return executeCommands(new String
[][] {
26 { "lttng", "create" },
27 { "lttng", "enable-event", "-j", "-a" },
32 public static boolean stopSession() {
33 return executeCommand(new String
[] { "lttng", "stop" });
36 public static boolean destroySession() {
37 return executeCommand(new String
[] { "lttng", "destroy" });
40 private static boolean executeCommands(String
[][] commands
) {
41 for (String
[] command
: commands
) {
42 if (executeCommand(command
) == false) {
49 public static void main(String
[] args
) {
50 executeCommand(new String
[] {"ls", "-l"});
53 private static boolean executeCommand(String
[] command
) {
55 ProcessBuilder builder
= new ProcessBuilder(command
);
56 builder
.redirectErrorStream(true);
57 builder
.redirectOutput(Redirect
.INHERIT
);
59 Process p
= builder
.start();
60 int ret
= p
.waitFor();
62 } catch (IOException
| InterruptedException e
) {
This page took 0.032759 seconds and 5 git commands to generate.