/**********************************************************************
- * Copyright (c) 2012 Ericsson
- *
+ * Copyright (c) 2012, 2013 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
+ * Bernd Hufmann - Updated for support of LTTng Tools 2.1
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TargetNodeState;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TargetNodePropertySource;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandShell;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.RemoteSystemProxy;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandShell;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlServiceFactory;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.subsystems.CommunicationsEvent;
import org.eclipse.rse.core.subsystems.ICommunicationsListener;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.properties.IPropertySource;
/**
- * <b><u>TargetNodeComponent</u></b>
* <p>
* Implementation of the trace node component.
* </p>
+ *
+ * @author Bernd Hufmann
*/
public class TargetNodeComponent extends TraceControlComponent implements ICommunicationsListener {
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
+
/**
* Path to icon file for this component (state connected).
*/
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
+
/**
* The node connection state.
*/
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+
/**
- * Constructor
+ * Constructor
* @param name - the name of the component
* @param parent - the parent of the component
* @param host - the host connection implementation
}
/**
- * Constructor (using default proxy)
+ * Constructor (using default proxy)
* @param name - the name of the component
* @param parent - the parent of the component
* @param host - the host connection implementation
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
- */
+
@Override
public Image getImage() {
if (fState == TargetNodeState.CONNECTED) {
}
return fDisconnectedImage;
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getTargetNodeState()
- */
+
@Override
public TargetNodeState getTargetNodeState() {
return fState;
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#setTargetNodeState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent.TargetNodeState)
- */
+
@Override
public void setTargetNodeState(TargetNodeState state) {
fState = state;
fireComponentChanged(TargetNodeComponent.this);
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getControlService()
- */
+
@Override
public ILttngControlService getControlService() {
return fService;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#setControlService(org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService)
- */
@Override
public void setControlService(ILttngControlService service) {
- fService = (ILttngControlService)service;
+ fService = service;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class) {
return new TargetNodePropertySource(this);
}
return null;
- }
-
+ }
+
/**
* @return remote host name
*/
return fRemoteProxy;
}
+ /**
+ * @return port of IP connection (shell) to be used
+ */
+ public int getPort() {
+ return fRemoteProxy.getPort();
+ }
+
+ /**
+ * Sets the port of the IP connections of the shell
+ * @param port - the IP port to set
+ */
+ public void setPort(int port) {
+ fRemoteProxy.setPort(port);
+ }
+
/**
* @return all available sessions.
*/
public TraceSessionComponent[] getSessions() {
List<ITraceControlComponent> compenents = getChildren(TraceSessionGroup.class);
if (compenents.size() > 0) {
- TraceSessionGroup group = (TraceSessionGroup)compenents.get(0);
+ TraceSessionGroup group = (TraceSessionGroup)compenents.get(0);
List<ITraceControlComponent> sessions = group.getChildren(TraceSessionComponent.class);
- return (TraceSessionComponent[])sessions.toArray(new TraceSessionComponent[sessions.size()]);
+ return sessions.toArray(new TraceSessionComponent[sessions.size()]);
}
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$
+ }
+
+ /**
+ * Returns if node supports filtering of events
+ * @return <code>true</code> if node supports filtering else <code>false</code>
+ */
+ public boolean isEventFilteringSupported() {
+ return getControlService().isVersionSupported("2.1.0"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns if node supports networks streaming or not
+ * @return <code>true</code> if node supports filtering else <code>false</code>
+ *
+ */
+ public boolean isNetworkStreamingSupported() {
+ return getControlService().isVersionSupported("2.1.0"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns if node supports configuring buffer type or not
+ * @return <code>true</code> if node supports buffer type configuration else <code>false</code>
+ */
+ public boolean isBufferTypeConfigSupported() {
+ return getControlService().isVersionSupported("2.2.0"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns if node supports trace file rotation or not
+ * @return <code>true</code> if node supports trace file rotation else <code>false</code>
+ */
+ public boolean isTraceFileRotationSupported() {
+ return getControlService().isVersionSupported("2.2.0"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns if node supports periodical flush for metadata or not
+ * @return <code>true</code> if node supports periodical flush for metadata else <code>false</code>
+ */
+ public boolean isPeriodicalMetadataFlushSupported() {
+ return getControlService().isVersionSupported("2.2.0"); //$NON-NLS-1$
+ }
+ /**
+ * Returns if node supports snapshots or not
+ * @return <code>true</code> if it supports snapshots else <code>false</code>
+ *
+ */
+ public boolean isSnapshotSupported() {
+ return getControlService().isVersionSupported("2.3.0"); //$NON-NLS-1$
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
-
- /*
- * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#communicationsStateChange(org.eclipse.rse.core.subsystems.CommunicationsEvent)
- */
+
@Override
public void communicationsStateChange(CommunicationsEvent e) {
if (e.getState() == CommunicationsEvent.AFTER_DISCONNECT ||
}
}
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#isPassiveCommunicationsListener()
- */
@Override
public boolean isPassiveCommunicationsListener() {
return true;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceControlComponent#dispose()
- */
@Override
public void dispose() {
fRemoteProxy.removeCommunicationListener(this);
});
} catch (Exception e) {
setTargetNodeState(TargetNodeState.DISCONNECTED);
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ConnectionFailure + " (" + getName() + "). \n", e)); //$NON-NLS-1$ //$NON-NLS-2$
+ Activator.getDefault().logError(Messages.TraceControl_ConnectionFailure + " (" + getName() + "). \n", e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
setTargetNodeState(TargetNodeState.DISCONNECTING);
fRemoteProxy.disconnect();
} catch (Exception e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_DisconnectionFailure + " (" + getName() + "). \n", e)); //$NON-NLS-1$ //$NON-NLS-2$
+ Activator.getDefault().logError(Messages.TraceControl_DisconnectionFailure + " (" + getName() + "). \n", e); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
- handleDisconnected();
+ handleDisconnected();
}
}
}
/**
- * Retrieves the trace configuration from the target node and populates the information
- * in the tree model. The execution is done in a own job.
- *
- * @throws ExecutionException
+ * Retrieves the trace configuration from the target node and populates the
+ * information in the tree model. The execution is done in a own job.
*/
public void getConfigurationFromNode() {
Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {
TraceProviderGroup providerGroup = new TraceProviderGroup(Messages.TraceControl_ProviderDisplayName, TargetNodeComponent.this);
addChild(providerGroup);
providerGroup.getProviderFromNode(monitor);
-
+
// Get session information from node
TraceSessionGroup sessionGroup = new TraceSessionGroup(Messages.TraceControl_AllSessionsDisplayName, TargetNodeComponent.this);
addChild(sessionGroup);
sessionGroup.getSessionsFromNode(monitor);
} catch (ExecutionException e) {
removeAllChildren();
- return new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ListSessionFailure, e);
- }
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_RetrieveNodeConfigurationFailure, e);
+ }
return Status.OK_STATUS;
}
removeAllChildren();
getConfigurationFromNode();
}
-
+
/**
* Deregisters host from registry.
*/
// ------------------------------------------------------------------------
// Helper function
// ------------------------------------------------------------------------
+
/**
* @return returns the control service for LTTng specific commands.
* @throws ExecutionException
}
/**
- * Handles the connected event.
+ * Handles the connected event.
*/
private void handleConnected() {
setTargetNodeState(TargetNodeState.CONNECTED);
try {
createControlService();
getConfigurationFromNode();
- } catch (ExecutionException e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ListSessionFailure + " (" + getName() + "). \n", e)); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (final ExecutionException e) {
+ // Disconnect only if no control service, otherwise stay connected.
+ if (getControlService() == null) {
+ disconnect();
+ }
+
+ // Notify user
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ErrorDialog er = new ErrorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ Messages.TraceControl_ErrorTitle, Messages.TraceControl_RetrieveNodeConfigurationFailure,
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e),
+ IStatus.ERROR);
+ er.open();
+ }
+ });
+ Activator.getDefault().logError(Messages.TraceControl_RetrieveNodeConfigurationFailure + " (" + getName() + "). \n", e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
/**
- * Handles the disconnected event.
+ * Handles the disconnected event.
*/
private void handleDisconnected() {
removeAllChildren();