From 3cfb6eceb590bb1a98c83c9476c9d75f4ed645b5 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Fri, 7 Sep 2012 08:18:32 -0400 Subject: Allow LTTng Control to connect to LTTng 2.x.y nodes (Bug 388545) Commit includes - Support of remote nodes that have LTTng Tools 2.x.y installed - Display of LTTng Tools version in Properties View - Update JUnit tests Change-Id: I3dd19cf8ded4ffd74a2ff9f92fbd55c8e1b38c4c Signed-off-by: Bernd Hufmann Reviewed-on: https://git.eclipse.org/r/7584 Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Tested-by: Alexandre Montplaisir --- .../component/TraceControlPropertiesTest.java | 1 + .../control/service/LTTngControlServiceTest.java | 2 +- .../testfiles/LTTngServiceTest.cfg | 2 +- .../lttng2/ui/views/control/messages/Messages.java | 1 + .../ui/views/control/messages/messages.properties | 1 + .../control/model/impl/TargetNodeComponent.java | 11 ++++++++ .../control/property/TargetNodePropertySource.java | 33 +++++++++++++++------- .../service/LTTngControlServiceConstants.java | 4 +-- .../service/LTTngControlServiceFactory.java | 9 +++--- 9 files changed, 46 insertions(+), 18 deletions(-) diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java b/lttng/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java index df0eda5e66..3b9f876c2c 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java +++ b/lttng/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java @@ -160,6 +160,7 @@ public class TraceControlPropertiesTest extends TestCase { assertEquals("myNode", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID)); assertEquals("LOCALHOST", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_ADDRESS_PROPERTY_ID)); assertEquals(TargetNodeState.CONNECTED.name(), source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_STATE_PROPERTY_ID)); + assertEquals("2.0.0", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_VERSION_PROPERTY_ID)); assertNull(source.getPropertyValue("test")); adapter = node.getAdapter(IChannelInfo.class); diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java b/lttng/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java index cf0abba697..4bce2d1eb9 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java +++ b/lttng/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java @@ -131,7 +131,7 @@ public class LTTngControlServiceTest extends TestCase { fShell.setScenario(SCEN_LTTNG_VERSION); ILttngControlService service = LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); assertNotNull(service); - assertEquals("2.0.0", service.getVersion()); + assertEquals("2.1.0", service.getVersion()); } catch (ExecutionException e) { fail("Exeption thrown " + e); } diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/LTTngServiceTest.cfg b/lttng/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/LTTngServiceTest.cfg index 42b400447b..283aa488fb 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/LTTngServiceTest.cfg +++ b/lttng/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/LTTngServiceTest.cfg @@ -37,7 +37,7 @@ lttng version 0 -lttng version 2.0.0 - Annedd'ale +lttng version 2.1.0 - Basse Messe Web site: http://lttng.org/ lttng is free software and under the GPL license and part LGPL diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/Messages.java b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/Messages.java index 32629d50d6..de3c0420ed 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/Messages.java +++ b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/Messages.java @@ -201,6 +201,7 @@ final public class Messages extends NLS { public static String TraceControl_EventTypePropertyName; public static String TraceControl_LogLevelPropertyName; public static String TraceControl_StatePropertyName; + public static String TraceControl_VersionPropertyName; public static String TraceControl_DomainNamePropertyName; public static String TraceControl_ChannelNamePropertyName; public static String TraceControl_OverwriteModePropertyName; diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/messages.properties b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/messages.properties index f6b2ed1e01..f0d1e50f0a 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/messages.properties +++ b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/messages.properties @@ -184,6 +184,7 @@ TraceControl_EventNamePropertyName=Event Name TraceControl_EventTypePropertyName=Event Type TraceControl_LogLevelPropertyName=Log Level TraceControl_StatePropertyName=State +TraceControl_VersionPropertyName=Version TraceControl_DomainNamePropertyName=Domain Name TraceControl_ChannelNamePropertyName=Channel Name TraceControl_OverwriteModePropertyName=Overwrite Mode diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TargetNodeComponent.java b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TargetNodeComponent.java index a5d1a0018f..acfb61f4e2 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TargetNodeComponent.java +++ b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TargetNodeComponent.java @@ -207,6 +207,17 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu return new TraceSessionComponent[0]; } + /** + * @return node version + */ + public String getNodeVersion() { + // Control service is null during connection to node + if (getControlService() != null) { + return getControlService().getVersion(); + } + return ""; //$NON-NLS-1$ + } + // ------------------------------------------------------------------------ // Operations // ------------------------------------------------------------------------ diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TargetNodePropertySource.java b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TargetNodePropertySource.java index 1fbb2a71ef..4d82be2620 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TargetNodePropertySource.java +++ b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TargetNodePropertySource.java @@ -1,12 +1,12 @@ /********************************************************************** * Copyright (c) 2012 Ericsson - * + * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: + * + * Contributors: * Bernd Hufmann - Initial API and implementation **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; @@ -20,7 +20,7 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; *

