Allow LTTng Control to connect to LTTng 2.x.y nodes (Bug 388545)
authorBernd Hufmann <bhufmann@gmail.com>
Fri, 7 Sep 2012 12:18:32 +0000 (08:18 -0400)
committerBernd Hufmann <bhufmann@gmail.com>
Fri, 7 Sep 2012 12:49:33 +0000 (08:49 -0400)
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 <bhufmann@gmail.com>
Reviewed-on: https://git.eclipse.org/r/7584
Tested-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java
org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java
org.eclipse.linuxtools.lttng2.ui.tests/testfiles/LTTngServiceTest.cfg
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/Messages.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/messages.properties
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TargetNodeComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TargetNodePropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceConstants.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceFactory.java

index df0eda5e668686f480161f42d8a4444aed0eda44..3b9f876c2c725b4816a125fc1f6439468d4384b9 100644 (file)
@@ -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);
index cf0abba6978f63c3ad516a154fa044822cd855ee..4bce2d1eb9cef1bf23214d582747155e0431e6d8 100644 (file)
@@ -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);
         }
index 42b400447b72106b33e184ff0819642b8c56e5f7..283aa488fb88290ec0420ee6f1530ea1ea20ddb6 100644 (file)
@@ -37,7 +37,7 @@ lttng version
 0
 </COMMAND_RESULT>
 <COMMAND_OUTPUT>
-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
index 32629d50d64752186d2411cdfcbf460029fb379f..de3c0420ed262c413fa1e10301b8bda459ee6d01 100644 (file)
@@ -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;
index f6b2ed1e0182bdd1a9e6737613a5158f46e283b0..f0d1e50f0ae2156ce24a8729b197037a9962f644 100644 (file)
@@ -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
index 5ce40f940aa6ab15ab7aff9874eed2a40968f40c..94a6678ba0ce6f7af535a330d66aa8bd9f233431 100644 (file)
@@ -206,6 +206,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
     // ------------------------------------------------------------------------
index 1fbb2a71ef00995132c0fa64c2f11909fda966a6..4d82be2620fea0dd32b1e1c4fc8c6da74d8dcb16 100644 (file)
@@ -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;
  * <p>
  * Property source implementation for the target node component.
  * </p>
- * 
+ *
  * @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;
     }
 }
index 5e84b86a853f13cb37b4aacf7c088ed76dce6744..d73ca76e4b223a752568d0024d49821cda04651d 100644 (file)
@@ -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
index 26649d563c97192721b96338f8349346bb35c523..130d89ecee986f65951eb5f65e2b6b0a15f12b8c 100644 (file)
@@ -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;
This page took 0.032081 seconds and 5 git commands to generate.