From ff620befefbb7be90965d845e76bc826eca2d951 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Wed, 29 Jul 2015 23:37:43 -0400 Subject: [PATCH] Provide default createSession() factory method Users may not care what backend is actually used, we can provide a default one. Signed-off-by: Alexandre Montplaisir --- .../java/org/lttng/tools/ILttngSession.java | 20 ++++++++++++++++--- .../org/lttng/tools/utils/LttngUtils.java | 2 +- ...tngJulHandlerTracingDisabledBenchmark.java | 2 +- ...ttngJulHandlerTracingEnabledBenchmark.java | 2 +- ...tngJulHandlerTracingDisabledBenchmark.java | 2 +- ...ttngJulHandlerTracingEnabledBenchmark.java | 2 +- .../integration/EnabledEventsTestBase.java | 2 +- .../integration/MultiSessionTestBase.java | 6 +++--- .../integration/jul/JulLegacyApiTest.java | 2 +- .../integration/log4j/Log4jLegacyApiTest.java | 2 +- 10 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/test/java/org/lttng/tools/ILttngSession.java b/src/test/java/org/lttng/tools/ILttngSession.java index c8b532c..e7d65a0 100644 --- a/src/test/java/org/lttng/tools/ILttngSession.java +++ b/src/test/java/org/lttng/tools/ILttngSession.java @@ -55,8 +55,7 @@ public interface ILttngSession extends AutoCloseable { // ------------------------------------------------------------------------ /** - * Constructor to create a new LTTng tracing session, which will use the - * command-line "lttng" utility. + * Create a new LTTng tracing session using the default backend. * * @param sessionName * The name of the session to use. It can be null, in which case @@ -65,7 +64,22 @@ public interface ILttngSession extends AutoCloseable { * The tracing domain of this session * @return The new session object */ - static ILttngSession newCommandLineSession(String sessionName, Domain domain) { + static ILttngSession createSession(String sessionName, Domain domain) { + return createCommandLineSession(sessionName, domain); + } + + /** + * Create a new LTTng tracing session, which will use the command-line + * "lttng" utility. + * + * @param sessionName + * The name of the session to use. It can be null, in which case + * we will provide a unique random name. + * @param domain + * The tracing domain of this session + * @return The new session object + */ + static ILttngSession createCommandLineSession(String sessionName, Domain domain) { return new LttngCommandLineSession(sessionName, domain); } diff --git a/src/test/java/org/lttng/tools/utils/LttngUtils.java b/src/test/java/org/lttng/tools/utils/LttngUtils.java index 3c1a83f..de7b233 100644 --- a/src/test/java/org/lttng/tools/utils/LttngUtils.java +++ b/src/test/java/org/lttng/tools/utils/LttngUtils.java @@ -78,7 +78,7 @@ public final class LttngUtils { * was an error */ public static boolean checkForLttngTools(Domain domain) { - try (ILttngSession session = ILttngSession.newCommandLineSession(null, domain)) { + try (ILttngSession session = ILttngSession.createSession(null, domain)) { boolean ret1 = session.enableAllEvents(); boolean ret2 = session.start(); boolean ret3 = session.stop(); diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java index 23ab1ee..d0e514c 100644 --- a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java +++ b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java @@ -46,7 +46,7 @@ public class LttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmark public void testSetup() throws IOException { handler = new LttngLogHandler(); - session = ILttngSession.newCommandLineSession(null, Domain.JUL); + session = ILttngSession.createSession(null, Domain.JUL); assertTrue(session.enableEvents("non-event")); assertTrue(session.start()); } diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java index 8e4c37d..c594de4 100644 --- a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java +++ b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java @@ -45,7 +45,7 @@ public class LttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkB public void testSetup() throws IOException { handler = new LttngLogHandler(); - session = ILttngSession.newCommandLineSession(null, Domain.JUL); + session = ILttngSession.createSession(null, Domain.JUL); assertTrue(session.enableAllEvents()); assertTrue(session.start()); } diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java index a3a5c41..112b0f0 100644 --- a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java +++ b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java @@ -43,7 +43,7 @@ public class OldLttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchm public void testSetup() { LTTngAgent.getLTTngAgent(); - session = ILttngSession.newCommandLineSession(null, Domain.JUL); + session = ILttngSession.createSession(null, Domain.JUL); assertTrue(session.enableEvents("non-event")); assertTrue(session.start()); } diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java index 23c6c95..a36578b 100644 --- a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java +++ b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java @@ -69,7 +69,7 @@ public class OldLttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchma fail(); } - session = ILttngSession.newCommandLineSession(null, Domain.JUL); + session = ILttngSession.createSession(null, Domain.JUL); assertTrue(session.enableAllEvents()); assertTrue(session.start()); } diff --git a/src/test/java/org/lttng/ust/agent/integration/EnabledEventsTestBase.java b/src/test/java/org/lttng/ust/agent/integration/EnabledEventsTestBase.java index a04057a..fd72279 100644 --- a/src/test/java/org/lttng/ust/agent/integration/EnabledEventsTestBase.java +++ b/src/test/java/org/lttng/ust/agent/integration/EnabledEventsTestBase.java @@ -61,7 +61,7 @@ public abstract class EnabledEventsTestBase { */ @Before public void testSetup() { - session = ILttngSession.newCommandLineSession(null, getDomain()); + session = ILttngSession.createSession(null, getDomain()); } /** diff --git a/src/test/java/org/lttng/ust/agent/integration/MultiSessionTestBase.java b/src/test/java/org/lttng/ust/agent/integration/MultiSessionTestBase.java index 9976e6a..1efa3a6 100644 --- a/src/test/java/org/lttng/ust/agent/integration/MultiSessionTestBase.java +++ b/src/test/java/org/lttng/ust/agent/integration/MultiSessionTestBase.java @@ -63,9 +63,9 @@ public abstract class MultiSessionTestBase { */ @Before public void testSetup() { - session1 = ILttngSession.newCommandLineSession(null, getDomain()); - session2 = ILttngSession.newCommandLineSession(null, getDomain()); - session3 = ILttngSession.newCommandLineSession(null, getDomain()); + session1 = ILttngSession.createSession(null, getDomain()); + session2 = ILttngSession.createSession(null, getDomain()); + session3 = ILttngSession.createSession(null, getDomain()); } /** diff --git a/src/test/java/org/lttng/ust/agent/integration/jul/JulLegacyApiTest.java b/src/test/java/org/lttng/ust/agent/integration/jul/JulLegacyApiTest.java index b1a7c48..a088bb9 100644 --- a/src/test/java/org/lttng/ust/agent/integration/jul/JulLegacyApiTest.java +++ b/src/test/java/org/lttng/ust/agent/integration/jul/JulLegacyApiTest.java @@ -92,7 +92,7 @@ public class JulLegacyApiTest { loggerA.setLevel(Level.ALL); loggerB.setLevel(Level.ALL); - session = ILttngSession.newCommandLineSession(null, DOMAIN); + session = ILttngSession.createSession(null, DOMAIN); } /** diff --git a/src/test/java/org/lttng/ust/agent/integration/log4j/Log4jLegacyApiTest.java b/src/test/java/org/lttng/ust/agent/integration/log4j/Log4jLegacyApiTest.java index 0f473f9..d9ab7ff 100644 --- a/src/test/java/org/lttng/ust/agent/integration/log4j/Log4jLegacyApiTest.java +++ b/src/test/java/org/lttng/ust/agent/integration/log4j/Log4jLegacyApiTest.java @@ -93,7 +93,7 @@ public class Log4jLegacyApiTest { loggerA.setLevel(Level.ALL); loggerB.setLevel(Level.ALL); - session = ILttngSession.newCommandLineSession(null, DOMAIN); + session = ILttngSession.createSession(null, DOMAIN); } /** -- 2.34.1