public void TestDuckTyping([Values(true, false)] bool local) { var svc = new TestIgniteServicePortable { TestProperty = 33 }; // Deploy locally or to the remote node var nodeId = (local ? Grid1 : Grid2).Cluster.LocalNode.Id; var cluster = Grid1.Cluster.ForNodeIds(nodeId); cluster.Services().DeployNodeSingleton(SvcName, svc); // Get proxy var prx = Services.GetServiceProxy <ITestIgniteServiceProxyInterface>(SvcName); // NodeId signature is the same as in service Assert.AreEqual(nodeId, prx.NodeId); // Method signature is different from service signature (object -> object), but is compatible. Assert.AreEqual(15, prx.Method(15)); // TestProperty is object in proxy and int in service, getter works.. Assert.AreEqual(33, prx.TestProperty); // .. but setter does not var ex = Assert.Throws <ServiceInvocationException>(() => { prx.TestProperty = new object(); }); Assert.AreEqual("Object of type 'System.Object' cannot be converted to type 'System.Int32'.", ex.InnerException.Message); }
public void TestDeployKeyAffinitySingleton() { var svc = new TestIgniteServicePortable(); Services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, AffKey); var affNode = Grid1.Affinity(CacheName).MapKeyToNode(AffKey); var prx = Services.GetServiceProxy <ITestIgniteService>(SvcName); Assert.AreEqual(affNode.Id, prx.NodeId); }
public void TestDeployKeyAffinitySingletonPortable() { var services = Services.WithKeepPortable(); var svc = new TestIgniteServicePortable(); var affKey = new PortableObject { Val = AffKey }; services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, affKey); var prx = services.GetServiceProxy <ITestIgniteService>(SvcName); Assert.IsTrue(prx.Initialized); }
public void TestWithKeepPortableBoth() { var svc = new TestIgniteServicePortable(); // Deploy to grid2 Grid1.Cluster.ForNodeIds(Grid2.Cluster.LocalNode.Id).Services().WithKeepPortable().WithServerKeepPortable() .DeployNodeSingleton(SvcName, svc); // Get proxy var prx = Services.WithKeepPortable().WithServerKeepPortable().GetServiceProxy <ITestIgniteService>(SvcName); var obj = new PortableObject { Val = 11 }; var res = (IPortableObject)prx.Method(obj); Assert.AreEqual(11, res.Deserialize <PortableObject>().Val); res = (IPortableObject)prx.Method(Grid1.Portables().ToPortable <IPortableObject>(obj)); Assert.AreEqual(11, res.Deserialize <PortableObject>().Val); }
public void TestWithKeepPortableBoth() { var svc = new TestIgniteServicePortable(); // Deploy to grid2 Grid1.Cluster.ForNodeIds(Grid2.Cluster.LocalNode.Id).Services().WithKeepPortable().WithServerKeepPortable() .DeployNodeSingleton(SvcName, svc); // Get proxy var prx = Services.WithKeepPortable().WithServerKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName); var obj = new PortableObject { Val = 11 }; var res = (IPortableObject)prx.Method(obj); Assert.AreEqual(11, res.Deserialize<PortableObject>().Val); res = (IPortableObject)prx.Method(Grid1.Portables().ToPortable<IPortableObject>(obj)); Assert.AreEqual(11, res.Deserialize<PortableObject>().Val); }
public void TestDuckTyping([Values(true, false)] bool local) { var svc = new TestIgniteServicePortable {TestProperty = 33}; // Deploy locally or to the remote node var nodeId = (local ? Grid1 : Grid2).Cluster.LocalNode.Id; var cluster = Grid1.Cluster.ForNodeIds(nodeId); cluster.Services().DeployNodeSingleton(SvcName, svc); // Get proxy var prx = Services.GetServiceProxy<ITestIgniteServiceProxyInterface>(SvcName); // NodeId signature is the same as in service Assert.AreEqual(nodeId, prx.NodeId); // Method signature is different from service signature (object -> object), but is compatible. Assert.AreEqual(15, prx.Method(15)); // TestProperty is object in proxy and int in service, getter works.. Assert.AreEqual(33, prx.TestProperty); // .. but setter does not var ex = Assert.Throws<ServiceInvocationException>(() => { prx.TestProperty = new object(); }); Assert.AreEqual("Object of type 'System.Object' cannot be converted to type 'System.Int32'.", ex.InnerException.Message); }
public void TestDeployKeyAffinitySingletonPortable() { var services = Services.WithKeepPortable(); var svc = new TestIgniteServicePortable(); var affKey = new PortableObject {Val = AffKey}; services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, affKey); var prx = services.GetServiceProxy<ITestIgniteService>(SvcName); Assert.IsTrue(prx.Initialized); }
public void TestDeployKeyAffinitySingleton() { var svc = new TestIgniteServicePortable(); Services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, AffKey); var affNode = Grid1.Affinity(CacheName).MapKeyToNode(AffKey); var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName); Assert.AreEqual(affNode.Id, prx.NodeId); }