Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tcf-dev] Multiple agents on localhost?

Hello,

I would like to run multiple agents on localhost. When I invoke
tcf-agent -i and issue peers, I can see all
all agents properly set up. Eclipse Target Explorer's System Management
View does only display a single
tcf-agent for localhost. I believe, that
org.eclipse.tcf.te.tcf.locator.nodes.LocatorModel.validatePeer() causes
this behavior.
validatePeer() tries to find a local interface for a peer, and remove
all other interfaces for this peer, if the
peer is using a TCP or SSL channel. Because validatePeer() does not take
the port (a TCP host:port-tuple is sufficient to distinguish two peers)
of the agent into account, different peers are assumed identical.

A patch, that seems to fix this problem, is attached.

Kind regards,

Michael Jahn

diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java
index 83d57bf..d9d8b47 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java
@@ -278,8 +278,9 @@
 		String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress();
 		// Get the canonical address
 		String canonical = IPAddressUtil.getInstance().getIPv4CanonicalAddress();
-		// Get the peer IP
+		// Get the peer IP and port
 		String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST);
+		String peerPort = peer.getAttributes().get(IPeer.ATTR_IP_PORT);
 
 		// If the new peer IP is not a local host address, we are done checking
 		if (!IPAddressUtil.getInstance().isLocalHost(peerIP)) return result;
@@ -291,12 +292,16 @@
 		for (Entry<String, IPeer> entry : peers.entrySet()) {
 			// Get the IP address from peers with transport type TCP or SSL
 			IPeer candidate = entry.getValue();
-			if (ITransportTypes.TRANSPORT_TYPE_TCP.equals(candidate.getTransportName()) || ITransportTypes.TRANSPORT_TYPE_SSL.equals(candidate.getTransportName())) {
+			if (ITransportTypes.TRANSPORT_TYPE_TCP.equals(candidate.getTransportName())
+							|| ITransportTypes.TRANSPORT_TYPE_SSL.equals(candidate.getTransportName())) {
+
 				String ip = candidate.getAttributes().get(IPeer.ATTR_IP_HOST);
 				Assert.isNotNull(ip);
+				String port = candidate.getAttributes().get(IPeer.ATTR_IP_PORT);
+				Assert.isNotNull(port);
 
 				// If the IP is for localhost, we have to do additional checking
-				if (IPAddressUtil.getInstance().isLocalHost(ip)) {
+				if (IPAddressUtil.getInstance().isLocalHost(ip) && port.equals(peerPort)) {
 					// If the IP of the peer already in the model is the loopback address,
 					// ignore all other.
 					if (ip.equals(loopback)) { result = null; break; }

Back to the top