From 85331bd92c302e13839b5a7c7c8973444cc5a231 Mon Sep 17 00:00:00 2001 From: Uwe Stieber Date: Fri, 11 Jul 2014 09:30:28 +0200 Subject: Target Explorer: Fix stepper based channel manager steps --- .../tcf/te/runtime/stepper/steps/AbstractStep.java | 5 +- .../META-INF/MANIFEST.MF | 1 + .../plugins/org.eclipse.tcf.te.tcf.core/plugin.xml | 8 +- .../te/tcf/core/interfaces/IChannelManager.java | 17 +--- .../internal/channelmanager/ChannelManager.java | 72 ----------------- .../internal/channelmanager/ChannelManager2.java | 88 ++++++-------------- .../iterators/ChainPeersIterator.java | 91 +++++++++++++++++++++ .../iterators/ValueAddsIterator.java | 58 +++++++++++++ .../channelmanager/steps/ApplyPathMapsStep.java | 51 ++++++++---- .../channelmanager/steps/ChainPeerStep.java | 94 +++++++++++++++------- .../channelmanager/steps/CloseChannelStep.java | 29 +++++-- .../channelmanager/steps/LaunchValueAddStep.java | 12 ++- .../channelmanager/steps/ShutdownValueAddStep.java | 15 +++- .../te/tcf/core/iterators/ChainPeersIterator.java | 90 --------------------- .../te/tcf/core/iterators/ValueAddsIterator.java | 57 ------------- .../org/eclipse/tcf/te/tcf/core/nls/Messages.java | 1 - .../tcf/te/tcf/core/nls/Messages.properties | 1 - .../tcf/te/tcf/locator/steps/WaitForReadyStep.java | 15 ++-- 18 files changed, 336 insertions(+), 369 deletions(-) create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ChainPeersIterator.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ValueAddsIterator.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ChainPeersIterator.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ValueAddsIterator.java diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/AbstractStep.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/AbstractStep.java index 1de88770c..a53f32407 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/AbstractStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/AbstractStep.java @@ -99,9 +99,8 @@ public abstract class AbstractStep extends ExecutableExtension implements IStep */ @Override public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { - if (callback != null) { - callback.done(this, Status.OK_STATUS); - } + Assert.isNotNull(callback); + callback.done(this, Status.OK_STATUS); } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF index 0722e01da..b916bd82b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF @@ -28,6 +28,7 @@ Export-Package: org.eclipse.tcf.te.tcf.core, org.eclipse.tcf.te.tcf.core.interfaces.tracing, org.eclipse.tcf.te.tcf.core.internal;x-internal:=true, org.eclipse.tcf.te.tcf.core.internal.channelmanager;x-internal:=true, + org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators;x-internal:=true, org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps;x-internal:=true, org.eclipse.tcf.te.tcf.core.internal.services;x-internal:=true, org.eclipse.tcf.te.tcf.core.internal.utils;x-internal:=true, 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 7ec0813d4..f4f218167 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 @@ -65,7 +65,7 @@ class="org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps.CloseChannelStep" label="%CloseChannelStep.name"/> @@ -81,13 +81,13 @@ + iterator="org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators.ValueAddsIterator"> + iterator="org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators.ChainPeersIterator"> @@ -101,7 +101,7 @@ + iterator="org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators.ValueAddsIterator"> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java index 92fc04553..a8f564f6f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java @@ -81,7 +81,8 @@ public interface IChannelManager extends IAdaptable { * Channels opened by the channel manager must be closed by the channel managers * {@link #closeChannel(IChannel)} API. *

- * The method can be called from any thread context. + * The method can be called from any thread context, the client done callback + * is always invoked within the TCF event dispatch thread. * * @param peer The peer. Must not be null. * @param flags Map containing the flags to parameterize the channel opening, or null. @@ -89,20 +90,6 @@ public interface IChannelManager extends IAdaptable { */ public void openChannel(IPeer peer, Map flags, DoneOpenChannel done); - /** - * Opens a new channel to communicate with the peer described by the given peer attributes. - *

- * Channels opened by the channel manager must be closed by the channel managers - * {@link #closeChannel(IChannel)} API. - *

- * The method can be called from any thread context. - * - * @param peerAttributes The peer attributes. Must not be null. - * @param flags Map containing the flags to parameterize the channel opening, or null. - * @param done The client callback. Must not be null. - */ - public void openChannel(Map peerAttributes, Map flags, DoneOpenChannel done); - /** * Returns the shared channel instance for the given peer. Channels retrieved using this * method cannot be closed by the caller. 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 c2403d82b..ad957936e 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 @@ -24,7 +24,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.osgi.util.NLS; -import org.eclipse.tcf.core.AbstractPeer; import org.eclipse.tcf.protocol.IChannel; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.IToken; @@ -40,7 +39,6 @@ import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService; import org.eclipse.tcf.te.tcf.core.interfaces.IPeerProperties; import org.eclipse.tcf.te.tcf.core.interfaces.tracing.ITraceIds; import org.eclipse.tcf.te.tcf.core.nls.Messages; -import org.eclipse.tcf.te.tcf.core.peers.Peer; import org.eclipse.tcf.te.tcf.core.util.persistence.PeerDataHelper; import org.eclipse.tcf.te.tcf.core.va.ValueAddManager; import org.eclipse.tcf.te.tcf.core.va.interfaces.IValueAdd; @@ -317,76 +315,6 @@ public final class ChannelManager extends PlatformObject implements IChannelMana } } - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#openChannel(java.util.Map, java.util.Map, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel) - */ - @Override - public void openChannel(final Map peerAttributes, final Map flags, final DoneOpenChannel done) { - Runnable runnable = new Runnable() { - @Override - public void run() { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - internalOpenChannel(peerAttributes, flags, done); - } - }; - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeLater(runnable); - } - - /** - * Internal implementation of {@link #openChannel(Map, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel)}. - *

- * Method must be called within the TCF dispatch thread. - * - * @param peerAttributes The peer attributes. Must not be null. - * @param flags Map containing the flags to parameterize the channel opening, or null. - * @param done The client callback. Must not be null. - */ - /* default */ void internalOpenChannel(final Map peerAttributes, final Map flags, final DoneOpenChannel done) { - Assert.isNotNull(peerAttributes); - Assert.isNotNull(done); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - // Call openChannel(IPeer, ...) instead of calling internalOpenChannel(IPeer, ...) directly - // to include the value-add handling. - openChannel(getOrCreatePeerInstance(peerAttributes), flags, done); - } - - /** - * Tries to find an existing peer instance or create an new {@link IPeer} - * instance if not found. - *

- * Note: This method must be invoked at the TCF dispatch thread. - * - * @param peerAttributes The peer attributes. Must not be null. - * @return The peer instance. - */ - private IPeer getOrCreatePeerInstance(final Map peerAttributes) { - Assert.isNotNull(peerAttributes); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // Get the peer id from the properties - String peerId = peerAttributes.get(IPeer.ATTR_ID); - Assert.isNotNull(peerId); - - // Check if we shall open the peer transient - boolean isTransient = peerAttributes.containsKey("transient") ? Boolean.parseBoolean(peerAttributes.remove("transient")) : false; //$NON-NLS-1$ //$NON-NLS-2$ - - // Look the peer via the Locator Service. - IPeer peer = Protocol.getLocator().getPeers().get(peerId); - // If not peer could be found, create a new one - if (peer == null) { - peer = isTransient ? new Peer(peerAttributes) : new AbstractPeer(peerAttributes); - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_createPeer_new_message, peerId, Boolean.valueOf(isTransient)), - 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, this); - } - } - - // Return the peer instance - return peer; - } - /* (non-Javadoc) * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#getChannel(org.eclipse.tcf.protocol.IPeer) */ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager2.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager2.java index 8d1ea51e1..57f8f2dfd 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager2.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager2.java @@ -21,7 +21,6 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.osgi.util.NLS; -import org.eclipse.tcf.core.AbstractPeer; import org.eclipse.tcf.protocol.IChannel; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.IToken; @@ -39,7 +38,6 @@ 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.interfaces.tracing.ITraceIds; import org.eclipse.tcf.te.tcf.core.nls.Messages; -import org.eclipse.tcf.te.tcf.core.peers.Peer; /** * Channel manager implementation. @@ -85,6 +83,23 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { } } + // The client done callback must be called within the TCF event dispatch thread + final DoneOpenChannel internalDone = new DoneOpenChannel() { + + @Override + public void doneOpenChannel(final Throwable error, final IChannel channel) { + Runnable runnable = new Runnable() { + @Override + public void run() { + done.doneOpenChannel(error, channel); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); + } + }; + // The channel instance to return IChannel channel = null; @@ -127,7 +142,7 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { } // Invoke the channel open done callback - done.doneOpenChannel(null, channel); + internalDone.doneOpenChannel(null, channel); } // If the channel is opening, wait for the channel to become fully opened. // Add the done open channel callback to the list of pending callback's. @@ -138,10 +153,10 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { pendingDones.put(id, dones); } Assert.isNotNull(dones); - dones.add(done); + dones.add(internalDone); if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_pending_message, id, "0x" + Integer.toHexString(done.hashCode())), //$NON-NLS-1$ + CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_pending_message, id, "0x" + Integer.toHexString(internalDone.hashCode())), //$NON-NLS-1$ 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager2.this); } } @@ -187,7 +202,7 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { pendingOpenChannel.remove(id); // Invoke the primary "open channel" done callback - done.doneOpenChannel(error, null); + internalDone.doneOpenChannel(error, null); // Invoke pending callback's List pending = pendingDones.remove(id); @@ -216,7 +231,7 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { } // Invoke the primary "open channel" done callback - done.doneOpenChannel(null, channel); + internalDone.doneOpenChannel(null, channel); // Invoke pending callback's List pending = pendingDones.remove(id); @@ -252,71 +267,16 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { pendingDones.put(id, dones); } Assert.isNotNull(dones); - dones.add(done); + dones.add(internalDone); if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_pending_message, id, "0x" + Integer.toHexString(done.hashCode())), //$NON-NLS-1$ + CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_pending_message, id, "0x" + Integer.toHexString(internalDone.hashCode())), //$NON-NLS-1$ 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager2.this); } } } } - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#openChannel(java.util.Map, java.util.Map, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel) - */ - @Override - public void openChannel(final Map peerAttributes, final Map flags, final DoneOpenChannel done) { - Assert.isNotNull(peerAttributes); - Assert.isNotNull(done); - - Runnable runnable = new Runnable() { - @Override - public void run() { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - openChannel(getOrCreatePeerInstance(peerAttributes), flags, done); - } - }; - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeLater(runnable); - } - - /** - * Tries to find an existing peer instance or create an new {@link IPeer} - * instance if not found. - *

- * Note: This method must be invoked at the TCF dispatch thread. - * - * @param peerAttributes The peer attributes. Must not be null. - * @return The peer instance. - */ - /* default */ IPeer getOrCreatePeerInstance(final Map peerAttributes) { - Assert.isNotNull(peerAttributes); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // Get the peer id from the properties - String peerId = peerAttributes.get(IPeer.ATTR_ID); - Assert.isNotNull(peerId); - - // Check if we shall open the peer transient - boolean isTransient = peerAttributes.containsKey("transient") ? Boolean.parseBoolean(peerAttributes.remove("transient")) : false; //$NON-NLS-1$ //$NON-NLS-2$ - - // Look the peer via the Locator Service. - IPeer peer = Protocol.getLocator().getPeers().get(peerId); - // If not peer could be found, create a new one - if (peer == null) { - peer = isTransient ? new Peer(peerAttributes) : new AbstractPeer(peerAttributes); - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_createPeer_new_message, peerId, Boolean.valueOf(isTransient)), - 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager2.this); - } - } - - // Return the peer instance - return peer; - } - /* (non-Javadoc) * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#getChannel(org.eclipse.tcf.protocol.IPeer) */ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ChainPeersIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ChainPeersIterator.java new file mode 100644 index 000000000..a0e5ef47e --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ChainPeersIterator.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * 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.iterators; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +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.IStepAttributes; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.core.interfaces.IPeerProperties; +import org.eclipse.tcf.te.tcf.core.iterators.AbstractPeerStepGroupIterator; +import org.eclipse.tcf.te.tcf.core.util.persistence.PeerDataHelper; +import org.eclipse.tcf.te.tcf.core.va.ValueAddManager; +import org.eclipse.tcf.te.tcf.core.va.interfaces.IValueAdd; + +/** + * ChainPeersIterator + */ +public class ChainPeersIterator extends AbstractPeerStepGroupIterator { + + /* default */ final List peers = new ArrayList(); + + /** + * Constructor. + */ + public ChainPeersIterator() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#initialize(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 initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + super.initialize(context, data, fullQualifiedId, monitor); + + final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); + final String peerId = peer.getID(); + + peers.clear(); + + Runnable runnable = new Runnable() { + @Override + public void run() { + IValueAdd[] valueAdds = ValueAddManager.getInstance().getValueAdd(peer); + for (IValueAdd valueAdd : valueAdds) { + IPeer valueAddPeer = valueAdd.getPeer(peerId); + if (valueAddPeer != null) { + peers.add(valueAddPeer); + } + } + + String proxyConfiguration = peer.getAttributes().get(IPeerProperties.PROP_PROXIES); + if (proxyConfiguration != null) { + for (IPeer proxy : PeerDataHelper.decodePeerList(proxyConfiguration)) { + peers.add(proxy); + } + } + + peers.add(peer); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); + + setIterations(peers.size()); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(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 internalNext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + StepperAttributeUtil.setProperty(IStepAttributes.ATTR_ACTIVE_CONTEXT, fullQualifiedId, data, peers.get(getIteration())); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ValueAddsIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ValueAddsIterator.java new file mode 100644 index 000000000..8a1e90c1d --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ValueAddsIterator.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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.iterators; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +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.interfaces.steps.ITcfStepAttributes; +import org.eclipse.tcf.te.tcf.core.iterators.AbstractPeerStepGroupIterator; +import org.eclipse.tcf.te.tcf.core.va.ValueAddManager; +import org.eclipse.tcf.te.tcf.core.va.interfaces.IValueAdd; + +/** + * ValueAddsIterator + */ +public class ValueAddsIterator extends AbstractPeerStepGroupIterator { + + private IValueAdd[] valueAdds = null; + + /** + * Constructor. + */ + public ValueAddsIterator() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#initialize(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 initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + super.initialize(context, data, fullQualifiedId, monitor); + + valueAdds = ValueAddManager.getInstance().getValueAdd(getActivePeerContext(context, data, fullQualifiedId)); + + setIterations(valueAdds != null ? valueAdds.length : 0); + + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(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 internalNext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + StepperAttributeUtil.setProperty(ITcfStepAttributes.ATTR_VALUE_ADD, fullQualifiedId, data, valueAdds[getIteration()]); + } + +} 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 080cdca2c..672e2835d 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 @@ -10,12 +10,14 @@ 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.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.services.IPathMap; import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; @@ -46,7 +48,7 @@ public class ApplyPathMapsStep extends AbstractPeerStep { public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); if (channel == null || channel.getState() != IChannel.STATE_OPEN) { - throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing TCF channel")); //$NON-NLS-1$ + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Channel to target not available.")); //$NON-NLS-1$ } } @@ -54,25 +56,40 @@ public class ApplyPathMapsStep extends AbstractPeerStep { * @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, final ICallback callback) { + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final 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); final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); - final IPathMapService service = ServiceManager.getInstance().getService(peer, IPathMapService.class); - final IPathMap svc = channel.getRemoteService(IPathMap.class); - if (service != null && svc != null) { - // Apply the initial path map to the opened channel. - // This must happen outside the TCF dispatch thread as it may trigger - // the launch configuration change listeners. - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - service.applyPathMap(peer, true, callback); + + Runnable runnable = new Runnable() { + @Override + public void run() { + final IPathMapService service = ServiceManager.getInstance().getService(peer, IPathMapService.class); + final IPathMap svc = channel.getRemoteService(IPathMap.class); + if (service != null && svc != null) { + // Apply the initial path map to the opened channel. + // This must happen outside the TCF dispatch thread as it may trigger + // the launch configuration change listeners. + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + service.applyPathMap(peer, true, callback); + } + }); + thread.start(); + } else { + callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); } - }); - thread.start(); - } else { - callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); - } + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java index bae06eb14..6ac19ef1b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java @@ -10,12 +10,16 @@ package org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps; +import java.util.concurrent.atomic.AtomicReference; + +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.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; 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; @@ -48,49 +52,81 @@ public class ChainPeerStep extends AbstractPeerStep { */ @Override public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { - IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); - final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); + Assert.isNotNull(context); + Assert.isNotNull(data); + Assert.isNotNull(fullQualifiedId); + Assert.isNotNull(monitor); + Assert.isNotNull(callback); - if (channel == null) { - channel = peer.openChannel(); - } - else { - channel.redirect(peer.getAttributes()); - } + final AtomicReference channel = new AtomicReference((IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data)); + final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); - final IChannel finChannel = channel; - channel.addChannelListener(new IChannel.IChannelListener() { + Runnable runnable = new Runnable() { @Override - public void onChannelOpened() { - finChannel.removeChannelListener(this); - StepperAttributeUtil.setProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data, finChannel, true); - callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); - } + public void run() { + IChannel c = channel.get(); - @Override - public void onChannelClosed(Throwable error) { - // Remove ourself as listener from the channel - finChannel.removeChannelListener(this); - callback(data, fullQualifiedId, callback, StatusHelper.getStatus(error), null); - } + // If the channel is not yet opened, open it now. + // Otherwise redirect the channel to the next peer. + if (c == null) { + c = peer.openChannel(); + channel.set(c); + } else { + c.redirect(peer.getAttributes()); + } - @Override - public void congestionLevel(int level) { + // At this point, channel must not be null and + // channel.get and c must be the same + Assert.isNotNull(c); + Assert.isTrue(c.equals(channel.get())); + + c.addChannelListener(new IChannel.IChannelListener() { + @Override + public void onChannelOpened() { + channel.get().removeChannelListener(this); + StepperAttributeUtil.setProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data, channel.get(), true); + callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); + } + + @Override + public void onChannelClosed(Throwable error) { + // Remove ourself as listener from the channel + channel.get().removeChannelListener(this); + callback(data, fullQualifiedId, callback, StatusHelper.getStatus(error), null); + } + + @Override + public void congestionLevel(int level) { + } + }); } - }); + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } /* (non-Javadoc) * @see org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep#rollback(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.core.runtime.IStatus, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) */ @Override - public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { - IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); + public void rollback(final IStepContext context, final IPropertiesContainer data, final IStatus status, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { + final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); if (channel != null && channel.getState() != IChannel.STATE_CLOSED) { - channel.close(); - } + Runnable runnable = new Runnable() { + @SuppressWarnings("synthetic-access") + @Override + public void run() { + channel.close(); + ChainPeerStep.super.rollback(context, data, status, fullQualifiedId, monitor, callback); + } + }; - super.rollback(context, data, status, fullQualifiedId, monitor, callback); + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); + } else { + super.rollback(context, data, status, fullQualifiedId, monitor, callback); + } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/CloseChannelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/CloseChannelStep.java index 67d5dfd90..cc645a8de 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/CloseChannelStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/CloseChannelStep.java @@ -9,10 +9,12 @@ *******************************************************************************/ 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.Status; import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.Protocol; 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; @@ -43,11 +45,26 @@ public class CloseChannelStep extends AbstractPeerStep { * @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) { - IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); - if (channel != null && channel.getState() != IChannel.STATE_CLOSED) { - channel.close(); - } - callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final 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); + + Runnable runnable = new Runnable() { + @Override + public void run() { + if (channel != null && channel.getState() != IChannel.STATE_CLOSED) { + channel.close(); + } + callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/LaunchValueAddStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/LaunchValueAddStep.java index 0cbcdaa2c..bb3d432ac 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/LaunchValueAddStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/LaunchValueAddStep.java @@ -10,6 +10,7 @@ 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; @@ -53,6 +54,12 @@ public class LaunchValueAddStep extends AbstractPeerStep { */ @Override public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { + Assert.isNotNull(context); + Assert.isNotNull(data); + Assert.isNotNull(fullQualifiedId); + Assert.isNotNull(monitor); + Assert.isNotNull(callback); + final IValueAdd valueAdd = (IValueAdd)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_VALUE_ADD, fullQualifiedId, data); final String peerId = getActivePeerContext(context, data, fullQualifiedId).getID(); @@ -88,10 +95,11 @@ public class LaunchValueAddStep extends AbstractPeerStep { final String peerId = getActivePeerContext(context, data, fullQualifiedId).getID(); Runnable runnable = new Runnable() { - @Override + @SuppressWarnings("synthetic-access") + @Override public void run() { valueAdd.shutdown(peerId, callback); - if (callback != null) callback.done(this, Status.OK_STATUS); + LaunchValueAddStep.super.rollback(context, data, status, fullQualifiedId, monitor, callback); } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ShutdownValueAddStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ShutdownValueAddStep.java index 37fbbeb3f..c52b6aa2a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ShutdownValueAddStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ShutdownValueAddStep.java @@ -14,6 +14,7 @@ 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.Protocol; 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; @@ -42,7 +43,7 @@ public class ShutdownValueAddStep extends AbstractPeerStep { public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { IValueAdd valueAdd = (IValueAdd)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_VALUE_ADD, fullQualifiedId, data); if (valueAdd == null) { - throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing value add channel")); //$NON-NLS-1$ + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Value-add descriptor instance not set.")); //$NON-NLS-1$ } } @@ -50,10 +51,18 @@ public class ShutdownValueAddStep extends AbstractPeerStep { * @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, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { final IValueAdd valueAdd = (IValueAdd)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_VALUE_ADD, fullQualifiedId, data); final String peerId = getActivePeerContext(context, data, fullQualifiedId).getID(); - valueAdd.shutdown(peerId, callback); + Runnable runnable = new Runnable() { + @Override + public void run() { + valueAdd.shutdown(peerId, callback); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ChainPeersIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ChainPeersIterator.java deleted file mode 100644 index 11f1c99ea..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ChainPeersIterator.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * 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.iterators; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -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.IStepAttributes; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.core.interfaces.IPeerProperties; -import org.eclipse.tcf.te.tcf.core.util.persistence.PeerDataHelper; -import org.eclipse.tcf.te.tcf.core.va.ValueAddManager; -import org.eclipse.tcf.te.tcf.core.va.interfaces.IValueAdd; - -/** - * ChainPeersIterator - */ -public class ChainPeersIterator extends AbstractPeerStepGroupIterator { - - /* default */ final List peers = new ArrayList(); - - /** - * Constructor. - */ - public ChainPeersIterator() { - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#initialize(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 initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { - super.initialize(context, data, fullQualifiedId, monitor); - - final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); - final String peerId = peer.getID(); - - peers.clear(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - IValueAdd[] valueAdds = ValueAddManager.getInstance().getValueAdd(peer); - for (IValueAdd valueAdd : valueAdds) { - IPeer valueAddPeer = valueAdd.getPeer(peerId); - if (valueAddPeer != null) { - peers.add(valueAddPeer); - } - } - - String proxyConfiguration = peer.getAttributes().get(IPeerProperties.PROP_PROXIES); - if (proxyConfiguration != null) { - for (IPeer proxy : PeerDataHelper.decodePeerList(proxyConfiguration)) { - peers.add(proxy); - } - } - - peers.add(peer); - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - - setIterations(peers.size()); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(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 internalNext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { - StepperAttributeUtil.setProperty(IStepAttributes.ATTR_ACTIVE_CONTEXT, fullQualifiedId, data, peers.get(getIteration())); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ValueAddsIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ValueAddsIterator.java deleted file mode 100644 index 066264b4d..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ValueAddsIterator.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * 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.iterators; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -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.interfaces.steps.ITcfStepAttributes; -import org.eclipse.tcf.te.tcf.core.va.ValueAddManager; -import org.eclipse.tcf.te.tcf.core.va.interfaces.IValueAdd; - -/** - * ValueAddsIterator - */ -public class ValueAddsIterator extends AbstractPeerStepGroupIterator { - - private IValueAdd[] valueAdds = null; - - /** - * Constructor. - */ - public ValueAddsIterator() { - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#initialize(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 initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { - super.initialize(context, data, fullQualifiedId, monitor); - - valueAdds = ValueAddManager.getInstance().getValueAdd(getActivePeerContext(context, data, fullQualifiedId)); - - setIterations(valueAdds != null ? valueAdds.length : 0); - - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(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 internalNext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { - StepperAttributeUtil.setProperty(ITcfStepAttributes.ATTR_VALUE_ADD, fullQualifiedId, data, valueAdds[getIteration()]); - } - -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java index 4bd8d0201..5b774472e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java @@ -91,7 +91,6 @@ public class Messages extends NLS { public static String ChannelManager_openChannel_redirect_succeeded; public static String ChannelManager_openChannel_redirect_failed; public static String ChannelManager_openChannel_redirect_invalidChannelState; - public static String ChannelManager_createPeer_new_message; public static String ChannelManager_closeChannel_close_message; public static String ChannelManager_closeChannel_message; public static String ChannelManager_closeChannel_inuse_message; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties index 0da1b2ceb..4586af976 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties @@ -32,7 +32,6 @@ ChannelManager_openChannel_failed=Failed to open channel to {0}. Redirect Level ChannelManager_openChannel_redirect_succeeded=Successfully redirected channel from {0} to {1}. Redirect Level = {2} ChannelManager_openChannel_redirect_failed=Failed to redirect channel from {0} to {1}. ChannelManager_openChannel_redirect_invalidChannelState=Channel not in open state. Cannot redirect channel to {1}. -ChannelManager_createPeer_new_message=New target created. Target id = {0}, isTransient = {1} ChannelManager_closeChannel_message=Request to close channel. Target id = {0} ChannelManager_closeChannel_close_message=Closing channel. Target id = {0} ChannelManager_closeChannel_inuse_message=Channel not closed. Still in use. Target id = {0}, new reference count = {1} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java index 06523b44b..cf31d292c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java @@ -179,15 +179,20 @@ public class WaitForReadyStep extends AbstractPeerNodeStep { * @see org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep#rollback(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.core.runtime.IStatus, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) */ @Override - public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { + public void rollback(final IStepContext context, final IPropertiesContainer data, final IStatus status, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); - Protocol.invokeAndWait(new Runnable() { - @Override + + Runnable runnable = new Runnable() { + @SuppressWarnings("synthetic-access") + @Override public void run() { Tcf.getChannelManager().shutdown(peer); + WaitForReadyStep.super.rollback(context, data, status, fullQualifiedId, monitor, callback); } - }); - callback.done(this, Status.OK_STATUS); + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } /* (non-Javadoc) -- cgit v1.2.3