Ejemplo n.º 1
0
        private void AddNewEvent(CoordinatedAdapter adapter)
        {
            if ((ExecutionPathDebugLog.IsDebugEnabled) && (Log.IsDebugEnabled))
            {
                Log.Debug(".addNewEvent eventsFromAdapters==" + _eventsFromAdapters);
            }
            var _event = adapter.Read();

            if (_event != null)
            {
                if ((ExecutionPathDebugLog.IsDebugEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug(".addNewEvent event==" + _event);
                }
                EventsToSend.Add(_event);
                _eventsFromAdapters[_event] = adapter;
            }
            else
            {
                if (adapter.State == AdapterState.DESTROYED)
                {
                    var keyList = new LinkedList <SendableEvent>();

                    foreach (var entry in _eventsFromAdapters)
                    {
                        if (entry.Value == adapter)
                        {
                            keyList.AddFirst(entry.Key);
                        }
                    }

                    foreach (var keyEvent in keyList)
                    {
                        _eventsFromAdapters.Remove(keyEvent);
                    }
                }
                else
                {
                    _emptyAdapters.Add(adapter);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///@see com.espertech.esper.adapter.AdapterCoordinator#add(com.espertech.esper.adapter.Adapter)
        /// </summary>
        public virtual void Coordinate(InputAdapter inputAdapter)
        {
            if (inputAdapter == null)
            {
                throw new ArgumentException("AdapterSpec cannot be null");
            }

            if (!(inputAdapter is CoordinatedAdapter))
            {
                throw new ArgumentException("Cannot coordinate a Adapter of type " + inputAdapter.GetType());
            }
            CoordinatedAdapter adapter = (CoordinatedAdapter)inputAdapter;

            if (_eventsFromAdapters.Values.Contains(adapter) || _emptyAdapters.Contains(adapter))
            {
                return;
            }
            adapter.DisallowStateTransitions();
            adapter.EPService          = _epService;
            adapter.UsingEngineThread  = _usingEngineThread;
            adapter.UsingExternalTimer = _usingExternalTimer;
            adapter.ScheduleSlot       = _scheduleBucket.AllocateSlot();
            AddNewEvent(adapter);
        }