Search in sources :

Example 1 with RemoteSystemProxy

use of org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy in project tracecompass by tracecompass.

the class ImportHandler method execute.

// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }
    CommandParameter param;
    fLock.lock();
    try {
        param = fParam;
        if (param == null) {
            return null;
        }
        param = param.clone();
    } finally {
        fLock.unlock();
    }
    // create default project
    IProject project = TmfProjectRegistry.createProject(RemoteFetchLogWizardRemotePage.DEFAULT_REMOTE_PROJECT_NAME, null, null);
    if (param.getSession().isLiveTrace()) {
        importLiveTrace(new LttngRelaydConnectionInfo(param.getSession().getLiveUrl(), param.getSession().getLivePort(), param.getSession().getName()), project);
        return null;
    } else if (param.getSession().isStreamedTrace()) {
        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        String notify = store.getString(NOTIFY_IMPORT_STREAMED_PREF_KEY);
        if (!MessageDialogWithToggle.ALWAYS.equals(notify)) {
            MessageDialogWithToggle.openInformation(window.getShell(), null, Messages.TraceControl_ImportDialogStreamedTraceNotification, Messages.TraceControl_ImportDialogStreamedTraceNotificationToggle, false, store, NOTIFY_IMPORT_STREAMED_PREF_KEY);
        }
        // Streamed trace
        TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true);
        TmfTraceFolder traceFolder = projectElement.getTracesFolder();
        ImportTraceWizard wizard = new ImportTraceWizard();
        wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(traceFolder));
        WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
        dialog.open();
        return null;
    }
    // Generate the profile
    TraceSessionComponent session = param.getSession();
    // $NON-NLS-1$
    RemoteImportProfileElement profile = new RemoteImportProfileElement(null, "LTTng Remote Traces");
    RemoteSystemProxy proxy = session.getTargetNode().getRemoteSystemProxy();
    IRemoteConnection rc = proxy.getRemoteConnection();
    String name = rc.getName();
    if (!rc.hasService(IRemoteConnectionHostService.class)) {
        return null;
    }
    String scheme = rc.getConnectionType().getScheme();
    IRemoteConnectionHostService hostService = checkNotNull(rc.getService(IRemoteConnectionHostService.class));
    String address = hostService.getHostname();
    String user = hostService.getUsername();
    int port = hostService.getPort();
    URI remoteUri;
    try {
        remoteUri = new URI(scheme, user, address, port, null, null, null);
    } catch (URISyntaxException e) {
        return false;
    }
    RemoteImportConnectionNodeElement connection = new RemoteImportConnectionNodeElement(profile, name, remoteUri.toString());
    String pathString = session.isSnapshotSession() ? session.getSnapshotInfo().getSnapshotPath() : session.getSessionPath();
    IPath path = new Path(pathString);
    RemoteImportTraceGroupElement group = new RemoteImportTraceGroupElement(connection, path.toString());
    group.setRecursive(true);
    // $NON-NLS-1$//$NON-NLS-2$
    TracePackageElement element = new TracePackageTraceElement(group, "", "");
    // $NON-NLS-1$
    new TracePackageFilesElement(element, ".*");
    String experimentName = path.lastSegment();
    if (!experimentName.startsWith(session.getName())) {
        experimentName = session.getName();
    }
    RemoteFetchLogWizard wizard = new RemoteFetchLogWizard(profile, experimentName);
    wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
    WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
    dialog.open();
    return null;
}
Also used : RemoteImportConnectionNodeElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportConnectionNodeElement) IRemoteConnectionHostService(org.eclipse.remote.core.IRemoteConnectionHostService) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TmfProjectElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement) URISyntaxException(java.net.URISyntaxException) RemoteImportProfileElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement) URI(java.net.URI) ImportTraceWizard(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard) TmfTraceFolder(org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) RemoteFetchLogWizard(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.RemoteFetchLogWizard) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TraceSessionComponent(org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent) IPath(org.eclipse.core.runtime.IPath) IRemoteConnection(org.eclipse.remote.core.IRemoteConnection) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) RemoteImportTraceGroupElement(org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTraceGroupElement) IProject(org.eclipse.core.resources.IProject) RemoteSystemProxy(org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy) LttngRelaydConnectionInfo(org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.LttngRelaydConnectionInfo) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with RemoteSystemProxy

use of org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy in project tracecompass by tracecompass.

the class RemoteGenerateManifestOperation method run.

