public void TopologyHelper_Client_PlugIn() { LeafRouter router = null; ITopologyProvider cluster = null; System.Type type; try { router = CreateLeaf("detached", "hub", Helper.NewGuid().ToString(), group); type = typeof(BasicTopology); Config.SetConfig(string.Format("topology-type={0}:{1}\r\nargs=cluster-ep=logical://foo", type.FullName, type.Assembly.Location)); cluster = TopologyHelper.OpenClient(router, "topology-type", "args"); Assert.AreEqual(type.FullName, cluster.GetType().FullName); Assert.IsTrue(cluster.IsClient); } finally { if (cluster != null) { cluster.Close(); } if (router != null) { router.Stop(); } Config.SetConfig(null); } }
private static StaticHashedTopology OpenClient(MsgRouter router, string clusterEP) { System.Type type = typeof(StaticHashedTopology); Config.SetConfig(string.Format(ClusterConfig, type.FullName, type.Assembly.Location, clusterEP, "")); return((StaticHashedTopology)TopologyHelper.OpenClient(router, "clusterType", "clusterArgs")); }
public void TopologyHelper_Server_PlugIn() { LeafRouter client = null; LeafRouter server = null; ITopologyProvider clientCluster = null; ITopologyProvider serverCluster = null; System.Type type; PropertyMsg reply; try { client = CreateLeaf("detached", "hub", Helper.NewGuid().ToString(), group); server = CreateLeaf("detached", "hub", Helper.NewGuid().ToString(), group); type = typeof(BasicTopology); Config.SetConfig(string.Format("topology-type={0}:{1}\r\nargs=cluster-ep=logical://foo", type.FullName, type.Assembly.Location)); clientCluster = TopologyHelper.OpenClient(client, "topology-type", "args"); Assert.AreEqual(type.FullName, clientCluster.GetType().FullName); Assert.IsTrue(clientCluster.IsClient); Config.SetConfig(string.Format("topology-type={0}:{1}\r\nargs=cluster-ep=logical://foo", type.FullName, type.Assembly.Location)); serverCluster = TopologyHelper.OpenServer(client, "A", this, "topology-type", "args"); Assert.AreEqual(type.FullName, serverCluster.GetType().FullName); Assert.IsFalse(serverCluster.IsClient); Thread.Sleep(2000); reply = (PropertyMsg)clientCluster.Query(null, new PropertyMsg()); Assert.AreEqual("Hello World!", reply["value"]); } finally { if (client != null) { client.Stop(); } if (server != null) { server.Stop(); } if (clientCluster != null) { clientCluster.Close(); } if (serverCluster != null) { serverCluster.Close(); } Config.SetConfig(null); } }