Esempio n. 1
0
        public CheckpointSlotStatus GetSlotsStatus()
        {
            CheckpointSlotStatus returnValue = new CheckpointSlotStatus();
            //we need to group projection per slot
            var allCheckpoint = _allCheckpoints
                                .ToDictionary(c => c.Id, c => c);
            var slots = _projectionInfo
                        .Where(_ => !_.OfflineProjection || OfflineMode.Enabled) //skip projection for offline when offline is not enabled
                        .GroupBy(
                p => p.SlotName,
                p => new
            {
                Projection = p,
                Checkpoint = allCheckpoint.ContainsKey(p.CommonName) ? allCheckpoint[p.CommonName] : null,
            });
            Int64 maxCheckpoint = 0;

            if (allCheckpoint.Count > 0)
            {
                maxCheckpoint = allCheckpoint.Select(c => c.Value.Value).Max();
            }
            if (maxCheckpoint > 0) //if we have no dispatched commit, we have no need to rebuild or do anything
            {
                foreach (var slot in slots)
                {
                    if (slot.All(s => s.Checkpoint == null || s.Checkpoint.Value == 0))
                    {
                        returnValue.NewSlots.Add(slot.Key);
                    }
                    else if (slot.Where(s => s.Checkpoint != null)
                             .Select(s => s.Checkpoint.Value).Distinct().Count() > 1)
                    {
                        returnValue.SlotsThatNeedsRebuild.Add(slot.Key);
                    }
                    else if (slot.Any(s => s.Checkpoint == null || s.Checkpoint.Signature != s.Projection.Signature))
                    {
                        returnValue.SlotsThatNeedsRebuild.Add(slot.Key);
                    }
                    else if (slot.Any(s => s.Checkpoint?.Current == null && s.Checkpoint?.Value > 0))
                    {
                        // #11561: slot has some checkpoint with current equal to null and value greater than zero, it is an interrupted rebuild.
                        returnValue.SlotsThatNeedsRebuild.Add(slot.Key);
                    }
                }
            }

            //Fill the all slot property, should be always valid.
            foreach (var slot in slots)
            {
                returnValue.AllSlots.Add(slot.Key);
            }
            return(returnValue);
        }
        public CheckpointSlotStatus GetSlotsStatus()
        {
            CheckpointSlotStatus returnValue = new CheckpointSlotStatus();
            //we need to group projection per slot
            var allCheckpoint = _allCheckpoints
                                .ToDictionary(c => c.Id, c => c);
            var slots = _projectionInfo
                        .Where(_ => !_.OfflineProjection || OfflineMode.Enabled)         //skip projection for offline when offline is not enabled
                        .GroupBy(
                p => p.SlotName,
                p => new
            {
                Projection = p,
                Checkpoint = allCheckpoint.ContainsKey(p.CommonName) ? allCheckpoint[p.CommonName] : null,
            });
            Int64 maxCheckpoint = 0;

            if (allCheckpoint.Count > 0)
            {
                maxCheckpoint = allCheckpoint.Select(c => c.Value.Value).Max();
            }
            if (maxCheckpoint > 0) //if we have no dispatched commit, we have no need to rebuild or do anything
            {
                foreach (var slot in slots)
                {
                    if (slot.All(s => s.Checkpoint == null || s.Checkpoint.Value == 0))
                    {
                        returnValue.NewSlots.Add(slot.Key);
                    }
                    else if (slot.Where(s => s.Checkpoint != null)
                             .Select(s => s.Checkpoint.Value).Distinct().Count() > 1)
                    {
                        returnValue.SlotsThatNeedsRebuild.Add(slot.Key);
                    }
                    else if (slot.Any(s => s.Checkpoint == null || s.Checkpoint.Signature != s.Projection.Signature))
                    {
                        returnValue.SlotsThatNeedsRebuild.Add(slot.Key);
                    }
                }
            }
            return(returnValue);
        }
Esempio n. 3
0
        public CheckpointSlotStatus GetSlotsStatus(IProjection[] projections)
        {
            CheckpointSlotStatus returnValue = new CheckpointSlotStatus();
            //we need to group projection per slot
            var allCheckpoint = _checkpoints.FindAll().ToEnumerable().ToDictionary(c => c.Id, c => c);
            var slots         = projections.GroupBy(
                p => p.GetSlotName(),
                p => new {
                Projection = p,
                Checkpoint = allCheckpoint.ContainsKey(p.GetCommonName()) ? allCheckpoint[p.GetCommonName()] : null,
            });
            Int64 maxCheckpoint = 0;

            if (allCheckpoint.Any())
            {
                maxCheckpoint = allCheckpoint.Select(c => c.Value.Value).Max();
            }
            if (maxCheckpoint > 0) //if we have no dispatched commit, we have no need to rebuild or do anything
            {
                foreach (var slot in slots)
                {
                    if (slot.All(s => s.Checkpoint == null || s.Checkpoint.Value == 0))
                    {
                        returnValue.NewSlots.Add(slot.Key);
                    }
                    else if (slot.Where(s => s.Checkpoint != null)
                             .Select(s => s.Checkpoint.Value).Distinct().Count() > 1)
                    {
                        returnValue.SlotsThatNeedsRebuild.Add(slot.Key);
                    }
                    else if (slot.Any(s => s.Checkpoint == null || s.Checkpoint.Signature != s.Projection.GetSignature()))
                    {
                        returnValue.SlotsThatNeedsRebuild.Add(slot.Key);
                    }
                }
            }
            return(returnValue);
        }