public void NodeIsReusable() { this.AssertNoActiveConnections(); var other = new LocalNode(); var node = new LocalNode(); try { other.Bind(IPAddress.Loopback, 12002); node.Bind(IPAddress.Loopback, 12000); node.GetService <IClientConnector>().Connect(IPAddress.Loopback, 12002); Assert.Equal(2, node.GetService <IClientLookup>().GetAll().Count()); node.Close(); node.Bind(IPAddress.Loopback, 12001); Assert.Equal(1, node.GetService <IClientLookup>().GetAll().Count()); } finally { other.Close(); node.Close(); } this.AssertNoActiveConnections(); }
public void CanBindNode() { var node = new LocalNode(); node.Bind(IPAddress.Loopback, 9000); node.Close(); }
public void TwoNodesCanNotRunInTheSameProcessOnTheSamePort() { var node = new LocalNode(); node.Bind(IPAddress.Loopback, 9004); var second = new LocalNode(); Assert.Throws<SocketException>(() => second.Bind(IPAddress.Loopback, 9004)); node.Close(); }
public void NodeBindsAndClosesCleanly() { var node = new LocalNode(); node.Bind(IPAddress.Loopback, 9001); node.Close(); var second = new LocalNode(); second.Bind(IPAddress.Loopback, 9001); second.Close(); }
public void TwoNodesCanRunInTheSameProcessOnDifferentPorts() { var node = new LocalNode(); node.Bind(IPAddress.Loopback, 9002); var second = new LocalNode(); second.Bind(IPAddress.Loopback, 9003); node.Close(); second.Close(); }
public void TwoNodesCanNotRunInTheSameProcessOnTheSamePort() { var node = new LocalNode(); node.Bind(IPAddress.Loopback, 9004); var second = new LocalNode(); Assert.Throws <SocketException>(() => second.Bind(IPAddress.Loopback, 9004)); node.Close(); }
public void InvokeOnSameNode() { // Set up nodes. var first = new LocalNode(); first.Bind(IPAddress.Loopback, 9002); // Create the bar object in the first node. var barFirst = (Bar)new Distributed<Bar>(first, "bar"); // Assert that the second bar returns the right value. Assert.Equal("Hello, World!", barFirst.GetHelloWorldString()); // Close nodes. first.Close(); }
public void InvokeOnSameNode() { // Set up nodes. var first = new LocalNode(); first.Bind(IPAddress.Loopback, 9002); // Create the bar object in the first node. var barFirst = (Bar) new Distributed <Bar>(first, "bar"); // Assert that the second bar returns the right value. Assert.Equal("Hello, World!", barFirst.GetHelloWorldString()); // Close nodes. first.Close(); }
public void InvocationIsCorrectForServer() { // Set up nodes. var first = new LocalNode(Architecture.ServerClient, Caching.PushOnChange) { IsServer = true }; var second = new LocalNode(Architecture.ServerClient, Caching.PushOnChange); first.Bind(IPAddress.Loopback, 9004); second.Bind(IPAddress.Loopback, 9005); // Connect the second node to the first. second.GetService <IClientConnector>().Connect(IPAddress.Loopback, 9004); // Create the bar object in the first node. var barFirst = (Semantic) new Distributed <Semantic>(first, "semantic"); // Retrieve it on the second node. var barSecond = (Semantic) new Distributed <Semantic>(second, "semantic"); // Set the property. barFirst.Value = "Hello, World!"; // If we try and call any of the methods from the server, they should // all work. Assert.Equal("Hello, World!", barFirst.GetException()); Assert.Equal("Hello, World!", barFirst.GetIgnore()); Assert.Equal("Hello, World!", barFirst.GetValue()); // If we try and call barSecond.GetException, we should get an exception // because we are not a server. Assert.Throws <MemberAccessException>(() => barSecond.GetException()); // If we try and call barSecond.GetIgnore, we should get a null value // because we are not a server. Assert.Equal(null, barSecond.GetIgnore()); // If we try and call barSecond.GetValue, we should get "Hello, World!" Assert.Equal("Hello, World!", barSecond.GetValue()); // Close nodes. first.Close(); second.Close(); }
public void TestFetchHandler() { var node = new LocalNode(); node.Bind(IPAddress.Loopback, 10001); try { var constructor = node.GetService <IMessageConstructor>(); var serializer = node.GetService <IObjectWithTypeSerializer>(); var storage = node.GetService <IObjectStorage>(); storage.Put(new LiveEntry { Key = ID.NewHash("hello"), Owner = node.Self, Value = 40 }); var fetchMessage = constructor.ConstructFetchMessage(ID.NewHash("hello")); fetchMessage.Sender = node.Self; var handler = node.GetService <FetchMessageHandler>(); handler.Handle(fetchMessage); var sideChannel = node.GetService <IMessageSideChannel>(); Assert.True( sideChannel.Has(x => x.Type == MessageType.FetchResult), "side channel does not report message"); var result = sideChannel.WaitUntil(x => x.Type == MessageType.FetchResult, 100); Assert.Equal(1, result.FetchResult.Length); var value = serializer.Deserialize(result.FetchResult.First().Value); Assert.IsType <int>(value); Assert.Equal(40, (int)value); } finally { node.Close(); } }
public void TestFetchHandler() { var node = new LocalNode(); node.Bind(IPAddress.Loopback, 10001); try { var constructor = node.GetService<IMessageConstructor>(); var serializer = node.GetService<IObjectWithTypeSerializer>(); var storage = node.GetService<IObjectStorage>(); storage.Put(new LiveEntry { Key = ID.NewHash("hello"), Owner = node.Self, Value = 40 }); var fetchMessage = constructor.ConstructFetchMessage(ID.NewHash("hello")); fetchMessage.Sender = node.Self; var handler = node.GetService<FetchMessageHandler>(); handler.Handle(fetchMessage); var sideChannel = node.GetService<IMessageSideChannel>(); Assert.True( sideChannel.Has(x => x.Type == MessageType.FetchResult), "side channel does not report message"); var result = sideChannel.WaitUntil(x => x.Type == MessageType.FetchResult, 100); Assert.Equal(1, result.FetchResult.Length); var value = serializer.Deserialize(result.FetchResult.First().Value); Assert.IsType<int>(value); Assert.Equal(40, (int)value); } finally { node.Close(); } }
public void InvocationIsCorrectForServer() { // Set up nodes. var first = new LocalNode(Architecture.ServerClient, Caching.PushOnChange) { IsServer = true }; var second = new LocalNode(Architecture.ServerClient, Caching.PushOnChange); first.Bind(IPAddress.Loopback, 9004); second.Bind(IPAddress.Loopback, 9005); // Connect the second node to the first. second.GetService<IClientConnector>().Connect(IPAddress.Loopback, 9004); // Create the bar object in the first node. var barFirst = (Semantic)new Distributed<Semantic>(first, "semantic"); // Retrieve it on the second node. var barSecond = (Semantic)new Distributed<Semantic>(second, "semantic"); // Set the property. barFirst.Value = "Hello, World!"; // If we try and call any of the methods from the server, they should // all work. Assert.Equal("Hello, World!", barFirst.GetException()); Assert.Equal("Hello, World!", barFirst.GetIgnore()); Assert.Equal("Hello, World!", barFirst.GetValue()); // If we try and call barSecond.GetException, we should get an exception // because we are not a server. Assert.Throws<MemberAccessException>(() => barSecond.GetException()); // If we try and call barSecond.GetIgnore, we should get a null value // because we are not a server. Assert.Equal(null, barSecond.GetIgnore()); // If we try and call barSecond.GetValue, we should get "Hello, World!" Assert.Equal("Hello, World!", barSecond.GetValue()); // Close nodes. first.Close(); second.Close(); }
public void InvokeAcrossNodes() { // Set up nodes. var first = new LocalNode(); var second = new LocalNode(); first.Bind(IPAddress.Loopback, 9004); second.Bind(IPAddress.Loopback, 9005); // Create the bar object in the first node. new Distributed<Bar>(first, "bar"); // Retrieve it on the second node. var barSecond = (Bar)new Distributed<Bar>(second, "bar"); // Assert that the second bar returns the right value. Assert.Equal("Hello, World!", barSecond.GetHelloWorldString()); // Close nodes. first.Close(); second.Close(); }
public void InvokeAcrossNodes() { // Set up nodes. var first = new LocalNode(); var second = new LocalNode(); first.Bind(IPAddress.Loopback, 9004); second.Bind(IPAddress.Loopback, 9005); // Create the bar object in the first node. new Distributed <Bar>(first, "bar"); // Retrieve it on the second node. var barSecond = (Bar) new Distributed <Bar>(second, "bar"); // Assert that the second bar returns the right value. Assert.Equal("Hello, World!", barSecond.GetHelloWorldString()); // Close nodes. first.Close(); second.Close(); }
public void NodeIsReusable() { this.AssertNoActiveConnections(); var other = new LocalNode(); var node = new LocalNode(); try { other.Bind(IPAddress.Loopback, 12002); node.Bind(IPAddress.Loopback, 12000); node.GetService<IClientConnector>().Connect(IPAddress.Loopback, 12002); Assert.Equal(2, node.GetService<IClientLookup>().GetAll().Count()); node.Close(); node.Bind(IPAddress.Loopback, 12001); Assert.Equal(1, node.GetService<IClientLookup>().GetAll().Count()); } finally { other.Close(); node.Close(); } this.AssertNoActiveConnections(); }