// ------------------------------------------------------------------------
// Operation(s)
// ------------------------------------------------------------------------
@Override
public void run(IProgressMonitor monitor) {
    try {
        monitor.worked(1);
        String root = null;
        List<TracePackageElement> resultElementList = new ArrayList<>();
        SubMonitor subMonitor = SubMonitor.convert(monitor, fProfile.getChildren().length * 2);
        List<RemoteImportConnectionNodeElement> connectionNodes = fProfile.getConnectionNodeElements();
        for (RemoteImportConnectionNodeElement connectionNode : connectionNodes) {
            RemoteSystemProxy proxy = connectionNode.getRemoteSystemProxy();
            // create new element to decouple from input element
            RemoteImportConnectionNodeElement outputConnectionNode = new RemoteImportConnectionNodeElement(null, connectionNode.getName(), connectionNode.getURI());
            resultElementList.add(outputConnectionNode);
            for (TracePackageElement element : connectionNode.getChildren()) {
                if (element instanceof RemoteImportTraceGroupElement) {
                    ModalContext.checkCanceled(monitor);
                    RemoteImportTraceGroupElement traceGroup = (RemoteImportTraceGroupElement) element;
                    root = traceGroup.getRootImportPath();
                    TracePackageElement[] traceElements = traceGroup.getChildren();
                    fTemplatePatternsToTraceElements = generatePatterns(traceElements);
                    IRemoteFileService fs = proxy.getRemoteConnection().getService(IRemoteFileService.class);
                    if (fs == null) {
                        continue;
                    }
                    final IFileStore remoteFolder = fs.getResource(root);
                    // make sure that remote directory is read and not cached
                    int recursionLevel = 0;
                    // create new element to decouple from input element
                    RemoteImportTraceGroupElement outputTraceGroup = new RemoteImportTraceGroupElement(outputConnectionNode, traceGroup.getRootImportPath());
                    outputTraceGroup.setRecursive(traceGroup.isRecursive());
                    generateElementsFromArchive(outputTraceGroup, outputTraceGroup, remoteFolder, recursionLevel, subMonitor.newChild(1));
                    filterElements(outputTraceGroup);
                }
            }
        }
        setResultElements(resultElementList.toArray(new TracePackageElement[0]));
        setStatus(Status.OK_STATUS);
    } catch (InterruptedException e) {
        setStatus(Status.CANCEL_STATUS);
    } catch (Exception e) {
        setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(RemoteMessages.RemoteGenerateManifest_GenerateProfileManifestError, fProfile.getText()), e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ArrayList(java.util.ArrayList) SubMonitor(org.eclipse.core.runtime.SubMonitor) CoreException(org.eclipse.core.runtime.CoreException) RemoteSystemProxy(org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) IFileStore(org.eclipse.core.filesystem.IFileStore) IRemoteFileService(org.eclipse.remote.core.IRemoteFileService)

Example 3 with RemoteSystemProxy

use of org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy in project tracecompass by tracecompass.

the class RemoteImportConnectionNodeElement method connect.

/**
 * Connects to the remote host
 *
 * @param monitor
 *                a progress monitor
 *
 * @return status of the executions
 */
public IStatus connect(@NonNull IProgressMonitor monitor) {
    // Use local variables to avoid null annotation warning
    RemoteSystemProxy proxy = fRemoteProxy;
    String name = fName;
    if (name == null) {
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, RemoteMessages.RemoteImportConnectionNodeElement_NodeNameNullError);
    }
    if (proxy == null) {
        try {
            URI hostUri = null;
            hostUri = URIUtil.fromString(fURI);
            if (hostUri == null) {
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, RemoteMessages.RemoteImportConnectionNodeElement_UriNullError);
            }
            proxy = new RemoteSystemProxy(TmfRemoteConnectionFactory.createConnection(hostUri, name));
            fRemoteProxy = proxy;
        } catch (URISyntaxException e) {
            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(RemoteMessages.RemoteImportConnectionNodeElement_InvalidUriString, fURI), e);
        } catch (RemoteConnectionException e) {
            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(RemoteMessages.RemoteImportConnectionNodeElement_ConnectionFailure, fURI), e);
        }
    }
    try {
        proxy.connect(monitor);
        return Status.OK_STATUS;
    } catch (ExecutionException e) {
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(RemoteMessages.RemoteImportConnectionNodeElement_ConnectionFailure, fURI), e);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) RemoteConnectionException(org.eclipse.remote.core.exception.RemoteConnectionException) URISyntaxException(java.net.URISyntaxException) ExecutionException(org.eclipse.core.commands.ExecutionException) URI(java.net.URI) RemoteSystemProxy(org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy)

Example 4 with RemoteSystemProxy

use of org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy in project tracecompass by tracecompass.

the class CreateSessionDialog method validate.

