Esempio n. 1
0
        public void SetSource <T>(ICepObservable <EdgeEvent <T> > source)
        {
            InternalSetSource(source.Select(e => e.EventKind == EventKind.Insert
                ? e.EdgeType == EdgeType.End
                ? new
            {
                EventKind = e.EventKind,
                EdgeType  = (EdgeType?)e.EdgeType,
                StartTime = e.StartTime,
                EndTime   = (DateTimeOffset?)e.EndTime,
                Payload   = e.Payload,
            }
                : new
            {
                EventKind = e.EventKind,
                EdgeType  = (EdgeType?)e.EdgeType,
                StartTime = e.StartTime,
                EndTime   = (DateTimeOffset?)null,
                Payload   = e.Payload,
            }
                : new
            {
                EventKind = e.EventKind,
                EdgeType  = (EdgeType?)null,
                StartTime = e.StartTime,
                EndTime   = (DateTimeOffset?)null,
                Payload   = default(T),
            }
                                            ));

            AddEventFields <EdgeEvent <T>, T>();
        }
Esempio n. 2
0
        public void SetSource <T>(ICepObservable <IntervalEvent <T> > source)
        {
            InternalSetSource(source.Select(i => i.EventKind == EventKind.Insert
                ? new { i.EventKind, i.StartTime, EndTime = (DateTimeOffset?)i.EndTime, i.Payload }
                : new { i.EventKind, i.StartTime, EndTime = (DateTimeOffset?)null, Payload = default(T) }));

            AddEventFields <IntervalEvent <T>, T>();
        }
Esempio n. 3
0
        public void SetSource <T>(ICepObservable <PointEvent <T> > source)
        {
            InternalSetSource(source.Select(p => p.EventKind == EventKind.Insert
                ? new { p.EventKind, p.StartTime, p.Payload }
                : new { p.EventKind, p.StartTime, Payload = default(T) }));

            AddEventFields <PointEvent <T>, T>();
        }
Esempio n. 4
0
        public void RegisterGathering()
        {
            int timeout = config.CoreDelay;

            var outStream2 = (from window in _pingInputStreamGathering.HoppingWindow(
                                  TimeSpan.FromSeconds(timeout),
                                  TimeSpan.FromSeconds(timeout),
                                  HoppingWindowOutputPolicy.ClipToWindowEnd)
                              from e in window
                              orderby e.Duration
                              select e);

            _pingOutputSource = outStream2.Take(int.MaxValue).ToPointObservable();

            try
            {
                _subscription2 = _pingOutputSource.Subscribe(_eventsOutputService);
            }
            catch (Exception e)
            {
                e.ToString();
                throw;
            }
        }
Esempio n. 5
0
        public void RegisterGathering()
        {
            int timeout = config.CoreDelay;

            var outStream2 = (from window in _pingInputStreamGathering.HoppingWindow(
                                 TimeSpan.FromSeconds(timeout),
                                 TimeSpan.FromSeconds(timeout),
                                 HoppingWindowOutputPolicy.ClipToWindowEnd)
                              from e in window
                              orderby e.Duration
                              select e);
            _pingOutputSource = outStream2.Take(int.MaxValue).ToPointObservable();

            try
            {
                _subscription2 = _pingOutputSource.Subscribe(_eventsOutputService);
            }
            catch (Exception e)
            {
                e.ToString();
                throw;
            }
        }
Esempio n. 6
0
        public void RegisterCounting()
        {
            int timeout = config.CoreDelay;

            var domainStats =
                from e in _pingInputStream
                group e by new { e.ParentDomain, e.SiteId } into domainGroups
                from win in domainGroups.HoppingWindow(
                    TimeSpan.FromSeconds(timeout),
                    TimeSpan.FromSeconds(timeout / 5),
                    HoppingWindowOutputPolicy.ClipToWindowEnd)
                select new DomainStatistics
                {
                    ParentId = domainGroups.Key.SiteId,
                    Id = DomainSelector.GetDomainId(domainGroups.Key.ParentDomain, domainGroups.Key.SiteId),
                    SelectorType = (int)PageSelectorType.DomainString,
                    Count = (int)win.Count(),
                    Pattern = domainGroups.Key.ParentDomain
                };

            var domainPatternStats =
                from e in _pingInputStream
                group e by new { e.SiteId } into domainGroups
                from win in domainGroups.HoppingWindow(
                    TimeSpan.FromSeconds(timeout),
                    TimeSpan.FromSeconds(timeout / 5),
                    HoppingWindowOutputPolicy.ClipToWindowEnd)
                select new DomainStatistics
                {
                    Id = domainGroups.Key.SiteId,
                    ParentId = null,
                    SelectorType = (int)PageSelectorType.DomainPattern,
                    Pattern = null,
                    Count = (int)win.Count()
                };

            var domainStatsTotal =
                from e in domainPatternStats
                select new DomainStatistics
                {
                    ParentId = e.Id,
                    Id = DomainSelector.GetDomainId(DomainSelector.TotalDomain, e.Id),
                    //Domain = string.Empty,
                    SelectorType = (int)PageSelectorType.DomainString,
                    //UserId = Guid.Empty,
                    Pattern = DomainSelector.TotalDomain,
                    Count = e.Count
                    //PageId = null
                };

            var pageStats =
                from e in _pingInputStream
                where e.PageId != null
                group e by new { e.PageId, e.ParentDomain, e.SiteId } into domainGroups
                from win in domainGroups.HoppingWindow(
                    TimeSpan.FromSeconds(timeout),
                    TimeSpan.FromSeconds(timeout / 5),
                    HoppingWindowOutputPolicy.ClipToWindowEnd)
                select new DomainStatistics
                {
                    ParentId = DomainSelector.GetDomainId(domainGroups.Key.ParentDomain, domainGroups.Key.SiteId),
                    Id = PageSelector.GetPageId(domainGroups.Key.PageId.Value, domainGroups.Key.ParentDomain, domainGroups.Key.SiteId),
                    Pattern = null,
                    SelectorType = (int)PageSelectorType.PagePattern,
                    Count = (int)win.Count()
                };

            var totalPageStats =
                from e in _pingInputStream
                where e.PageId != null
                group e by new { e.PageId, e.SiteId } into domainGroups
                from win in domainGroups.HoppingWindow(
                    TimeSpan.FromSeconds(timeout),
                    TimeSpan.FromSeconds(timeout / 5),
                    HoppingWindowOutputPolicy.ClipToWindowEnd)
                select new DomainStatistics
                {
                    ParentId = DomainSelector.GetDomainId(DomainSelector.TotalDomain, domainGroups.Key.SiteId),
                    Id = PageSelector.GetPageId(domainGroups.Key.PageId.Value, DomainSelector.TotalDomain, domainGroups.Key.SiteId),
                    Pattern = null,
                    SelectorType = (int)PageSelectorType.PagePattern,
                    Count = (int)win.Count()
                };

            var totalStats = domainPatternStats.Union(domainStats).Union(domainStatsTotal).Union(totalPageStats).Union(pageStats);

            _domainStatSource = totalStats.ToObservable();

            _statsOutputService = new CepObserver<DomainStatistics>();
            _eventsOutputService = new CepDataCollector<PageRequest>();

            _subscription = _domainStatSource.Subscribe(_statsOutputService);
        }
