Ejemplo n.º 1
0
        /// <summary>
        /// Creates a cache implementation for the strategy as defined by the cache descriptor.
        /// </summary>
        /// <param name="cacheDesc">cache descriptor</param>
        /// <param name="epStatementAgentInstanceHandle">statement handle for timer invocations</param>
        /// <param name="schedulingService">scheduling service for time-based caches</param>
        /// <param name="scheduleBucket">for ordered timer invokation</param>
        /// <returns>data cache implementation</returns>
        public DataCache GetDataCache(
            ConfigurationDataCache cacheDesc,
            StatementContext statementContext,
            EPStatementAgentInstanceHandle epStatementAgentInstanceHandle,
            SchedulingService schedulingService,
            ScheduleBucket scheduleBucket,
            int streamNum)
        {
            if (cacheDesc == null)
            {
                return(new DataCacheNullImpl());
            }

            if (cacheDesc is ConfigurationLRUCache)
            {
                var lruCache = (ConfigurationLRUCache)cacheDesc;
                return(new DataCacheLRUImpl(lruCache.Size));
            }

            if (cacheDesc is ConfigurationExpiryTimeCache)
            {
                var expCache = (ConfigurationExpiryTimeCache)cacheDesc;
                return(MakeTimeCache(expCache, statementContext, epStatementAgentInstanceHandle, schedulingService, scheduleBucket, streamNum));
            }

            throw new IllegalStateException("Cache implementation class not configured");
        }
Ejemplo n.º 2
0
        /// <summary>Creates a cache implementation for the strategy as defined by the cache descriptor. </summary>
        /// <param name="cacheDesc">cache descriptor</param>
        /// <param name="epStatementAgentInstanceHandle">statement handle for timer invocations</param>
        /// <param name="schedulingService">scheduling service for time-based caches</param>
        /// <param name="scheduleBucket">for ordered timer invokation</param>
        /// <returns>data cache implementation</returns>
        public static DataCache GetDataCache(ConfigurationDataCache cacheDesc,
                                             EPStatementAgentInstanceHandle epStatementAgentInstanceHandle,
                                             SchedulingService schedulingService,
                                             ScheduleBucket scheduleBucket)
        {
            if (cacheDesc == null)
            {
                return(new DataCacheNullImpl());
            }

            if (cacheDesc is ConfigurationLRUCache)
            {
                ConfigurationLRUCache lruCache = (ConfigurationLRUCache)cacheDesc;
                return(new DataCacheLRUImpl(lruCache.Size));
            }

            if (cacheDesc is ConfigurationExpiryTimeCache)
            {
                ConfigurationExpiryTimeCache expCache = (ConfigurationExpiryTimeCache)cacheDesc;
                return(new DataCacheExpiringImpl(expCache.MaxAgeSeconds, expCache.PurgeIntervalSeconds, expCache.CacheReferenceType,
                                                 schedulingService, scheduleBucket.AllocateSlot(), epStatementAgentInstanceHandle));
            }

            throw new IllegalStateException("Cache implementation class not configured");
        }
Ejemplo n.º 3
0
 public void HandleException(
     Exception ex,
     EPStatementAgentInstanceHandle handle,
     ExceptionHandlerExceptionType type)
 {
     HandleException(ex, handle.StatementHandle.StatementName, handle.StatementHandle.EPL, type);
 }
Ejemplo n.º 4
0
 /// <summary>Ctor. </summary>
 /// <param name="services">engine services</param>
 /// <param name="runtime">runtime to process</param>
 /// <param name="handle">statement handle</param>
 /// <param name="callbackObject">callback list</param>
 public TimerUnitMultiple(EPServicesContext services, EPRuntimeImpl runtime, EPStatementAgentInstanceHandle handle, object callbackObject)
 {
     _services       = services;
     _handle         = handle;
     _runtime        = runtime;
     _callbackObject = callbackObject;
 }
        private void StartContextCallback()
        {
            var scheduleCallback = new ProxyScheduleHandleCallback
            {
                ProcScheduledTrigger = (extensionServicesContext) =>
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QContextScheduledEval(_statementContext.ContextDescriptor);
                    }
                    _scheduleHandle = null;  // terminates automatically unless scheduled again
                    _callback.RangeNotification(Collections.EmptyDataMap, this, null, null, _filterAddendum);
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AContextScheduledEval();
                    }
                }
            };
            var agentHandle = new EPStatementAgentInstanceHandle(_statementContext.EpStatementHandle, _statementContext.DefaultAgentInstanceLock, -1, new StatementAgentInstanceFilterVersion(), _statementContext.FilterFaultHandlerFactory);

            _scheduleHandle = new EPStatementHandleCallback(agentHandle, scheduleCallback);
            var schedulingService   = _statementContext.SchedulingService;
            var engineImportService = _statementContext.EngineImportService;
            var nextScheduledTime   = ScheduleComputeHelper.ComputeDeltaNextOccurance(_spec.Schedule, schedulingService.Time, engineImportService.TimeZone, engineImportService.TimeAbacus);

            _statementContext.SchedulingService.Add(nextScheduledTime, _scheduleHandle, _scheduleSlot);
        }
