Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-10-30 11:55:47 +0000
committerTobias Schwarz2014-10-30 11:55:47 +0000
commitbfb46d490f8017620ba0c4d3c732b4f2ef652d15 (patch)
tree7fd8e0d23f8376072c5825c503aee77306abd12c
parente4646dba8596b42781d0f1cf5c9876fe2ce18d0c (diff)
downloadorg.eclipse.tcf-bfb46d490f8017620ba0c4d3c732b4f2ef652d15.tar.gz
org.eclipse.tcf-bfb46d490f8017620ba0c4d3c732b4f2ef652d15.tar.xz
org.eclipse.tcf-bfb46d490f8017620ba0c4d3c732b4f2ef652d15.zip
SM: add progress monitor to channel manager interface to be able to join
channel manager job with running job
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java53
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/CloseChannelStep.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/OpenChannelStep.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java2
6 files changed, 72 insertions, 10 deletions
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 dc6850971..44bfb9ac5 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
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.tcf.core.interfaces;
import java.util.Map;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IPeer;
@@ -90,6 +91,8 @@ public interface IChannelManager extends IAdaptable {
*/
public void openChannel(IPeer peer, Map<String, Boolean> flags, DoneOpenChannel done);
+ public void openChannel(IPeer peer, Map<String, Boolean> flags, DoneOpenChannel done, IProgressMonitor monitor);
+
/**
* Returns the shared channel instance for the given peer. Channels retrieved using this
* method cannot be closed by the caller.
@@ -118,6 +121,8 @@ public interface IChannelManager extends IAdaptable {
*/
public void closeChannel(IChannel channel);
+ public void closeChannel(IChannel channel, IProgressMonitor monitor);
+
/**
* Shutdown the communication to the given peer, no matter of the current
* reference count. A possible associated value-add is shutdown as well.
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 deda18f44..fc10ac499 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
@@ -18,6 +18,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.osgi.util.NLS;
@@ -80,6 +81,14 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
*/
@Override
public void openChannel(final IPeer peer, final Map<String, Boolean> flags, final DoneOpenChannel done) {
+ openChannel(peer, flags, done, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#openChannel(org.eclipse.tcf.protocol.IPeer, java.util.Map, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void openChannel(final IPeer peer, final Map<String, Boolean> flags, final DoneOpenChannel done, final IProgressMonitor monitor) {
Assert.isNotNull(peer);
Assert.isNotNull(done);
@@ -280,7 +289,19 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
job = new StepperJob(name != null ? name : "", stepContext, stepperOperationService.getStepGroupData(peer, IStepperServiceOperations.OPEN_CHANNEL, data), stepGroupId, IStepperServiceOperations.OPEN_CHANNEL, isCancelable, true); //$NON-NLS-1$
job.setJobCallback(callback);
job.markStatusHandled();
- job.schedule();
+ if (monitor != null) {
+ final StepperJob finalJob = job;
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ finalJob.run(monitor);
+ }
+ }, "Open channel to " + job.getName()); //$NON-NLS-1$
+ thread.start();
+ }
+ else {
+ job.schedule();
+ }
}
// Remember the "open channel" stepper job until finished (shared channels only)
@@ -357,11 +378,19 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
*/
@Override
public void closeChannel(final IChannel channel) {
+ closeChannel(channel, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#closeChannel(org.eclipse.tcf.protocol.IChannel)
+ */
+ @Override
+ public void closeChannel(final IChannel channel, final IProgressMonitor monitor) {
Runnable runnable = new Runnable() {
@Override
public void run() {
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- internalCloseChannel(channel);
+ internalCloseChannel(channel, monitor);
}
};
if (Protocol.isDispatchThread()) runnable.run();
@@ -378,7 +407,7 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
*
* @param channel The channel. Must not be <code>null</code>.
*/
- /* default */ void internalCloseChannel(final IChannel channel) {
+ /* default */ void internalCloseChannel(final IChannel channel, final IProgressMonitor monitor) {
Assert.isNotNull(channel);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
@@ -525,7 +554,19 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
job = new StepperJob(name != null ? name : "", stepContext, stepperOperationService.getStepGroupData(peer, IStepperServiceOperations.CLOSE_CHANNEL, data), stepGroupId, IStepperServiceOperations.CLOSE_CHANNEL, isCancelable, true); //$NON-NLS-1$
job.setJobCallback(callback);
job.markStatusHandled();
- job.schedule();
+ if (monitor != null) {
+ final StepperJob finalJob = job;
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ finalJob.run(monitor);
+ }
+ }, "Close channel to " + job.getName()); //$NON-NLS-1$
+ thread.start();
+ }
+ else {
+ job.schedule();
+ }
}
// Remember the "close channel" stepper job until finished
@@ -605,7 +646,7 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
refCounters.remove(channel);
// Close the channel
- internalCloseChannel(channel);
+ internalCloseChannel(channel, null);
}
}
@@ -642,7 +683,7 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
refCounters.clear();
channels.clear();
- for (IChannel channel : openChannels) internalCloseChannel(channel);
+ for (IChannel channel : openChannels) internalCloseChannel(channel, null);
c2p.clear();
}
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 f34882be2..56356d01f 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
@@ -155,4 +155,12 @@ public class ChainPeerStep extends AbstractPeerStep {
super.rollback(context, data, status, fullQualifiedId, monitor, callback);
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep#getCancelTimeout()
+ */
+ @Override
+ public int getCancelTimeout() {
+ return 500;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/CloseChannelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/CloseChannelStep.java
index c33878b5c..3c451ba49 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/CloseChannelStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/CloseChannelStep.java
@@ -46,7 +46,7 @@ public class CloseChannelStep extends AbstractPeerStep {
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) {
- Tcf.getChannelManager().closeChannel(channel);
+ Tcf.getChannelManager().closeChannel(channel, monitor);
}
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/steps/OpenChannelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/OpenChannelStep.java
index 7c07759ce..f441ca4f1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/OpenChannelStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/steps/OpenChannelStep.java
@@ -53,7 +53,7 @@ public class OpenChannelStep extends AbstractPeerStep {
StepperAttributeUtil.setProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId.getParentId(), data, channel);
callback(data, fullQualifiedId, callback, StatusHelper.getStatus(error), null);
}
- });
+ }, monitor);
}
/* (non-Javadoc)
@@ -64,8 +64,16 @@ public class OpenChannelStep extends AbstractPeerStep {
IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data);
if (channel != null && channel.getState() != IChannel.STATE_CLOSED) {
ProgressHelper.setSubTaskName(monitor, "Closing TCF channel"); //$NON-NLS-1$
- Tcf.getChannelManager().closeChannel(channel);
+ Tcf.getChannelManager().closeChannel(channel, monitor);
}
super.rollback(context, data, status, fullQualifiedId, monitor, callback);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep#getCancelTimeout()
+ */
+ @Override
+ public int getCancelTimeout() {
+ return 500;
+ }
}
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 633b97b58..3cc07984c 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
@@ -165,7 +165,7 @@ public class WaitForReadyStep extends AbstractPeerNodeStep {
ProgressHelper.worked(monitor, 1);
Protocol.invokeLater(refreshCount < 20 ? 500 : 1000, thisRunnable);
}
- });
+ }, monitor);
}
}
});

Back to the top