public void TestDuckTyping([Values(true, false)] bool local) { var svc = new TestIgniteServiceBinarizable { TestProperty = 33 }; // Deploy locally or to the remote node var nodeId = (local ? Grid1 : Grid2).GetCluster().GetLocalNode().Id; var cluster = Grid1.GetCluster().ForNodeIds(nodeId); cluster.GetServices().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 TestIgniteServiceBinarizable(); Services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, AffKey); var affNode = Grid1.GetAffinity(CacheName).MapKeyToNode(AffKey); var prx = Services.GetServiceProxy <ITestIgniteService>(SvcName); Assert.AreEqual(affNode.Id, prx.NodeId); }
public void TestDeployKeyAffinitySingletonBinarizable() { var services = Services.WithKeepBinary(); var svc = new TestIgniteServiceBinarizable(); var affKey = new BinarizableObject { Val = AffKey }; services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, affKey); var prx = services.GetServiceProxy <ITestIgniteService>(SvcName); Assert.IsTrue(prx.Initialized); }
public void TestWithKeepBinaryBoth() { var svc = new TestIgniteServiceBinarizable(); // Deploy to grid2 Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepBinary().WithServerKeepBinary() .DeployNodeSingleton(SvcName, svc); // Get proxy var prx = Services.WithKeepBinary().WithServerKeepBinary().GetServiceProxy <ITestIgniteService>(SvcName); var obj = new BinarizableObject { Val = 11 }; var res = (IBinaryObject)prx.Method(obj); Assert.AreEqual(11, res.Deserialize <BinarizableObject>().Val); res = (IBinaryObject)prx.Method(Grid1.GetBinary().ToBinary <IBinaryObject>(obj)); Assert.AreEqual(11, res.Deserialize <BinarizableObject>().Val); }
public void TestWithKeepBinaryBoth() { var svc = new TestIgniteServiceBinarizable(); // Deploy to grid2 Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepBinary().WithServerKeepBinary() .DeployNodeSingleton(SvcName, svc); // Get proxy var prx = Services.WithKeepBinary().WithServerKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName); var obj = new BinarizableObject { Val = 11 }; var res = (IBinaryObject)prx.Method(obj); Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val); res = (IBinaryObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj)); Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val); }
public void TestDuckTyping([Values(true, false)] bool local) { var svc = new TestIgniteServiceBinarizable {TestProperty = 33}; // Deploy locally or to the remote node var nodeId = (local ? Grid1 : Grid2).GetCluster().GetLocalNode().Id; var cluster = Grid1.GetCluster().ForNodeIds(nodeId); cluster.GetServices().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("Specified cast is not valid.", ex.InnerException.Message); }
public void TestDeployKeyAffinitySingletonBinarizable() { var services = Services.WithKeepBinary(); var svc = new TestIgniteServiceBinarizable(); var affKey = new BinarizableObject {Val = AffKey}; services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, affKey); var prx = services.GetServiceProxy<ITestIgniteService>(SvcName); Assert.IsTrue(prx.Initialized); }
public void TestDeployKeyAffinitySingleton() { var svc = new TestIgniteServiceBinarizable(); Services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, AffKey); var affNode = Grid1.GetAffinity(CacheName).MapKeyToNode(AffKey); var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName); Assert.AreEqual(affNode.Id, prx.NodeId); }