Ejemplo n.º 6
0
        /// <summary>Processing multiple filter matches for a statement. </summary>
        /// <param name="handle">statement handle</param>
        /// <param name="callbackList">object containing callbacks</param>
        /// <param name="theEvent">to process</param>
        public void ProcessStatementFilterMultiple(EPStatementAgentInstanceHandle handle, ICollection <FilterHandleCallback> callbackList, EventBean theEvent)
        {
            using (handle.StatementAgentInstanceLock.AcquireWriteLock())
            {
                try
                {
                    if (handle.HasVariables)
                    {
                        _unisolatedServices.VariableService.SetLocalVersion();
                    }

                    handle.MultiMatchHandler.Handle(callbackList, theEvent);

                    // internal join processing, if applicable
                    handle.InternalDispatch();
                }
                catch (Exception ex)
                {
                    _unisolatedServices.ExceptionHandlingService.HandleException(ex, handle);
                }
                finally
                {
                    if (handle.HasTableAccess)
                    {
                        _unisolatedServices.TableService.TableExprEvaluatorContext.ReleaseAcquiredLocks();
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="maxAgeSec">is the maximum age in seconds</param>
        /// <param name="purgeIntervalSec">is the purge interval in seconds</param>
        /// <param name="cacheReferenceType">indicates whether hard, soft or weak references are used in the cache</param>
        /// <param name="schedulingService">is a service for call backs at a scheduled time, for purging</param>
        /// <param name="scheduleSlot">slot for scheduling callbacks for this cache</param>
        /// <param name="epStatementAgentInstanceHandle">is the statements-own handle for use in registering callbacks with services</param>
        /// <param name="timeAbacus">time abacus</param>
        public DataCacheExpiringImpl(
            double maxAgeSec,
            double purgeIntervalSec,
            ConfigurationCacheReferenceType cacheReferenceType,
            SchedulingService schedulingService,
            long scheduleSlot,
            EPStatementAgentInstanceHandle epStatementAgentInstanceHandle,
            TimeAbacus timeAbacus)
        {
            _maxAgeSec         = maxAgeSec;
            _purgeIntervalSec  = purgeIntervalSec;
            _schedulingService = schedulingService;
            _scheduleSlot      = scheduleSlot;
            _timeAbacus        = timeAbacus;

            if (cacheReferenceType == ConfigurationCacheReferenceType.HARD)
            {
                _cache = new Dictionary <Object, Item>();
            }
            else if (cacheReferenceType == ConfigurationCacheReferenceType.SOFT)
            {
                _cache = new ReferenceMap <Object, Item>(ReferenceType.SOFT, ReferenceType.SOFT);
            }
            else
            {
                _cache = new WeakDictionary <Object, Item>();
            }

            _epStatementAgentInstanceHandle = epStatementAgentInstanceHandle;
        }
Ejemplo n.º 8
0
        /// <summary>Ctor. </summary>
        /// <param name="maxAgeSec">is the maximum age in seconds</param>
        /// <param name="purgeIntervalSec">is the purge interval in seconds</param>
        /// <param name="cacheReferenceType">indicates whether hard, soft or weak references are used in the cache</param>
        /// <param name="schedulingService">is a service for call backs at a scheduled time, for purging</param>
        /// <param name="scheduleSlot">slot for scheduling callbacks for this cache</param>
        /// <param name="epStatementAgentInstanceHandle">is the statements-own handle for use in registering callbacks with services</param>
        public DataCacheExpiringImpl(double maxAgeSec,
                                     double purgeIntervalSec,
                                     ConfigurationCacheReferenceType cacheReferenceType,
                                     SchedulingService schedulingService,
                                     long scheduleSlot,
                                     EPStatementAgentInstanceHandle epStatementAgentInstanceHandle)
        {
            MaxAgeMSec         = (long)maxAgeSec * 1000;
            PurgeIntervalMSec  = (long)purgeIntervalSec * 1000;
            _schedulingService = schedulingService;
            _scheduleSlot      = scheduleSlot;

            if (cacheReferenceType == ConfigurationCacheReferenceType.HARD)
            {
                _cache = new Dictionary <Object, Item>();
            }
            else if (cacheReferenceType == ConfigurationCacheReferenceType.SOFT)
            {
                _cache = new ReferenceMap <Object, Item>(ReferenceType.SOFT, ReferenceType.SOFT);
            }
            else
            {
                _cache = new WeakDictionary <Object, Item>();
            }

            _epStatementAgentInstanceHandle = epStatementAgentInstanceHandle;
        }
Ejemplo n.º 9
0
        public void TestDropNoJoin()
        {
            var stmtHande       = new EPStatementHandle(1, "id", null, StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler());
            var stmtAgentHandle = new EPStatementAgentInstanceHandle(stmtHande, ReaderWriterLockManager.CreateDefaultLock(), -1, null, null);

            _streams    = new EventStream[4];
            _streams[0] = _streamFactoryService.CreateStream(1, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[1] = _streamFactoryService.CreateStream(2, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[2] = _streamFactoryService.CreateStream(3, _filterSpecs[1], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[3] = _streamFactoryService.CreateStream(4, _filterSpecs[2], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;

            _streamFactoryService.DropStream(_filterSpecs[0], _supportFilterService, false, false, false, false);
            _streamFactoryService.DropStream(_filterSpecs[1], _supportFilterService, false, false, false, false);
            Assert.AreEqual(0, _supportFilterService.Removed.Count);

            // Filter removed
            _streamFactoryService.DropStream(_filterSpecs[0], _supportFilterService, false, false, false, false);
            Assert.AreEqual(1, _supportFilterService.Removed.Count);

            _streamFactoryService.DropStream(_filterSpecs[2], _supportFilterService, false, false, false, false);
            Assert.AreEqual(2, _supportFilterService.Removed.Count);

            // Something already removed
            try
            {
                _streamFactoryService.DropStream(_filterSpecs[2], _supportFilterService, false, false, false, false);
                Assert.Fail();
            }
            catch (IllegalStateException)
            {
                // Expected
            }
        }
Ejemplo n.º 10
0
 public void QNamedWindowCPMulti(
     string runtimeURI,
     IDictionary<NamedWindowConsumerView, NamedWindowDeltaData> deltaPerConsumer,
     EPStatementAgentInstanceHandle handle,
     long time)
 {
 }
Ejemplo n.º 11
0
        /// <summary>
        ///     Called by the consumer view to indicate it was stopped or destroyed, such that the
        ///     consumer can be deregistered and further dispatches disregard this consumer.
        /// </summary>
        public void RemoveConsumer(NamedWindowConsumerView namedWindowConsumerView)
        {
            EPStatementAgentInstanceHandle handleRemoved = null;
            // Find the consumer view
            foreach (var entry in _consumersInContext) {
                var foundAndRemoved = entry.Value.Remove(namedWindowConsumerView);
                // Remove the consumer view
                if (foundAndRemoved && entry.Value.IsEmpty()) {
                    // Remove the handle if this list is now empty
                    handleRemoved = entry.Key;
                    break;
                }
            }

            if (handleRemoved != null) {
                var newConsumers = NamedWindowUtil.CreateConsumerMap(TailView.IsPrioritized);
                newConsumers.PutAll(_consumersInContext);
                newConsumers.Remove(handleRemoved);
                _consumersInContext = newConsumers;
            }

            // indicate to virtual data window that a consumer was added
            var virtualDWView = _rootViewInstance.VirtualDataWindow;
            if (virtualDWView != null && handleRemoved != null) {
                virtualDWView.VirtualDataWindow.HandleEvent(
                    new VirtualDataWindowEventConsumerRemove(
                        TailView.EventType.Name,
                        namedWindowConsumerView,
                        handleRemoved.StatementHandle.StatementName,
                        handleRemoved.AgentInstanceId));
            }
        }
Ejemplo n.º 12
0
        public void Open(DataFlowOpOpenContext openContext)
        {
            FilterValueSet valueSet;

            try
            {
                IList <ExprNode> filters = new ExprNode[0];
                if (filter != null)
                {
                    filters = new ExprNode[] { filter };
                }

                var spec = FilterSpecCompiler.MakeFilterSpec(
                    _eventType, _eventType.Name, filters, null,
                    null, null,
                    new StreamTypeServiceImpl(
                        _eventType,
                        _eventType.Name, true,
                        _agentInstanceContext.EngineURI),
                    null,
                    _agentInstanceContext.StatementContext,
                    new List <int>());
                valueSet = spec.GetValueSet(null, _agentInstanceContext, null);
            }
            catch (ExprValidationException ex)
            {
                throw new EPException("Failed to open filter: " + ex.Message, ex);
            }

            var handle = new EPStatementAgentInstanceHandle(_agentInstanceContext.StatementContext.EpStatementHandle, _agentInstanceContext.AgentInstanceLock, 0, new StatementAgentInstanceFilterVersion());

            _callbackHandle     = new EPStatementHandleCallback(handle, this);
            _filterServiceEntry = _agentInstanceContext.StatementContext.FilterService.Add(valueSet, _callbackHandle);
        }
Ejemplo n.º 13
0
        private void StartContextCallback(long timeOffset)
        {
            var scheduleCallback = new ProxyScheduleHandleCallback()
            {
                ProcScheduledTrigger = extensionServicesContext =>
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QContextScheduledEval(_agentInstanceContext.StatementContext.ContextDescriptor);
                    }
                    _scheduleHandle = null; // terminates automatically unless scheduled again
                    _callback.RangeNotification(Collections.GetEmptyMap <String, Object>(), this, null, null, _filterAddendum);
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AContextScheduledEval();
                    }
                }
            };
            var agentHandle =
                new EPStatementAgentInstanceHandle(
                    _agentInstanceContext.StatementContext.EpStatementHandle,
                    _agentInstanceContext.StatementContext.DefaultAgentInstanceLock, -1,
                    new StatementAgentInstanceFilterVersion(),
                    _agentInstanceContext.StatementContext.FilterFaultHandlerFactory);

            _scheduleHandle = new EPStatementHandleCallback(agentHandle, scheduleCallback);


            long timeDelta = _spec.TimePeriod.NonconstEvaluator().DeltaUseEngineTime(null, _agentInstanceContext) - timeOffset;

            _agentInstanceContext.StatementContext.SchedulingService.Add(timeDelta, _scheduleHandle, _scheduleSlot);
        }
Ejemplo n.º 14
0
        /// <summary>Process a single match. </summary>
        /// <param name="handle">statement</param>
        /// <param name="handleCallback">callback</param>
        /// <param name="theEvent">event to indicate</param>
        public void ProcessStatementFilterSingle(EPStatementAgentInstanceHandle handle, EPStatementHandleCallback handleCallback, EventBean theEvent)
        {
            using (handle.StatementAgentInstanceLock.AcquireWriteLock())
            {
                try
                {
                    if (handle.HasVariables)
                    {
                        _unisolatedServices.VariableService.SetLocalVersion();
                    }

                    handleCallback.FilterCallback.MatchFound(theEvent, null);

                    // internal join processing, if applicable
                    handle.InternalDispatch();
                }
                catch (Exception ex)
                {
                    _unisolatedServices.ExceptionHandlingService.HandleException(ex, handle, ExceptionHandlerExceptionType.PROCESS, theEvent);
                }
                finally
                {
                    if (handle.HasTableAccess)
                    {
                        _unisolatedServices.TableService.TableExprEvaluatorContext.ReleaseAcquiredLocks();
                    }
                }
            }
        }
Ejemplo n.º 15
0
        private void ScheduleNextCallback()
        {
            var nextScheduleCallback = new ProxyScheduleHandleCallback(delegate { ContinueSendingEvents(); });
            var spi                 = (EPServiceProviderSPI)_epService;
            var metricsHandle       = spi.MetricReportingService.GetStatementHandle(-1, "AbstractCoordinatedAdapter");
            var lockImpl            = ReaderWriterLockManager.CreateLock("CSV");
            var stmtHandle          = new EPStatementHandle(-1, "AbstractCoordinatedAdapter", null, StatementType.ESPERIO, "AbstractCoordinatedAdapter", false, metricsHandle, 0, false, false, spi.ServicesContext.MultiMatchHandlerFactory.GetDefaultHandler());
            var agentInstanceHandle = new EPStatementAgentInstanceHandle(stmtHandle, lockImpl, -1, new StatementAgentInstanceFilterVersion(), null);
            var scheduleCSVHandle   = new EPStatementHandleCallback(agentInstanceHandle, nextScheduleCallback);

            ScheduleSlot nextScheduleSlot;

            if (EventsToSend.IsEmpty())
            {
                if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug(".scheduleNextCallback no events to send, scheduling callback in 100 ms");
                }
                nextScheduleSlot = new ScheduleSlot(0, 0);
                _schedulingService.Add(100, scheduleCSVHandle, nextScheduleSlot);
            }
            else
            {
                // Offset is not a function of the currentTime alone.
                var  first     = EventsToSend.First();
                long baseMsec  = _currentTime - _startTime;
                long afterMsec = first.SendTime - baseMsec;
                nextScheduleSlot = first.ScheduleSlot;
                if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug(".scheduleNextCallback schedulingCallback in " + afterMsec + " milliseconds");
                }
                _schedulingService.Add(afterMsec, scheduleCSVHandle, nextScheduleSlot);
            }
        }
Ejemplo n.º 16
0
 /// <summary>Ctor. </summary>
 /// <param name="epRuntime">runtime to process</param>
 /// <param name="callbackList">callback list</param>
 /// <param name="theEvent">event to pass</param>
 /// <param name="handle">statement handle</param>
 /// <param name="filterVersion">version of filter</param>
 public RouteUnitMultiple(EPRuntimeImpl epRuntime, Object callbackList, EventBean theEvent, EPStatementAgentInstanceHandle handle, long filterVersion)
 {
     _epRuntime     = epRuntime;
     _callbackList  = callbackList;
     _theEvent      = theEvent;
     _handle        = handle;
     _filterVersion = filterVersion;
 }
Ejemplo n.º 17
0
 public void HandleException(
     Exception ex,
     EPStatementAgentInstanceHandle handle,
     ExceptionHandlerExceptionType type,
     EventBean optionalCurrentEvent)
 {
     HandleException(ex, handle.StatementHandle.StatementName, handle.StatementHandle.EPL, type, optionalCurrentEvent);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="epRuntime">runtime to process</param>
 /// <param name="callbackList">callback list</param>
 /// <param name="theEvent">event to pass</param>
 /// <param name="handle">statement handle</param>
 /// <param name="filterVersion">version of filter</param>
 public RouteUnitMultiple(EPEventServiceImpl epRuntime, object callbackList, EventBean theEvent, EPStatementAgentInstanceHandle handle, long filterVersion)
 {
     this.epRuntime = epRuntime;
     this.callbackList = callbackList;
     this.theEvent = theEvent;
     this.handle = handle;
     this.filterVersion = filterVersion;
 }
Ejemplo n.º 19
0
 public void QNamedWindowCPSingle(
     string runtimeURI,
     int numConsumers,
     EventBean[] newData,
     EventBean[] oldData,
     EPStatementAgentInstanceHandle handle,
     long time)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="services">runtime services</param>
 /// <param name="runtime">runtime to process</param>
 /// <param name="handle">statement handle</param>
 /// <param name="callbackObject">callback list</param>
 public TimerUnitMultiple(
     EPServicesContext services,
     EPEventServiceImpl runtime,
     EPStatementAgentInstanceHandle handle,
     object callbackObject)
 {
     this.services = services;
     this.handle = handle;
     this.runtime = runtime;
     this.callbackObject = callbackObject;
 }
Ejemplo n.º 21
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="services">runtime services</param>
 /// <param name="runtime">runtime to process</param>
 /// <param name="handle">statement handle</param>
 /// <param name="callbackObject">callback list</param>
 public TimerUnitMultipleStaged(
     StageSpecificServices services,
     EPStageEventServiceImpl runtime,
     EPStatementAgentInstanceHandle handle,
     object callbackObject)
 {
     this.services = services;
     this.handle = handle;
     this.runtime = runtime;
     this.callbackObject = callbackObject;
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Processing multiple schedule matches for a statement.
        /// </summary>
        /// <param name="handle">statement handle</param>
        /// <param name="callbackObject">object containing matches</param>
        /// <param name="services">runtime services</param>
        public static void ProcessStatementScheduleMultiple(
            EPStatementAgentInstanceHandle handle,
            object callbackObject,
            EPServicesEvaluation services)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QTimeCP(handle, services.SchedulingService.Time);
            }

            handle.StatementAgentInstanceLock.AcquireWriteLock();
            try {
                if (!handle.IsDestroyed)
                {
                    if (handle.HasVariables)
                    {
                        services.VariableManagementService.SetLocalVersion();
                    }

                    if (callbackObject is ArrayDeque <ScheduleHandleCallback> )
                    {
                        ArrayDeque <ScheduleHandleCallback> callbackList = (ArrayDeque <ScheduleHandleCallback>)callbackObject;
                        foreach (ScheduleHandleCallback callback in callbackList)
                        {
                            callback.ScheduledTrigger();
                        }
                    }
                    else
                    {
                        ScheduleHandleCallback callback = (ScheduleHandleCallback)callbackObject;
                        callback.ScheduledTrigger();
                    }

                    // internal join processing, if applicable
                    handle.InternalDispatch();
                }
            }
            catch (Exception ex) {
                services.ExceptionHandlingService.HandleException(ex, handle, ExceptionHandlerExceptionType.PROCESS, null);
            }
            finally {
                if (handle.HasTableAccess)
                {
                    services.TableExprEvaluatorContext.ReleaseAcquiredLocks();
                }

                handle.StatementAgentInstanceLock.ReleaseWriteLock();

                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().ATimeCP();
                }
            }
        }
Ejemplo n.º 23
0
 protected internal DataCache MakeTimeCache(
     ConfigurationExpiryTimeCache expCache,
     StatementContext statementContext,
     EPStatementAgentInstanceHandle epStatementAgentInstanceHandle,
     SchedulingService schedulingService,
     ScheduleBucket scheduleBucket,
     int streamNum)
 {
     return(new DataCacheExpiringImpl(
                expCache.MaxAgeSeconds, expCache.PurgeIntervalSeconds, expCache.CacheReferenceType,
                schedulingService, scheduleBucket.AllocateSlot(), epStatementAgentInstanceHandle));
 }
Ejemplo n.º 24
0
        public void HandleException(Exception ex, EPStatementAgentInstanceHandle handle)
        {
            if (UnhandledException == null)
            {
                Log.Error(string.Format("Exception encountered processing statement '{0}' statement text '{1}' : {2}", handle.StatementHandle.StatementName, handle.StatementHandle.EPL, ex.Message), ex);
                return;
            }

            UnhandledException(
                new ExceptionHandlerContext(
                    _engineURI, ex, handle.StatementHandle.StatementName, handle.StatementHandle.EPL));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Returns a new cache implementation for this database.
        /// </summary>
        /// <param name="databaseName">the name of the database to return a new cache implementation for for</param>
        /// <param name="epStatementAgentInstanceHandle">is the statements-own handle for use in registering callbacks with services</param>
        /// <returns>cache implementation</returns>
        /// <throws>  DatabaseConfigException is thrown to indicate database configuration errors </throws>
        public virtual DataCache GetDataCache(String databaseName, EPStatementAgentInstanceHandle epStatementAgentInstanceHandle)
        {
            ConfigurationDBRef config;

            if (!_mapDatabaseRef.TryGetValue(databaseName, out config))
            {
                throw new DatabaseConfigException("Cannot locate configuration information for database '" + databaseName + "'");
            }

            ConfigurationDataCache dataCacheDesc = config.DataCacheDesc;

            return(DataCacheFactory.GetDataCache(dataCacheDesc, epStatementAgentInstanceHandle, _schedulingService, _scheduleBucket));
        }
Ejemplo n.º 26
0
        /// <summary>Register an adapter. </summary>
        /// <param name="epService">engine</param>
        public void RegisterAdapter(EPServiceProvider epService)
        {
            var spi       = (EPServiceProviderSPI)epService;
            var eventType = spi.EventAdapterService.GetEventTypeByName(EventTypeName);
            var fvs       = new FilterSpecCompiled(eventType, null, new IList <FilterSpecParam> [0], null).GetValueSet(null, null, null);

            var name            = "subscription:" + SubscriptionName;
            var metricsHandle   = spi.MetricReportingService.GetStatementHandle(name, name);
            var statementHandle = new EPStatementHandle(name, name, name, StatementType.ESPERIO, name, false, metricsHandle, 0, false, false, MultiMatchHandlerFactory.DefaultHandler);
            var agentHandle     = new EPStatementAgentInstanceHandle(statementHandle, ReaderWriterLockManager.CreateDefaultLock(), -1, new StatementAgentInstanceFilterVersion());
            var registerHandle  = new EPStatementHandleCallback(agentHandle, this);

            spi.FilterService.Add(fvs, registerHandle);
        }
Ejemplo n.º 27
0
        public void SetUp()
        {
            _container   = SupportContainer.Reset();
            _handle      = new EPStatementHandle(1, "name", "text", StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler());
            _agentHandle = new EPStatementAgentInstanceHandle(_handle, _container.RWLockManager().CreateDefaultLock(), -1, null, null);

            _supportFilterService = new SupportFilterServiceImpl();
            _streamFactoryService = new StreamFactorySvcImpl("default", true);
            var eventType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean));

            _filterSpecs    = new FilterSpecCompiled[3];
            _filterSpecs[0] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "a" });
            _filterSpecs[1] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "a" });
            _filterSpecs[2] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "b" });
        }
