Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2010-06-29 21:42:39 +0000
committereutarass2010-06-29 21:42:39 +0000
commite07bb1ae00d4f83f7aaa021e65a89f1f946f9da2 (patch)
treedc737cfa152e4f224a7bea46f86dffc951b6c912 /plugins
parentbce270b8c93af8377de9bd6d90c307669c7ca8a7 (diff)
downloadorg.eclipse.tcf-e07bb1ae00d4f83f7aaa021e65a89f1f946f9da2.tar.gz
org.eclipse.tcf-e07bb1ae00d4f83f7aaa021e65a89f1f946f9da2.tar.xz
org.eclipse.tcf-e07bb1ae00d4f83f7aaa021e65a89f1f946f9da2.zip
Bug 317845: TCF Peer accessible via two networks appear as two distinct peers
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java4
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java6
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java10
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractPeer.java14
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ServerTCP.java16
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java29
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/Protocol.java11
7 files changed, 84 insertions, 6 deletions
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java
index 6c38ba360..00142ee30 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java
@@ -14,6 +14,8 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.tm.tcf.core.AbstractPeer;
+import org.eclipse.tm.tcf.protocol.IPeer;
+import org.eclipse.tm.tcf.protocol.Protocol;
/**
* LocalPeer object represents local end-point of TCF communication channel.
@@ -27,6 +29,8 @@ public class LocalPeer extends AbstractPeer {
private static Map<String,String> createAttributes() {
Map<String, String> attrs = new HashMap<String, String>();
attrs.put(ATTR_ID, "TCFLocal");
+ attrs.put(IPeer.ATTR_SERVICE_MANGER_ID, ServiceManager.getID());
+ attrs.put(IPeer.ATTR_AGENT_ID, Protocol.getAgentID());
attrs.put(ATTR_NAME, "Local Peer");
attrs.put(ATTR_OS_NAME, System.getProperty("os.name"));
attrs.put(ATTR_TRANSPORT_NAME, "Loop");
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java
index 413df7e97..e0eb9f8a8 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java
@@ -49,6 +49,12 @@ public class ServiceManager {
});
}
+ public static String getID() {
+ // In current implementation ServiceManager is a singleton,
+ // so its ID is same as agent ID.
+ return Protocol.getAgentID();
+ }
+
public static synchronized void addServiceProvider(IServiceProvider provider) {
providers.add(provider);
}
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java
index e484f1693..3415fa321 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java
@@ -54,6 +54,16 @@ public class LocatorProxy implements ILocator {
return attrs.get(ATTR_ID);
}
+ public String getServiceManagerID() {
+ assert Protocol.isDispatchThread();
+ return attrs.get(ATTR_SERVICE_MANGER_ID);
+ }
+
+ public String getAgentID() {
+ assert Protocol.isDispatchThread();
+ return attrs.get(ATTR_AGENT_ID);
+ }
+
public String getName() {
assert Protocol.isDispatchThread();
return attrs.get(ATTR_NAME);
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractPeer.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractPeer.java
index 09d4dcadd..9423b9de9 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractPeer.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractPeer.java
@@ -38,10 +38,10 @@ public class AbstractPeer implements IPeer {
public AbstractPeer(Map<String,String> attrs) {
assert Protocol.isDispatchThread();
if (attrs != null) {
- rw_attrs = new HashMap<String, String>(attrs);
+ rw_attrs = new HashMap<String,String>(attrs);
}
else {
- rw_attrs = new HashMap<String, String>();
+ rw_attrs = new HashMap<String,String>();
}
ro_attrs = Collections.unmodifiableMap(rw_attrs);
assert getID() != null;
@@ -165,6 +165,16 @@ public class AbstractPeer implements IPeer {
return ro_attrs.get(ATTR_ID);
}
+ public String getServiceManagerID() {
+ assert Protocol.isDispatchThread();
+ return ro_attrs.get(ATTR_SERVICE_MANGER_ID);
+ }
+
+ public String getAgentID() {
+ assert Protocol.isDispatchThread();
+ return ro_attrs.get(ATTR_AGENT_ID);
+ }
+
public String getName() {
assert Protocol.isDispatchThread();
return ro_attrs.get(ATTR_NAME);
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ServerTCP.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ServerTCP.java
index d9af4610c..6b85a5842 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ServerTCP.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ServerTCP.java
@@ -17,11 +17,13 @@ import java.net.NetworkInterface;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.tm.internal.tcf.core.ServiceManager;
import org.eclipse.tm.tcf.protocol.IChannel;
import org.eclipse.tm.tcf.protocol.IPeer;
import org.eclipse.tm.tcf.protocol.Protocol;
@@ -45,7 +47,7 @@ public class ServerTCP extends ServerSocket {
private final Map<String,String> attrs;
TransientPeer(Map<String,String> attrs) {
- this.attrs = attrs;
+ this.attrs = Collections.unmodifiableMap(attrs);
}
public Map<String, String> getAttributes() {
@@ -56,6 +58,16 @@ public class ServerTCP extends ServerSocket {
return attrs.get(ATTR_ID);
}
+ public String getServiceManagerID() {
+ assert Protocol.isDispatchThread();
+ return attrs.get(ATTR_SERVICE_MANGER_ID);
+ }
+
+ public String getAgentID() {
+ assert Protocol.isDispatchThread();
+ return attrs.get(ATTR_AGENT_ID);
+ }
+
public String getName() {
return attrs.get(ATTR_NAME);
}
@@ -134,6 +146,8 @@ public class ServerTCP extends ServerSocket {
String port = Integer.toString(getLocalPort());
Map<String,String> attrs = new HashMap<String,String>();
attrs.put(IPeer.ATTR_ID, "TCP:" + host + ":" + port);
+ attrs.put(IPeer.ATTR_SERVICE_MANGER_ID, ServiceManager.getID());
+ attrs.put(IPeer.ATTR_AGENT_ID, Protocol.getAgentID());
attrs.put(IPeer.ATTR_NAME, name);
attrs.put(IPeer.ATTR_OS_NAME, System.getProperty("os.name"));
attrs.put(IPeer.ATTR_TRANSPORT_NAME, "TCP");
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java
index c7e2bb6ec..6ec39d070 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java
@@ -19,6 +19,13 @@ import java.util.Map;
* List of currently known peers can be retrieved by
* calling ILocator.getPeers()
*
+ * A TCF agent houses one or more service managers. A service manager has a one or more
+ * services to expose to the world. The service manager creates one or more peers
+ * to represent itself, one for every access path the agent is
+ * reachable by. For example, in agents accessible via TCP/IP, the
+ * service manger would create a peer for every subnet it wants to participate in.
+ * All peers of particular service manager represent identical sets of services.
+ *
* @noimplement This interface is not intended to be implemented by clients.
* Client can extends the abstract IPeer implementation: AbstractPeer.
*/
@@ -31,6 +38,12 @@ public interface IPeer {
/** Peer unique ID */
ATTR_ID = "ID",
+ /** Unique ID of service manager that is represented by this peer */
+ ATTR_SERVICE_MANGER_ID = "ServiceManagerID",
+
+ /** Agent unique ID */
+ ATTR_AGENT_ID = "AgentID",
+
/** Peer name */
ATTR_NAME = "Name",
@@ -67,24 +80,34 @@ public interface IPeer {
String getID();
/**
+ * @return service manager unique ID, same as getAttributes().get(ATTR_SERVICE_MANAGER_ID)
+ */
+ String getServiceManagerID();
+
+ /**
+ * @return agent unique ID, same as getAttributes().get(ATTR_AGENT_ID)
+ */
+ String getAgentID();
+
+ /**
* @return peer name, same as getAttributes().get(ATTR_NAME)
*/
String getName();
/**
- * Same as getAttributes().get(ATTR_OS_NAME)
+ * @return agent OS name, same as getAttributes().get(ATTR_OS_NAME)
*/
String getOSName();
/**
- * Same as getAttributes().get(ATTR_TRANSPORT_NAME)
+ * @return transport name, same as getAttributes().get(ATTR_TRANSPORT_NAME)
*/
String getTransportName();
/**
* Open channel to communicate with this peer.
* Note: the channel is not fully open yet when this method returns.
- * It’s state is IChannel.STATE_OPENNING.
+ * Its state is IChannel.STATE_OPENNING.
* Protocol.Listener will be called when the channel will be opened or closed.
*/
IChannel openChannel();
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/Protocol.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/Protocol.java
index b80e489d4..24902a26c 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/Protocol.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/Protocol.java
@@ -12,6 +12,7 @@ package org.eclipse.tm.tcf.protocol;
import java.util.ArrayList;
import java.util.TreeSet;
+import java.util.UUID;
import org.eclipse.tm.internal.tcf.core.LocalPeer;
import org.eclipse.tm.internal.tcf.core.ServiceManager;
@@ -40,6 +41,7 @@ public final class Protocol {
private static IEventQueue event_queue;
private static ILogger logger;
private static final TreeSet<Timer> timer_queue = new TreeSet<Timer>();
+ private static final String agent_id = UUID.randomUUID().toString();
private static int timer_cnt;
private static class Timer implements Comparable<Timer>{
@@ -255,6 +257,15 @@ public final class Protocol {
}
/**
+ * Get TCF agent unique ID.
+ * The intent of the ID is to enable distributed systems to uniquely identify instances of TCF agents.
+ * @return the agent ID.
+ */
+ public static String getAgentID() {
+ return agent_id;
+ }
+
+ /**
* Get instance of the framework locator service.
* The service can be used to discover available remote peers.
*

Back to the top