Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-08-13 16:44:11 +0000
committerUwe Stieber2013-08-13 16:44:11 +0000
commitee9b181ea290f19ad5c918edc8ec5a9150b05449 (patch)
tree7118e330fa378dd617ae5ecf40f1cbe76b8c4b3b /target_explorer
parent707190b2fca91b375903afacfd1fc6e2f82656d8 (diff)
downloadorg.eclipse.tcf-ee9b181ea290f19ad5c918edc8ec5a9150b05449.tar.gz
org.eclipse.tcf-ee9b181ea290f19ad5c918edc8ec5a9150b05449.tar.xz
org.eclipse.tcf-ee9b181ea290f19ad5c918edc8ec5a9150b05449.zip
Target Explorer: Further improvements to the Locator.getPeers handling
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java56
1 files changed, 38 insertions, 18 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
index aa289897f..ea6dd2791 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
@@ -296,16 +296,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, new Peer(attrs));
}
- String remoteIP = channel.getRemotePeer().getAttributes().get(IPeer.ATTR_IP_HOST);
- boolean isLocal = remoteIP != null && IPAddressUtil.getInstance().isLocalHost(remoteIP);
-
- boolean isCLI = channel.getRemotePeer().getName() != null
- && (channel.getRemotePeer().getName().startsWith("Eclipse CLI") //$NON-NLS-1$
- || channel.getRemotePeer().getName().endsWith("CLI Server") //$NON-NLS-1$
- || channel.getRemotePeer().getName().endsWith("CLI Client")); //$NON-NLS-1$
- if (isLocal || isCLI) {
- onDone(peerNode, changed);
- } else {
+ if (isGetPeersAllowed(channel)) {
// Get the peers from the remote locator
getPeers(channel, model, ip, new Callback() {
@Override
@@ -314,6 +305,8 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
onDone(peerNode, changed);
}
});
+ } else {
+ onDone(peerNode, changed);
}
}
});
@@ -322,14 +315,18 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
onDone(peerNode, changed);
}
} else {
- // Get the peers from the remote locator
- getPeers(channel, model, ip, new Callback() {
- @Override
- protected void internalDone(Object caller, IStatus status) {
- // Complete
- onDone(peerNode, changed);
- }
- });
+ if (isGetPeersAllowed(channel)) {
+ // Get the peers from the remote locator
+ getPeers(channel, model, ip, new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ // Complete
+ onDone(peerNode, changed);
+ }
+ });
+ } else {
+ onDone(peerNode, changed);
+ }
}
} else {
// Complete
@@ -338,6 +335,29 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
}
/**
+ * Returns if or if not "getPeers" is allowed for the given channel.
+ *
+ * @param channel The channel. Must not be <code>null</code>.
+ * @return <code>True</code> if "getPeers" is allowed, <code>false</code> otherwise.
+ */
+ /* default */ boolean isGetPeersAllowed(IChannel channel) {
+ String remoteIP = channel.getRemotePeer().getAttributes().get(IPeer.ATTR_IP_HOST);
+ boolean isLocal = remoteIP != null && IPAddressUtil.getInstance().isLocalHost(remoteIP);
+
+ boolean isCLI = channel.getRemotePeer().getName() != null
+ && (channel.getRemotePeer().getName().startsWith("Eclipse CLI") //$NON-NLS-1$
+ || channel.getRemotePeer().getName().endsWith("CLI Server") //$NON-NLS-1$
+ || channel.getRemotePeer().getName().endsWith("CLI Client")); //$NON-NLS-1$
+
+ isCLI |= channel.getLocalPeer().getName() != null
+ && (channel.getLocalPeer().getName().startsWith("Eclipse CLI") //$NON-NLS-1$
+ || channel.getLocalPeer().getName().endsWith("CLI Server") //$NON-NLS-1$
+ || channel.getLocalPeer().getName().endsWith("CLI Client")); //$NON-NLS-1$
+
+ return !isLocal && !isCLI;
+ }
+
+ /**
* Query the peers from the remote locator.
*
* @param channel The channel. Must not be <code>null</code>.

Back to the top