Ejemplo n.º 28
0
        private void ProcessHandleMultiple(EPStatementAgentInstanceHandle handle, IDictionary <NamedWindowConsumerView, NamedWindowDeltaData> deltaPerConsumer)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QNamedWindowCPMulti(_exceptionHandlingService.EngineURI, deltaPerConsumer, handle, _schedulingService.Time);
            }

            try
            {
                using (handle.StatementAgentInstanceLock.AcquireWriteLock())
                {
                    try
                    {
                        if (handle.HasVariables)
                        {
                            _variableService.SetLocalVersion();
                        }
                        foreach (var entryDelta in deltaPerConsumer)
                        {
                            var newData = entryDelta.Value.NewData;
                            var oldData = entryDelta.Value.OldData;
                            entryDelta.Key.Update(newData, oldData);
                        }

                        // internal join processing, if applicable
                        handle.InternalDispatch();
                    }
                    catch (Exception ex)
                    {
                        _exceptionHandlingService.HandleException(ex, handle, ExceptionHandlerExceptionType.PROCESS);
                    }
                    finally
                    {
                        if (handle.HasTableAccess)
                        {
                            _tableService.TableExprEvaluatorContext.ReleaseAcquiredLocks();
                        }
                    }
                }
            }
            finally
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().ANamedWindowCPMulti();
                }
            }
        }
