Example #1
0
        public void PartitionLostEventArgs()
        {
            var memberInfo = new MemberInfo(Guid.NewGuid(), NetworkAddress.Parse("127.0.0.1:88"), new MemberVersion(1, 1, 1), false, new Dictionary <string, string>());
            var args       = new PartitionLostEventArgs(12, 13, true, memberInfo);

            Assert.That(args.PartitionId, Is.EqualTo(12));
            Assert.That(args.LostBackupCount, Is.EqualTo(13));
            Assert.That(args.IsAllReplicasInPartitionLost);
            Assert.That(args.Member, Is.SameAs(memberInfo));
        }
        public async Task PartitionLostEventHandler()
        {
            var    count = 0;
            object eventSender = null, eventArgs = null;

            var handler = new PartitionLostEventHandler((sender, args) =>
            {
                eventSender = sender;
                eventArgs   = args;
                count++;
                return(new ValueTask());
            });

            var client     = Mock.Of <IHazelcastClient>();
            var memberInfo = new MemberInfo(Guid.NewGuid(), NetworkAddress.Parse("127.0.0.1:88"), new MemberVersion(1, 1, 1), false, new Dictionary <string, string>());
            var args       = new PartitionLostEventArgs(12, 13, true, memberInfo);
            await handler.HandleAsync(client, args);

            Assert.That(count, Is.EqualTo(1));
            Assert.That(eventSender, Is.SameAs(client));
            Assert.That(eventArgs, Is.SameAs(args));
        }
 /// <summary>
 /// Handles a lost partition.
 /// </summary>
 /// <param name="args">The event arguments.</param>
 public ValueTask OnPartitionLost(PartitionLostEventArgs args)
 {
     // triggers PartitionLost event
     return(ForEachHandler <PartitionLostEventHandler, PartitionLostEventArgs>(
                (handler, sender, a) => handler.HandleAsync(sender, a), args));
 }