Esempio n. 7
0
        public void RegisterCounting()
        {
            int timeout = config.CoreDelay;


            var domainStats =
                from e in _pingInputStream
                group e by new { e.ParentDomain, e.SiteId } into domainGroups
            from win in domainGroups.HoppingWindow(
                TimeSpan.FromSeconds(timeout),
                TimeSpan.FromSeconds(timeout / 5),
                HoppingWindowOutputPolicy.ClipToWindowEnd)
            select new DomainStatistics
            {
                ParentId     = domainGroups.Key.SiteId,
                Id           = DomainSelector.GetDomainId(domainGroups.Key.ParentDomain, domainGroups.Key.SiteId),
                SelectorType = (int)PageSelectorType.DomainString,
                Count        = (int)win.Count(),
                Pattern      = domainGroups.Key.ParentDomain
            };

            var domainPatternStats =
                from e in _pingInputStream
                group e by new { e.SiteId } into domainGroups
            from win in domainGroups.HoppingWindow(
                TimeSpan.FromSeconds(timeout),
                TimeSpan.FromSeconds(timeout / 5),
                HoppingWindowOutputPolicy.ClipToWindowEnd)
            select new DomainStatistics
            {
                Id           = domainGroups.Key.SiteId,
                ParentId     = null,
                SelectorType = (int)PageSelectorType.DomainPattern,
                Pattern      = null,
                Count        = (int)win.Count()
            };

            var domainStatsTotal =
                from e in domainPatternStats
                select new DomainStatistics
            {
                ParentId = e.Id,
                Id       = DomainSelector.GetDomainId(DomainSelector.TotalDomain, e.Id),
                //Domain = string.Empty,
                SelectorType = (int)PageSelectorType.DomainString,
                //UserId = Guid.Empty,
                Pattern = DomainSelector.TotalDomain,
                Count   = e.Count
                          //PageId = null
            };

            var pageStats =
                from e in _pingInputStream
                where e.PageId != null
                group e by new { e.PageId, e.ParentDomain, e.SiteId } into domainGroups
            from win in domainGroups.HoppingWindow(
                TimeSpan.FromSeconds(timeout),
                TimeSpan.FromSeconds(timeout / 5),
                HoppingWindowOutputPolicy.ClipToWindowEnd)
            select new DomainStatistics
            {
                ParentId     = DomainSelector.GetDomainId(domainGroups.Key.ParentDomain, domainGroups.Key.SiteId),
                Id           = PageSelector.GetPageId(domainGroups.Key.PageId.Value, domainGroups.Key.ParentDomain, domainGroups.Key.SiteId),
                Pattern      = null,
                SelectorType = (int)PageSelectorType.PagePattern,
                Count        = (int)win.Count()
            };

            var totalPageStats =
                from e in _pingInputStream
                where e.PageId != null
                group e by new { e.PageId, e.SiteId } into domainGroups
            from win in domainGroups.HoppingWindow(
                TimeSpan.FromSeconds(timeout),
                TimeSpan.FromSeconds(timeout / 5),
                HoppingWindowOutputPolicy.ClipToWindowEnd)
            select new DomainStatistics
            {
                ParentId     = DomainSelector.GetDomainId(DomainSelector.TotalDomain, domainGroups.Key.SiteId),
                Id           = PageSelector.GetPageId(domainGroups.Key.PageId.Value, DomainSelector.TotalDomain, domainGroups.Key.SiteId),
                Pattern      = null,
                SelectorType = (int)PageSelectorType.PagePattern,
                Count        = (int)win.Count()
            };

            var totalStats = domainPatternStats.Union(domainStats).Union(domainStatsTotal).Union(totalPageStats).Union(pageStats);

            _domainStatSource = totalStats.ToObservable();

            _statsOutputService  = new CepObserver <DomainStatistics>();
            _eventsOutputService = new CepDataCollector <PageRequest>();

            _subscription = _domainStatSource.Subscribe(_statsOutputService);
        }