Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-05-15 04:43:39 -0400
committerTobias Schwarz2014-05-15 04:44:11 -0400
commit48fccf42e7c95b299c1d87646f9ed92c84ecd755 (patch)
treeeaa04293f6bf2ceef64f4845bf773d39fe218cde
parent01b90c8dd12a14515ef1418691d866ba4360a4de (diff)
downloadorg.eclipse.tcf-48fccf42e7c95b299c1d87646f9ed92c84ecd755.tar.gz
org.eclipse.tcf-48fccf42e7c95b299c1d87646f9ed92c84ecd755.tar.xz
org.eclipse.tcf-48fccf42e7c95b299c1d87646f9ed92c84ecd755.zip
Target Explorer: add target ping to check target still available
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartPingTimerStep.java119
5 files changed, 131 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties
index f45d6ca10..610a623bb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties
@@ -13,6 +13,7 @@ providerName = Eclipse.org - Target Explorer
# ***** Steps *****
+StartPingTimerStep.name=Start Ping Timer
CheckServiceStep.name=Check TCF Service
StartSimulatorStep.name=Start Simulator
StopSimulatorStep.name=Stop Simulator
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
index 5ec4136b3..493d638fe 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
@@ -181,6 +181,10 @@
id="org.eclipse.tcf.te.tcf.locator.waitForReadyStep"
class="org.eclipse.tcf.te.tcf.locator.steps.WaitForReadyStep"
label="%WaitForReadyStep.name"/>
+ <step
+ id="org.eclipse.tcf.te.tcf.locator.startPingTimerStep"
+ class="org.eclipse.tcf.te.tcf.locator.steps.StartPingTimerStep"
+ label="%StartPingTimerStep.name"/>
</extension>
<!-- Step group contributions -->
@@ -206,6 +210,7 @@
<reference id="org.eclipse.tcf.te.core.setConnectStateStep">
<parameter name="state" value="connected" />
</reference>
+ <reference id="org.eclipse.tcf.te.tcf.locator.startPingTimerStep"/>
</references>
</stepGroup>
@@ -256,6 +261,7 @@
<reference id="org.eclipse.tcf.te.core.setConnectStateStep">
<parameter name="state" value="connected" />
</reference>
+ <reference id="org.eclipse.tcf.te.tcf.locator.startPingTimerStep"/>
</references>
</stepGroup>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.java
index 0ee569779..30730e7b2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.java
@@ -75,4 +75,6 @@ public class Messages extends NLS {
public static String PeerNode_notification_message_disconnected;
public static String PeerNode_info_connectionLost;
public static String PeerNode_info_connectionDisconnected;
+
+ public static String StartPingTimerStep_warning_noDiagnosticsService;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties
index 2c39ce86c..42720c79f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties
@@ -17,4 +17,6 @@ PeerNode_notification_message_connectionLost=Connection lost
PeerNode_notification_message_connectionRecovered=Connection recovered
PeerNode_notification_message_disconnected=Connection disconnected
PeerNode_info_connectionLost=Connection to ''{0}'' lost
-PeerNode_info_connectionDisconnected=Connection to ''{0}'' disconnected \ No newline at end of file
+PeerNode_info_connectionDisconnected=Connection to ''{0}'' disconnected
+
+StartPingTimerStep_warning_noDiagnosticsService=Missing Diagnostics service in ''{0}'' TCF agent.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartPingTimerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartPingTimerStep.java
new file mode 100644
index 000000000..8acfc38b5
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartPingTimerStep.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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.locator.steps;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IDiagnostics;
+import org.eclipse.tcf.te.core.interfaces.IConnectable;
+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.interfaces.steps.ITcfStepAttributes;
+import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.nls.Messages;
+import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
+
+/**
+ * Start ping timer step implementation.
+ */
+public class StartPingTimerStep extends AbstractPeerNodeStep {
+
+ /**
+ * Constructor.
+ */
+ public StartPingTimerStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#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(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final 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 or closed channel")); //$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(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
+ SimulatorUtils.Result result = SimulatorUtils.getSimulatorService(getActivePeerModelContext(context, data, fullQualifiedId));
+
+ if (result == null) {
+ final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data);
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ final IPeerNode peerNode = getActivePeerModelContext(context, data, fullQualifiedId);
+ final String name = peerNode.getName();
+ final IDiagnostics diagnostics = channel.getRemoteService(IDiagnostics.class);
+ if (diagnostics != null) {
+ final Timer pingTimer = new Timer(name + " ping"); //$NON-NLS-1$
+ TimerTask pingTask = new TimerTask() {
+ final Timer thisTimer = pingTimer;
+ final AtomicBoolean running = new AtomicBoolean(false);
+ @Override
+ public void run() {
+ if (!running.get()) {
+ running.set(true);
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ if (peerNode.getConnectState() == IConnectable.STATE_CONNECTED) {
+ diagnostics.echo("ping", new IDiagnostics.DoneEcho() { //$NON-NLS-1$
+ @Override
+ public void doneEcho(IToken token, Throwable error, String s) {
+ running.set(false);
+ if (error != null) {
+ thisTimer.cancel();
+ }
+ }
+ });
+ }
+ else {
+ thisTimer.cancel();
+ }
+ }
+ });
+ }
+ }
+ };
+ pingTimer.schedule(pingTask, 10000, 10000);
+ }
+ else if (Platform.inDebugMode()) {
+ Platform.getLog(CoreBundleActivator.getDefault().getBundle()).log(new Status(IStatus.WARNING,
+ CoreBundleActivator.getUniqueIdentifier(),
+ NLS.bind(Messages.StartPingTimerStep_warning_noDiagnosticsService, name)));
+ }
+ }
+ });
+ }
+
+ callback(data, fullQualifiedId, callback, Status.OK_STATUS, null);
+ }
+}

Back to the top