From c44ff301740782af3fd8a5a942e241bb52b1ab92 Mon Sep 17 00:00:00 2001 From: Uwe Stieber Date: Thu, 24 Jul 2014 13:56:48 +0200 Subject: Target Explorer: Fix channel communication log misses early "open channel" commands --- .../org.eclipse.tcf.te.tcf.core/plugin.properties | 1 + .../plugins/org.eclipse.tcf.te.tcf.core/plugin.xml | 6 ++ .../te/tcf/core/interfaces/IPathMapService.java | 5 +- .../internal/channelmanager/ChannelManager.java | 9 +-- .../channelmanager/steps/ApplyPathMapsStep.java | 2 +- .../steps/InitializeLoggingStep.java | 83 ++++++++++++++++++++++ .../core/internal/services/PathMapService.java | 15 ++-- .../te/tcf/launch/ui/editor/PathMapEditorPage.java | 2 +- 8 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties index 9c7ee52cd..17fb6c1a5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties @@ -25,6 +25,7 @@ ShutDownStep.name=Close all TCF channels LaunchValueAddStep.name=Launch value-add ChainPeerStep.name=Redirect channel +InitializeLoggingStep.name=Initialize channel communication logging ApplyPatMapsStep.name=Apply path map to channel CloseChannelStep.name=Close channel ShutdownValueAddStep.name=Shutdown value-add diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml index 51feeedc9..797a230e2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml @@ -59,6 +59,11 @@ id="org.eclipse.tcf.te.tcf.core.channelmanager.chainPeerStep" class="org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps.ChainPeerStep" label="%ChainPeerStep.name"/> + + + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java index ebb610b3e..2eb6bf0b5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java @@ -74,11 +74,12 @@ public interface IPathMapService extends IService { * Note: This method must be called from outside the TCF event dispatch thread. * * @param context The context. Must not be null. - * @param force If true the path map will be set even if it appears not to be + * @param force If true, the path map will be set even if it appears not to be * different from the path map already set. + * @param forceEmpty If true, the path map will be set even if empty. * @param callback The callback to invoke once the operation completed. Must not be null. */ - public void applyPathMap(Object context, boolean force, ICallback callback); + public void applyPathMap(Object context, boolean force, boolean forceEmpty, ICallback callback); /** * Returns the current client ID used to identify path map rules handled diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java index bdb8ded07..b723c6253 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java @@ -190,6 +190,7 @@ public class ChannelManager extends PlatformObject implements IChannelManager { // Create the data properties container passed to the "open channel" steps final IPropertiesContainer data = new PropertiesContainer(); // Set the flags to be passed to the "open channel" steps + data.setProperty(IChannelManager.FLAG_FORCE_NEW, forceNew); data.setProperty(IChannelManager.FLAG_NO_VALUE_ADD, noValueAdd); data.setProperty(IChannelManager.FLAG_NO_PATH_MAP, noPathMap); // No recent action history persistence @@ -242,14 +243,6 @@ public class ChannelManager extends PlatformObject implements IChannelManager { 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager.this); } - // Log successfully opened channels - String message = finForceNew ? "Private" : "Shared"; //$NON-NLS-1$ //$NON-NLS-2$ - if (noValueAdd) message += ", No Value Add"; //$NON-NLS-1$ - if (noPathMap) message += ", Not Applying Path Map"; //$NON-NLS-1$ - - ChannelEvent event = new ChannelEvent(ChannelManager.this, channel, ChannelEvent.TYPE_OPEN, message); - EventManager.getInstance().fireEvent(event); - // Invoke the primary "open channel" done callback internalDone.doneOpenChannel(null, channel); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ApplyPathMapsStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ApplyPathMapsStep.java index ce48d6f41..e2124c841 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ApplyPathMapsStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ApplyPathMapsStep.java @@ -79,7 +79,7 @@ public class ApplyPathMapsStep extends AbstractPeerStep { if (service != null) { // Pass in the channel for direct use. IChannelManager.getChannel(peer) // does return null while still executing the "open channel" step group. - service.applyPathMap(channel, true, callback); + service.applyPathMap(channel, true, false, callback); } else { callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java new file mode 100644 index 000000000..7ced62b10 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2014 Wind River Systems, Inc. and others. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.te.runtime.events.EventManager; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.core.activator.CoreBundleActivator; +import org.eclipse.tcf.te.tcf.core.events.ChannelEvent; +import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; +import org.eclipse.tcf.te.tcf.core.interfaces.steps.ITcfStepAttributes; +import org.eclipse.tcf.te.tcf.core.steps.AbstractPeerStep; + +/** + * Initialize channel communication logging step implementation. + */ +public class InitializeLoggingStep extends AbstractPeerStep { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + Assert.isNotNull(context); + Assert.isNotNull(data); + Assert.isNotNull(fullQualifiedId); + Assert.isNotNull(monitor); + + IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); + if (channel == null) { + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Channel to target not available.")); //$NON-NLS-1$ + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { + Assert.isNotNull(context); + Assert.isNotNull(data); + Assert.isNotNull(fullQualifiedId); + Assert.isNotNull(monitor); + Assert.isNotNull(callback); + + final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); + Assert.isNotNull(channel); + + if (channel.getState() == IChannel.STATE_OPEN) { + boolean forceNew = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_FORCE_NEW, fullQualifiedId, data); + boolean noValueAdd = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_NO_VALUE_ADD, fullQualifiedId, data); + boolean noPathMap = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_NO_PATH_MAP, fullQualifiedId, data); + + // Log successfully opened channels + String message = forceNew ? "Private" : "Shared"; //$NON-NLS-1$ //$NON-NLS-2$ + if (noValueAdd) message += ", No Value Add"; //$NON-NLS-1$ + if (noPathMap) message += ", Not Applying Path Map"; //$NON-NLS-1$ + + ChannelEvent event = new ChannelEvent(InitializeLoggingStep.this, channel, ChannelEvent.TYPE_OPEN, message); + EventManager.getInstance().fireEvent(event); + } + + callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); + } + + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java index 16d25d370..e5b1bac67 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java @@ -160,7 +160,7 @@ public class PathMapService extends AbstractService implements IPathMapService { updateLaunchConfiguration(config, rulesList); // Apply the path map - applyPathMap(context, false, new Callback() { + applyPathMap(context, false, false, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { if (status != null && Platform.inDebugMode()) { @@ -208,7 +208,7 @@ public class PathMapService extends AbstractService implements IPathMapService { updateLaunchConfiguration(config, rulesList); // Apply the path map - applyPathMap(context, true, new Callback() { + applyPathMap(context, true, true, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { if (status != null && Platform.inDebugMode()) { @@ -306,10 +306,10 @@ public class PathMapService extends AbstractService implements IPathMapService { } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#applyPathMap(java.lang.Object, boolean, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#applyPathMap(java.lang.Object, boolean, boolean, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) */ @Override - public void applyPathMap(final Object context, final boolean force, final ICallback callback) { + public void applyPathMap(final Object context, final boolean force, final boolean forceEmpty, final ICallback callback) { Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ Assert.isNotNull(context); Assert.isNotNull(callback); @@ -367,7 +367,7 @@ public class PathMapService extends AbstractService implements IPathMapService { // If the merged path map differs from the agent side path map, apply the map if (force || isDifferent(rules, map)) { // Apply the path map - set(rules, svc, force, new IPathMap.DoneSet() { + set(rules, svc, forceEmpty, new IPathMap.DoneSet() { @Override public void doneSet(IToken token, Exception error) { innerCallback.done(PathMapService.this, StatusHelper.getStatus(error)); @@ -489,9 +489,10 @@ public class PathMapService extends AbstractService implements IPathMapService { * * @param map The path map. Must not be null. * @param svc The path map service. Must not be null. + * @param forceEmpty If true, the path map will be set even if empty. * @param done The callback to invoke. Must not be null. */ - public static void set(List map, IPathMap svc, boolean force, IPathMap.DoneSet done) { + public static void set(List map, IPathMap svc, boolean forceEmpty, IPathMap.DoneSet done) { Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ Assert.isNotNull(map); Assert.isNotNull(svc); @@ -506,7 +507,7 @@ public class PathMapService extends AbstractService implements IPathMapService { } } // Apply the path map rules if not empty or forced - if (!map.isEmpty() || force) { + if (!map.isEmpty() || forceEmpty) { svc.set(map.toArray(new PathMapRule[map.size()]), done); } else { done.doneSet(null, null); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java index ae7a4a146..dfe184235 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java @@ -53,7 +53,7 @@ public class PathMapEditorPage extends AbstractTcfLaunchTabContainerEditorPage { if (peerNode != null && peerNode.getPeer() != null) { IPathMapService service = ServiceManager.getInstance().getService(peerNode.getPeer(), IPathMapService.class); if (service != null) { - service.applyPathMap(peerNode.getPeer(), false, new Callback() { + service.applyPathMap(peerNode.getPeer(), false, true, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { if (status != null && status.getSeverity() == IStatus.ERROR) { -- cgit v1.2.3