private void validate() {
    // Validate input data
    fSessionName = fSessionNameText.getText();
    fSessionPath = fSessionPathText.getText();
    setErrorMessage(null);
    if (fParent.isLiveSupported() && fLiveButton != null) {
        fIsLive = fLiveButton.getSelection();
        fLiveDelay = Long.valueOf(LTTngControlServiceConstants.UNUSED_VALUE);
        fLiveUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URL;
        fLivePort = SessionInfo.DEFAULT_LIVE_PORT;
    }
    if (!"".equals(fSessionPath)) {
        // validate sessionPath
        if (!fIsAdvancedEnabled && !fIsLive) {
            TargetNodeComponent node = (TargetNodeComponent) fParent.getParent();
            RemoteSystemProxy proxy = node.getRemoteSystemProxy();
            IRemoteFileService fsss = proxy.getRemoteConnection().getService(IRemoteFileService.class);
            if (fsss != null) {
                IFileStore remoteFolder = fsss.getResource(fSessionPath);
                if (remoteFolder == null) {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    setErrorMessage(Messages.TraceControl_InvalidSessionPathError + " (" + fSessionPath + ") \n");
                    return;
                }
                IFileInfo fileInfo = remoteFolder.fetchInfo();
                if (fileInfo.exists()) {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    setErrorMessage(Messages.TraceControl_SessionPathAlreadyExistsError + " (" + fSessionPath + ") \n");
                    return;
                }
            }
        }
        fIsDefaultPath = false;
    }
    if (fParent.isSnapshotSupported()) {
        fIsSnapshot = fSnapshotButton.getSelection();
    }
    fNetworkUrl = null;
    fControlUrl = null;
    fDataUrl = null;
    if (fIsAdvancedEnabled && fStreamingComposite != null) {
        if (fIsLive && fLiveGroup != null) {
            String liveDelayText = fLiveDelayText.getText();
            try {
                fLiveDelay = liveDelayText.equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.valueOf(liveDelayText);
                fLivePort = Integer.valueOf(fLivePortText.getText());
                fLiveUrl = fLiveHostAddressText.getText();
            } catch (NumberFormatException e) {
                setErrorMessage(Messages.TraceControl_InvalidLiveDelayError);
                return;
            }
        }
        fTracePath = fTracePathText.getText();
        if (fControlProtocolCombo.getSelectionIndex() < 0) {
            // $NON-NLS-1$
            setErrorMessage("Control Protocol Text is empty\n");
            return;
        }
        if ("".equals(fControlHostAddressText.getText())) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            setErrorMessage("Control Address Text is empty\n");
            return;
        }
        if (!fLinkDataWithControlButton.getSelection()) {
            if (fDataProtocolCombo.getSelectionIndex() < 0) {
                // $NON-NLS-1$
                setErrorMessage("Data Protocol Text is empty\n");
                return;
            }
            if ("".equals(fDataHostAddressText.getText())) {
                // $NON-NLS-1$
                // $NON-NLS-1$
                setErrorMessage("Data Address Text is empty\n");
                return;
            }
            fControlUrl = getUrlString(fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()), fControlHostAddressText.getText(), fControlPortText.getText(), null, fTracePath);
            fDataUrl = getUrlString(fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()), fDataHostAddressText.getText(), null, fDataPortText.getText(), fTracePath);
        } else {
            fNetworkUrl = getUrlString(fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()), fControlHostAddressText.getText(), fControlPortText.getText(), fDataPortText.getText(), fTracePath);
        }
    }
    if (fIsLive && fNetworkUrl == null && fControlUrl == null && fDataUrl == null) {
        fNetworkUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URL;
    }
    // Check for invalid names
    if (!"".equals(fSessionName) && !fSessionName.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) {
        // $NON-NLS-1$ //$NON-NLS-2$
        // $NON-NLS-1$ //$NON-NLS-2$
        setErrorMessage(Messages.TraceControl_InvalidSessionNameError + " (" + fSessionName + ") \n");
        return;
    }
    // Check if node with name already exists in parent
    if (fParent.containsChild(fSessionName)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        setErrorMessage(Messages.TraceControl_SessionAlreadyExistsError + " (" + fSessionName + ")");
        return;
    }
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo) IFileStore(org.eclipse.core.filesystem.IFileStore) TargetNodeComponent(org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent) RemoteSystemProxy(org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy) IRemoteFileService(org.eclipse.remote.core.IRemoteFileService)

Aggregations

RemoteSystemProxy (org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy)4 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 IFileStore (org.eclipse.core.filesystem.IFileStore)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IRemoteFileService (org.eclipse.remote.core.IRemoteFileService)2 TracePackageElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement)2 ArrayList (java.util.ArrayList)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 IRemoteConnection (org.eclipse.remote.core.IRemoteConnection)1