コード例 #1
0
        private async void ProcessSiloStoppingEvent_Impl()
        {
            if (logger.IsVerbose)
            {
                logger.Verbose("Processing silo stopping event");
            }

            // Select our nearest predecessor to receive our hand-off, since that's the silo that will wind up owning our partition (assuming
            // that it doesn't also fail and that no other silo joins during the transition period).
            if (silosHoldingMyPartition.Count == 0)
            {
                silosHoldingMyPartition.AddRange(localDirectory.FindPredecessors(localDirectory.MyAddress, 1));
            }
            // take a copy of the current directory partition
            Dictionary <GrainId, IGrainInfo> batchUpdate = localDirectory.DirectoryPartition.GetItems();

            try
            {
                await HandoffMyPartitionUponStop(batchUpdate, true);

                localDirectory.MarkStopPreparationCompleted();
            }
            catch (Exception exc)
            {
                localDirectory.MarkStopPreparationFailed(exc);
            }
        }
コード例 #2
0
        private async void ProcessSiloStoppingEvent_Impl()
        {
            if (logger.IsVerbose)
            {
                logger.Verbose("Processing silo stopping event");
            }

            // As we're about to enter an async context further down, this is the latest opportunity to lock, modify and copy
            // silosHoldingMyPartition for use inside of HandoffMyPartitionUponStop
            List <SiloAddress> silosHoldingMyPartitionCopy;

            lock (this)
            {
                // Select our nearest predecessor to receive our hand-off, since that's the silo that will wind up owning our partition (assuming
                // that it doesn't also fail and that no other silo joins during the transition period).
                if (silosHoldingMyPartition.Count == 0)
                {
                    silosHoldingMyPartition.AddRange(localDirectory.FindPredecessors(localDirectory.MyAddress, 1));
                }
                silosHoldingMyPartitionCopy = silosHoldingMyPartition.ToList();
            }
            // take a copy of the current directory partition
            Dictionary <GrainId, IGrainInfo> batchUpdate = localDirectory.DirectoryPartition.GetItems();

            try
            {
                await HandoffMyPartitionUponStop(batchUpdate, silosHoldingMyPartitionCopy, true);

                localDirectory.MarkStopPreparationCompleted();
            }
            catch (Exception exc)
            {
                localDirectory.MarkStopPreparationFailed(exc);
            }
        }