예제 #1
0
        /// <summary>
        /// Register the given <see cref="RingMasterInstance"/> as a secondary.
        /// </summary>
        /// <param name="secondary">The instance to register as secondary</param>
        public void RegisterSecondary(RingMasterInstance secondary)
        {
            if (secondary == null)
            {
                throw new ArgumentNullException(nameof(secondary));
            }

            this.persistedDataFactory.RegisterSecondary(secondary.persistedDataFactory);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RingMasterRing"/> class.
        /// </summary>
        /// <param name="id">Unique Id of this ring</param>
        /// <param name="memberCount">Number of <see cref="RingMasterInstance"/>s in this ring</param>
        public RingMasterRing(int id, int memberCount = 1)
        {
            Trace.TraceInformation($"RingMasterRing id={id}");
            this.Id = id;

            for (int i = 0; i < memberCount; i++)
            {
                var ringMaster = new RingMasterInstance(i, isPrimary: i == 0);
                this.ringMasters.Add(ringMaster);

                if (i > 0)
                {
                    this.ringMasters[0].RegisterSecondary(ringMaster);
                }
            }
        }