private static void AssertClientWithAddress(string address)
        {
            var client =
                new HazelcastClientFactory().CreateClient(config => { config.GetNetworkConfig().AddAddress(address); });

            var map = client.GetMap<string, string>("ipv6");
            map.Put("key", "val");
            Assert.AreEqual("val", map.Get("key"));
            map.Destroy();

            client.Shutdown();
        }
        private static void AssertClientWithAddress(string address)
        {
            var client = new HazelcastClientFactory().CreateClient(config =>
            {
                config.GetNetworkConfig().AddAddress(address);
            });

            var map = client.GetMap <string, string>("ipv6");

            map.Put("key", "val");
            Assert.AreEqual("val", map.Get("key"));
            map.Destroy();

            client.Shutdown();
        }
        protected virtual IHazelcastInstance CreateClient()
        {
            var clientFactory = new HazelcastClientFactory();
            var resetEvent    = new ManualResetEventSlim();
            var listener      = new ListenerConfig(new LifecycleListener(l =>
            {
                if (l.GetState() == LifecycleEvent.LifecycleState.ClientConnected)
                {
                    resetEvent.Set();
                }
            }));
            var client = clientFactory.CreateClient(c =>
            {
                ConfigureClient(c);
                c.AddListenerConfig(listener);
            });

            Assert.IsTrue(resetEvent.Wait(30 * 1000), "Client did not start after 30 seconds");
            return(client);
        }
示例#4
0
        public void TestRetryTimeout()
        {
            var member = _remoteController.startMember(_cluster.Id);

            Environment.SetEnvironmentVariable("hazelcast.client.invocation.timeout.seconds", "2");
            var client =
                new HazelcastClientFactory().CreateClient(c => c.GetNetworkConfig().AddAddress("127.0.0.1:5701"));

            try
            {
                var map = client.GetMap <string, string>(TestSupport.RandomString());

                StopMember(_remoteController, _cluster, member);

                var resetEvent = new ManualResetEventSlim();
                Task.Factory.StartNew(() =>
                {
                    Logger.GetLogger("ClientRetryTest").Info("Calling map.Put");
                    map.Put("key", "value");
                }).ContinueWith(t =>
                {
                    var e = t.Exception;//observe the exception
                    if (t.IsFaulted)
                    {
                        resetEvent.Set();
                    }
                    else
                    {
                        Assert.Fail("Method invocation did not fail as expected");
                    }
                });

                Assert.IsTrue(resetEvent.Wait(4000), "Did not get an exception within seconds");
            }
            finally
            {
                Environment.SetEnvironmentVariable("hazelcast.client.invocation.timeout.seconds", null);
                client.Shutdown();
            }
        }
 protected virtual IHazelcastInstance CreateClient()
 {
     var clientFactory = new HazelcastClientFactory();
     var resetEvent = new ManualResetEventSlim();
     var listener = new ListenerConfig(new LifecycleListener(l =>
     {
         if (l.GetState() == LifecycleEvent.LifecycleState.ClientConnected)
         {
             resetEvent.Set();
         }
     }));
     var client = clientFactory.CreateClient(c =>
     {
         ConfigureClient(c);
         c.AddListenerConfig(listener);
     });
     Assert.IsTrue(resetEvent.Wait(30*1000), "Client did not start after 30 seconds");
     return client;
 }
        public void TestRetryTimeout()
        {
            var member = _remoteController.startMember(_cluster.Id);
            Environment.SetEnvironmentVariable("hazelcast.client.invocation.timeout.seconds", "2");
            var client =
               new HazelcastClientFactory().CreateClient(c => c.GetNetworkConfig().AddAddress("127.0.0.1:5701"));
            try
            {
                var map = client.GetMap<string, string>(TestSupport.RandomString());

                StopMember(_remoteController, _cluster, member);

                var resetEvent = new ManualResetEventSlim();
                Task.Factory.StartNew(() =>
                {
                    Logger.GetLogger("ClientRetryTest").Info("Calling map.Put");
                    map.Put("key", "value");
                }).ContinueWith(t =>
                {
                    var e = t.Exception;//observe the exception
                    if (t.IsFaulted) resetEvent.Set();
                    else Assert.Fail("Method invocation did not fail as expected");
                });

                Assert.IsTrue(resetEvent.Wait(4000), "Did not get an exception within seconds");
            }
            finally
            {
                Environment.SetEnvironmentVariable("hazelcast.client.invocation.timeout.seconds", null);
                client.Shutdown();
            }
        }