Ejemplo n.º 29
0
 public override ICollection <EventBean> GetSnapshot(EPStatementAgentInstanceHandle createWindowStmtHandle, Viewable parent)
 {
     using (createWindowStmtHandle.StatementAgentInstanceLock.AcquireReadLock())
     {
         var it   = parent.GetEnumerator();
         var list = new LinkedList <EventBean>();
         while (it.MoveNext())
         {
             var fullRevision = (RevisionEventBeanDeclared)it.Current;
             var key          = fullRevision.Key;
             var state        = _statePerKey.Get(key);
             list.AddLast(state.LastEvent);
         }
         return(list);
     }
 }
Ejemplo n.º 30
0
        private void ProcessHandle(EPStatementAgentInstanceHandle handle, IList <NamedWindowConsumerView> value, EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QNamedWindowCPSingle(_exceptionHandlingService.EngineURI, value, newData, oldData, handle, _schedulingService.Time);
            }

            try
            {
                using (handle.StatementAgentInstanceLock.AcquireWriteLock())
                {
                    try
                    {
                        if (handle.HasVariables)
                        {
                            _variableService.SetLocalVersion();
                        }

                        foreach (var consumerView in value)
                        {
                            consumerView.Update(newData, oldData);
                        }

                        // internal join processing, if applicable
                        handle.InternalDispatch();
                    }
                    catch (Exception ex)
                    {
                        _exceptionHandlingService.HandleException(ex, handle, ExceptionHandlerExceptionType.PROCESS);
                    }
                    finally
                    {
                        if (handle.HasTableAccess)
                        {
                            _tableService.TableExprEvaluatorContext.ReleaseAcquiredLocks();
                        }
                    }
                }
            }
            finally
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().ANamedWindowCPSingle();
                }
            }
        }