Example #1
0
        public void ClientTransactionRetry()
        {
            var member = _remoteController.startMember(_cluster.Id);
            var client = CreateClient();

            var context = client.NewTransactionContext();

            context.BeginTransaction();

            var map = context.GetMap <int, string>(TestSupport.RandomString());

            Task.Factory.StartNew(() =>
            {
                _remoteController.shutdownMember(_cluster.Id, member.Uuid);
                _remoteController.startMember(_cluster.Id);
            });
            try
            {
                for (var i = 0; i < Count; i++)
                {
                    // put should eventually fail as the node which the transaction is running against
                    // will be shut down
                    map.Put(i, TestSupport.RandomString());
                }
            }
            finally
            {
                context.RollbackTransaction();
            }
        }
Example #2
0
        public void TestListenerReconnect()
        {
            var member = StartMember(_remoteController, _cluster);
            var client = CreateClient();

            var name       = TestSupport.RandomString();
            var map        = client.GetMap <string, string>(name);
            var eventCount = 0;
            var count      = 2;
            var regId      = map.AddEntryListener(new EntryAdapter <string, string>
            {
                Added = e => { Interlocked.Increment(ref eventCount); }
            }, true);

            // try to start and stop the instance several times
            for (var i = 0; i < count; i++)
            {
                var clientDisconnected = TestSupport.WaitForClientState(client,
                                                                        LifecycleEvent.LifecycleState.ClientDisconnected);
                _remoteController.shutdownMember(_cluster.Id, member.Uuid);
                TestSupport.AssertCompletedEventually(clientDisconnected, taskName: "clientDisconnected");
                Interlocked.Exchange(ref eventCount, 0);
                var clientConnected = TestSupport.WaitForClientState(client,
                                                                     LifecycleEvent.LifecycleState.ClientConnected);
                member = _remoteController.startMember(_cluster.Id);
                TestSupport.AssertCompletedEventually(clientConnected, taskName: "clientConnected");

                TestSupport.AssertTrueEventually(() =>
                {
                    map.Put(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    return(eventCount > 0);
                });
            }
            Assert.IsTrue(map.RemoveEntryListener(regId));
            map.Destroy();
        }
Example #3
0
 protected virtual void StopMember(RemoteController.Client remoteController, Cluster cluster, Member member)
 {
     _logger.Info("Shutting down  member " + member.Uuid);
     remoteController.shutdownMember(cluster.Id, member.Uuid);
 }