* Property source implementation for the target node component. *

- * + * * @author Bernd Hufmann */ public class TargetNodePropertySource extends BasePropertySource { @@ -41,7 +41,12 @@ public class TargetNodePropertySource extends BasePropertySource { */ public static final String TARGET_NODE_STATE_PROPERTY_ID = "target.node.state"; //$NON-NLS-1$ /** - * The node name property name. + * The node version property ID. + */ + public static final String TARGET_NODE_VERSION_PROPERTY_ID = "target.node.version"; //$NON-NLS-1$ + + /** + * The node name property name. */ public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName; /** @@ -52,15 +57,19 @@ public class TargetNodePropertySource extends BasePropertySource { * The state address property name. */ public static final String TARGET_NODE_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; - + /** + * The node version property name. + */ + public static final String TARGET_NODE_VERSION_PROPERTY_NAME = Messages.TraceControl_VersionPropertyName; + // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ /** - * The node component which this property source is for. + * The node component which this property source is for. */ private final TargetNodeComponent fTargetNode; - + // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ @@ -71,7 +80,7 @@ public class TargetNodePropertySource extends BasePropertySource { public TargetNodePropertySource(TargetNodeComponent component) { fTargetNode = component; } - + // ------------------------------------------------------------------------ // Operations // ------------------------------------------------------------------------ @@ -84,7 +93,8 @@ public class TargetNodePropertySource extends BasePropertySource { return new IPropertyDescriptor[] { new TextPropertyDescriptor(TARGET_NODE_NAME_PROPERTY_ID, TARGET_NODE_NAME_PROPERTY_NAME), new TextPropertyDescriptor(TARGET_NODE_ADDRESS_PROPERTY_ID, TARGET_NODE_ADDRESS_PROPERTY_NAME), - new TextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID, TARGET_NODE_STATE_PROPERTY_NAME)}; + new TextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID, TARGET_NODE_STATE_PROPERTY_NAME), + new TextPropertyDescriptor(TARGET_NODE_VERSION_PROPERTY_ID, TARGET_NODE_VERSION_PROPERTY_NAME)}; } /* @@ -102,6 +112,9 @@ public class TargetNodePropertySource extends BasePropertySource { if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) { return fTargetNode.getTargetNodeState().name(); } + if (TARGET_NODE_VERSION_PROPERTY_ID.equals(id)) { + return fTargetNode.getNodeVersion(); + } return null; } } diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceConstants.java b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceConstants.java index 5e84b86a85..d73ca76e4b 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceConstants.java +++ b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceConstants.java @@ -26,9 +26,9 @@ public class LTTngControlServiceConstants { // Version constants // ------------------------------------------------------------------------ /** - * Constant for the LTTng toolchain version 2.0 + * Pattern to match the LTTng toolchain version 2.x.y. */ - public final static String LTTNG_MAJOR_VERSION_2_0 = "2.0"; //$NON-NLS-1$ + public final static Pattern VERSION_2_PATTERN = Pattern.compile("(2\\.\\d+\\.\\d+).*"); //$NON-NLS-1$ // ------------------------------------------------------------------------ // Command constants diff --git a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java index 26649d563c..130d89ecee 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java +++ b/lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java @@ -90,10 +90,11 @@ public class LTTngControlServiceFactory { int index = 0; while (index < result.getOutput().length) { String line = result.getOutput()[index]; - Matcher matcher = LTTngControlServiceConstants.VERSION_PATTERN.matcher(line); - if (matcher.matches()) { - String version = matcher.group(1).trim(); - if (version.startsWith(LTTngControlServiceConstants.LTTNG_MAJOR_VERSION_2_0)) { + Matcher versionMatcher = LTTngControlServiceConstants.VERSION_PATTERN.matcher(line); + if (versionMatcher.matches()) { + String version = versionMatcher.group(1).trim(); + Matcher matcher = LTTngControlServiceConstants.VERSION_2_PATTERN.matcher(version); + if (matcher.matches()) { LTTngControlService service = new LTTngControlService(shell); service.setVersion(version); return service; -- cgit v1.2.3