Exemple #1
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            // Only old data (remove stream) needs to be removed from indexes (kept by root view), if any
            if (oldData != null)
            {
                _rootViewInstance.RemoveOldData(oldData);
                _numberOfEvents -= oldData.Length;
            }

            if ((newData != null) && (!_tailView.IsParentBatchWindow))
            {
                _rootViewInstance.AddNewData(newData);
            }

            if (newData != null)
            {
                _numberOfEvents += newData.Length;
            }

            // Post to child views, only if there are listeners or subscribers
            if (_tailView.StatementResultService.IsMakeNatural || _tailView.StatementResultService.IsMakeSynthetic)
            {
                UpdateChildren(newData, oldData);
            }

            var delta = new NamedWindowDeltaData(newData, oldData);

            _tailView.AddDispatches(_latchFactory, _consumersInContext, delta, _agentInstanceContext);
        }
 public void AddDispatch(
     NamedWindowConsumerLatchFactory latchFactory,
     NamedWindowDeltaData delta,
     IDictionary <EPStatementAgentInstanceHandle, IList <NamedWindowConsumerView> > consumers)
 {
     _threadLocal.GetOrCreate().Add(
         latchFactory.NewLatch(delta, consumers));
 }
 public void AddDispatch(NamedWindowDeltaData delta, IDictionary <EPStatementAgentInstanceHandle, IList <NamedWindowConsumerView> > consumers)
 {
     if (!consumers.IsEmpty())
     {
         var unit = new NamedWindowConsumerDispatchUnit(delta, consumers);
         _threadLocal.GetOrCreate().Add(unit);
     }
 }
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="deltaData">The delta data.</param>
        /// <param name="dispatchTo">The dispatch to.</param>
        /// <param name="factory">The factory.</param>
        /// <param name="earlier">the latch before this latch that this latch should be waiting for</param>
        public NamedWindowConsumerLatchSpin(NamedWindowDeltaData deltaData, IDictionary <EPStatementAgentInstanceHandle, IList <NamedWindowConsumerView> > dispatchTo, NamedWindowConsumerLatchFactory factory, NamedWindowConsumerLatchSpin earlier)
            : base(deltaData, dispatchTo)
        {
            _factory = factory;
            _earlier = earlier;
#if DEBUG && DEVELOPMENT
            _allocTime = _factory.TimeSourceService.GetTimeMillis();
#endif
        }
        protected NamedWindowConsumerLatch(NamedWindowDeltaData deltaData, IDictionary<EPStatementAgentInstanceHandle, IList<NamedWindowConsumerView>> dispatchTo)
        {
#if DEBUG && DEVELOPMENT
            Id = Guid.NewGuid();
            AllocThread = Thread.CurrentThread;
#endif
            DeltaData = deltaData;
            DispatchTo = dispatchTo;
        }
Exemple #6
0
 public void AddDispatches(
     NamedWindowConsumerLatchFactory latchFactory,
     IDictionary <EPStatementAgentInstanceHandle, IList <NamedWindowConsumerView> > consumersInContext,
     NamedWindowDeltaData delta,
     AgentInstanceContext agentInstanceContext)
 {
     if (!consumersInContext.IsEmpty())
     {
         _namedWindowDispatchService.AddDispatch(latchFactory, delta, consumersInContext);
     }
     if (!_consumersNonContext.IsEmpty())
     {
         _namedWindowDispatchService.AddDispatch(latchFactory, delta, _consumersNonContext);
     }
 }
Exemple #7
0
 /// <summary>
 /// Returns a new latch.
 /// <para />Need not be synchronized as there is one per statement and execution is during statement lock.
 /// </summary>
 /// <returns>latch</returns>
 public NamedWindowConsumerLatch NewLatch(NamedWindowDeltaData delta, IDictionary <EPStatementAgentInstanceHandle, IList <NamedWindowConsumerView> > consumers)
 {
     if (_useSpin)
     {
         var nextLatch = new NamedWindowConsumerLatchSpin(delta, consumers, this, _currentLatchSpin);
         _currentLatchSpin = nextLatch;
         return(nextLatch);
     }
     else
     {
         if (_enabled)
         {
             var nextLatch = new NamedWindowConsumerLatchWait(delta, consumers, this, _currentLatchWait);
             _currentLatchWait.Later = nextLatch;
             _currentLatchWait       = nextLatch;
             return(nextLatch);
         }
         return(new NamedWindowConsumerLatchNone(delta, consumers));
     }
 }
        public IDictionary <NamedWindowConsumerView, NamedWindowDeltaData> GetDeltaPerConsumer(object perStmtObj, EPStatementAgentInstanceHandle handle)
        {
            var list             = (IList <NamedWindowConsumerLatch>)perStmtObj;
            var deltaPerConsumer = new LinkedHashMap <NamedWindowConsumerView, NamedWindowDeltaData>();

            foreach (var unit in list)                                    // for each unit
            {
                foreach (var consumerView in unit.DispatchTo.Get(handle)) // each consumer
                {
                    var deltaForConsumer = deltaPerConsumer.Get(consumerView);
                    if (deltaForConsumer == null)
                    {
                        deltaPerConsumer.Put(consumerView, unit.DeltaData);
                    }
                    else
                    {
                        var aggregated = new NamedWindowDeltaData(deltaForConsumer, unit.DeltaData);
                        deltaPerConsumer.Put(consumerView, aggregated);
                    }
                }
            }
            return(deltaPerConsumer);
        }
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="earlier">the latch before this latch that this latch should be waiting for</param>
 public NamedWindowConsumerLatchSpin(NamedWindowDeltaData deltaData, IDictionary <EPStatementAgentInstanceHandle, IList <NamedWindowConsumerView> > dispatchTo, NamedWindowConsumerLatchFactory factory, NamedWindowConsumerLatchSpin earlier)
     : base(deltaData, dispatchTo)
 {
     _factory = factory;
     _earlier = earlier;
 }
Exemple #10
0
 public NamedWindowConsumerLatchNone(NamedWindowDeltaData deltaData, IDictionary<EPStatementAgentInstanceHandle, IList<NamedWindowConsumerView>> dispatchTo)
     : base(deltaData, dispatchTo)
 {
 }
Exemple #11
0
 /// <summary>Ctor aggregates two deltas into a single delta.</summary>
 /// <param name="deltaOne">
 /// is the insert and remove stream events of a first result
 /// </param>
 /// <param name="deltaTwo">
 /// is the insert and remove stream events of a second result
 /// </param>
 public NamedWindowDeltaData(NamedWindowDeltaData deltaOne, NamedWindowDeltaData deltaTwo)
 {
     this.newData = Aggregate(deltaOne.NewData, deltaTwo.NewData);
     this.oldData = Aggregate(deltaOne.OldData, deltaTwo.OldData);
 }
Exemple #12
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="deltaData">the insert and remove stream posted by the named window</param>
 /// <param name="dispatchTo">the list of consuming statements, and for each the list of consumer views</param>
 public NamedWindowConsumerDispatchUnit(NamedWindowDeltaData deltaData, IDictionary <EPStatementAgentInstanceHandle, IList <NamedWindowConsumerView> > dispatchTo)
 {
     DeltaData  = deltaData;
     DispatchTo = dispatchTo;
 }