Ejemplo n.º 1
0
        private void RunAssertionVariantOneWildcard(EPServiceProvider epService)
        {
            string stmtText = "insert into Event_1W (delta, product) " +
                              "select * from " + typeof(SupportBean).FullName + "#length(100)";

            try {
                epService.EPAdministrator.CreateEPL(stmtText);
                Assert.Fail();
            } catch (EPStatementException) {
                // Expected
            }

            // assert statement-type reference
            EPServiceProviderSPI spi = (EPServiceProviderSPI)epService;

            Assert.IsFalse(spi.StatementEventTypeRef.IsInUse("Event_1W"));

            // test insert wildcard to wildcard
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            var listener = new SupportUpdateListener();

            string      stmtSelectText = "insert into ABCStream select * from SupportBean";
            EPStatement stmtSelect     = epService.EPAdministrator.CreateEPL(stmtSelectText, "resilient i0");

            stmtSelect.Events += listener.Update;
            Assert.IsTrue(stmtSelect.EventType is BeanEventType);

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.AreEqual("E1", listener.AssertOneGetNew().Get("TheString"));
            Assert.IsTrue(listener.AssertOneGetNew().Underlying is SupportBean);

            stmtSelect.Dispose();
        }
Ejemplo n.º 2
0
        private void RunAssertionReclaimTimeWindow(EPServiceProvider epService)
        {
            SendTimer(epService, 0);

            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            epService.EPAdministrator.CreateEPL("@Hint('reclaim_group_aged=30,reclaim_group_freq=5') " +
                                                "select LongPrimitive, count(*) from SupportBean#groupwin(TheString)#time(3000000)");

            for (int i = 0; i < 10; i++)
            {
                var theEvent = new SupportBean(Convert.ToString(i), i);
                epService.EPRuntime.SendEvent(theEvent);
            }

            EPServiceProviderSPI spi = (EPServiceProviderSPI)epService;
            int handleCountBefore    = spi.SchedulingService.ScheduleHandleCount;

            Assert.AreEqual(10, handleCountBefore);

            SendTimer(epService, 1000000);
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));

            int handleCountAfter = spi.SchedulingService.ScheduleHandleCount;

            Assert.AreEqual(1, handleCountAfter);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 3
0
        public static Pair <ExprNode, string> CompileValidateStatementFilterExpr(
            EPServiceProviderSPI engine,
            string filterExpression)
        {
            ExprNode exprNode;

            try
            {
                var spi = (EPAdministratorSPI)engine.EPAdministrator;
                exprNode = spi.CompileExpression(filterExpression);
            }
            catch (Exception ex)
            {
                return(new Pair <ExprNode, string>(null, "Error compiling expression: " + ex.Message));
            }

            try
            {
                var streamTypeService = new StreamTypeServiceImpl(STATEMENT_META_EVENT_TYPE, null, true, engine.URI);
                exprNode = ExprNodeUtility.GetValidatedSubtree(
                    ExprNodeOrigin.SCRIPTPARAMS, exprNode,
                    new ExprValidationContext(
                        streamTypeService,
                        engine.EngineImportService,
                        null, null,
                        engine.TimeProvider, null, null, null,
                        engine.EventAdapterService, "no-name-assigned", -1,
                        null, null, null, true, false, false, false, null, true));
            }
            catch (Exception ex)
            {
                return(new Pair <ExprNode, string>(null, "Error validating expression: " + ex.Message));
            }
            return(new Pair <ExprNode, string>(exprNode, null));
        }
Ejemplo n.º 4
0
        private void AssertTypeExists(EPServiceProvider epService, String typeName, bool isPreconfigured)
        {
            EPServiceProviderSPI spi  = (EPServiceProviderSPI)epService;
            EventTypeSPI         type = (EventTypeSPI)spi.EventAdapterService.GetEventTypeByName(typeName);

            Assert.IsTrue(type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(isPreconfigured, type.Metadata.IsApplicationPreConfigured);
            Assert.IsFalse(type.Metadata.IsApplicationPreConfiguredStatic);
        }
Ejemplo n.º 5
0
        public void TestStartStop()
        {
            String      viewExpr    = "@IterableUnbound every tag=" + typeof(SupportBean).FullName;
            EPStatement patternStmt = _epService.EPAdministrator.CreatePattern(viewExpr, "MyPattern");

            Assert.AreEqual(StatementType.PATTERN, ((EPStatementSPI)patternStmt).StatementMetadata.StatementType);

            // Pattern started when created
            Assert.IsFalse(patternStmt.HasFirst());
            using (IEnumerator <EventBean> safe = patternStmt.GetSafeEnumerator())
            {
                Assert.IsFalse(safe.MoveNext());
            }

            // Stop pattern
            patternStmt.Stop();
            SendEvent();
            Assert.That(patternStmt.GetEnumerator(), Is.InstanceOf <NullEnumerator <EventBean> >());

            // Start pattern
            patternStmt.Start();
            Assert.IsFalse(patternStmt.HasFirst());

            // Send event
            SupportBean theEvent = SendEvent();

            Assert.AreSame(theEvent, patternStmt.First().Get("tag"));
            using (var safe = patternStmt.GetSafeEnumerator())
            {
                Assert.That(safe.MoveNext(), Is.True);
                Assert.AreSame(theEvent, safe.Current.Get("tag"));
            }

            // Stop pattern
            patternStmt.Stop();
            Assert.That(patternStmt.GetEnumerator(), Is.InstanceOf <NullEnumerator <EventBean> >());

            // Start again, iterator is zero
            patternStmt.Start();
            Assert.IsFalse(patternStmt.HasFirst());

            // assert statement-eventtype reference info
            EPServiceProviderSPI spi = (EPServiceProviderSPI)_epService;

            Assert.IsTrue(spi.StatementEventTypeRef.IsInUse(typeof(SupportBean).FullName));
            ICollection <String> stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportBean).FullName);

            Assert.IsTrue(stmtNames.Contains("MyPattern"));

            patternStmt.Dispose();

            Assert.IsFalse(spi.StatementEventTypeRef.IsInUse(typeof(SupportBean).FullName));
            stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportBean).FullName);
            Assert.IsFalse(stmtNames.Contains("MyPattern"));
        }
Ejemplo n.º 6
0
        private void RunAssertionStartStop(EPServiceProvider epService)
        {
            string      epl         = "@IterableUnbound every tag=" + typeof(SupportBean).FullName;
            EPStatement patternStmt = epService.EPAdministrator.CreatePattern(epl, "MyPattern");

            Assert.AreEqual(StatementType.PATTERN, ((EPStatementSPI)patternStmt).StatementMetadata.StatementType);

            // Pattern started when created
            Assert.IsFalse(patternStmt.HasFirst());
            var safe = patternStmt.GetSafeEnumerator();

            Assert.IsFalse(safe.MoveNext());
            safe.Dispose();

            // Stop pattern
            patternStmt.Stop();
            SendEvent(epService);
            //Assert.IsNull(patternStmt.GetEnumerator());

            // Start pattern
            patternStmt.Start();
            Assert.IsFalse(patternStmt.HasFirst());

            // Send event
            SupportBean theEvent = SendEvent(epService);

            Assert.AreSame(theEvent, patternStmt.First().Get("tag"));
            safe = patternStmt.GetSafeEnumerator();
            Assert.IsTrue(safe.MoveNext());
            Assert.AreSame(theEvent, safe.Current.Get("tag"));
            safe.Dispose();

            // Stop pattern
            patternStmt.Stop();
            //Assert.IsNull(patternStmt.GetEnumerator());

            // Start again, iterator is zero
            patternStmt.Start();
            Assert.IsFalse(patternStmt.HasFirst());

            // assert statement-eventtype reference info
            EPServiceProviderSPI spi = (EPServiceProviderSPI)epService;

            Assert.IsTrue(spi.StatementEventTypeRef.IsInUse(typeof(SupportBean).FullName));
            var stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportBean).FullName);

            Assert.IsTrue(stmtNames.Contains("MyPattern"));

            patternStmt.Dispose();

            Assert.IsFalse(spi.StatementEventTypeRef.IsInUse(typeof(SupportBean).FullName));
            stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportBean).FullName);
            Assert.IsFalse(stmtNames.Contains("MyPattern"));
        }
Ejemplo n.º 7
0
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            _epService = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), GetType().FullName);
            }
        }
Ejemplo n.º 8
0
        private void RunAssertionVariantTwoWildcard(EPServiceProvider epService)
        {
            string stmtText  = "insert into event1 select * from " + typeof(SupportBean).FullName + "#length(100)";
            string otherText = "select * from default.event1#length(10)";

            // Attach listener to feed
            EPStatement stmtOne = epService.EPAdministrator.CreateEPL(stmtText, "stmt1");

            Assert.AreEqual(StatementType.INSERT_INTO, ((EPStatementSPI)stmtOne).StatementMetadata.StatementType);
            var listenerOne = new SupportUpdateListener();

            stmtOne.Events += listenerOne.Update;
            EPStatement stmtTwo     = epService.EPAdministrator.CreateEPL(otherText, "stmt2");
            var         listenerTwo = new SupportUpdateListener();

            stmtTwo.Events += listenerTwo.Update;

            SupportBean theEvent = SendEvent(epService, 10, 11);

            Assert.IsTrue(listenerOne.GetAndClearIsInvoked());
            Assert.AreEqual(1, listenerOne.LastNewData.Length);
            Assert.AreEqual(10, listenerOne.LastNewData[0].Get("IntPrimitive"));
            Assert.AreEqual(11, listenerOne.LastNewData[0].Get("IntBoxed"));
            Assert.AreEqual(20, listenerOne.LastNewData[0].EventType.PropertyNames.Length);
            Assert.AreSame(theEvent, listenerOne.LastNewData[0].Underlying);

            Assert.IsTrue(listenerTwo.GetAndClearIsInvoked());
            Assert.AreEqual(1, listenerTwo.LastNewData.Length);
            Assert.AreEqual(10, listenerTwo.LastNewData[0].Get("IntPrimitive"));
            Assert.AreEqual(11, listenerTwo.LastNewData[0].Get("IntBoxed"));
            Assert.AreEqual(20, listenerTwo.LastNewData[0].EventType.PropertyNames.Length);
            Assert.AreSame(theEvent, listenerTwo.LastNewData[0].Underlying);

            // assert statement-type reference
            EPServiceProviderSPI spi = (EPServiceProviderSPI)epService;

            Assert.IsTrue(spi.StatementEventTypeRef.IsInUse("event1"));
            var stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType("event1");

            EPAssertionUtil.AssertEqualsAnyOrder(stmtNames.ToArray(), new string[] { "stmt1", "stmt2" });
            Assert.IsTrue(spi.StatementEventTypeRef.IsInUse(typeof(SupportBean).FullName));
            stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportBean).FullName);
            EPAssertionUtil.AssertEqualsAnyOrder(stmtNames.ToArray(), new string[] { "stmt1" });

            stmtOne.Dispose();
            Assert.IsTrue(spi.StatementEventTypeRef.IsInUse("event1"));
            stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType("event1");
            EPAssertionUtil.AssertEqualsAnyOrder(new string[] { "stmt2" }, stmtNames.ToArray());
            Assert.IsFalse(spi.StatementEventTypeRef.IsInUse(typeof(SupportBean).FullName));

            stmtTwo.Dispose();
            Assert.IsFalse(spi.StatementEventTypeRef.IsInUse("event1"));
        }
        public static void AddTypeConfiguration(EPServiceProviderSPI epService)
        {
            var propertyTypes = new LinkedHashMap <String, Object>();

            propertyTypes.Put("myDouble", typeof(Double));
            propertyTypes.Put("myInt", typeof(int));
            propertyTypes.Put("myString", typeof(String));
            epService.EPAdministrator.Configuration.AddEventType("MyMapEvent", propertyTypes);
            epService.EPAdministrator.Configuration.AddEventType("MyOAEvent", "myDouble,myInt,myString".Split(','), new Object[] { typeof(double), typeof(int), typeof(string) });
            epService.EPAdministrator.Configuration.AddEventType(typeof(MyEvent));
            epService.EPAdministrator.Configuration.AddEventType("MyXMLEvent", GetConfig(
                                                                     epService.ServicesContext.ResourceManager));
        }
Ejemplo n.º 10
0
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.LoggingConfig.IsEnableQueryPlan = true;
            _epService = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            _listenerWindow = new SupportUpdateListener();
            _listenerSelect = new SupportUpdateListener();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), GetType().FullName);
            }
        }
Ejemplo n.º 11
0
 public void SetUp()
 {
     Configuration config = SupportConfigFactory.GetConfiguration();
     config.EngineDefaults.LoggingConfig.IsEnableQueryPlan = true;
     epService = (EPServiceProviderSPI) EPServiceProviderManager.GetDefaultProvider(config);
     epService.Initialize();
     if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, this.GetType(), GetType().FullName);}
     listenerInfra = new SupportUpdateListener();
     listenerDelete = new SupportUpdateListener();
     listenerSelect = new SupportUpdateListener();        
     foreach (Type clazz in new Type[] {typeof(SupportBean), typeof(SupportBean_A), typeof(SupportBean_B)}) {
         epService.EPAdministrator.Configuration.AddEventType(clazz);
     }
 }
Ejemplo n.º 12
0
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.Logging.IsEnableQueryPlan = true;
            epService = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(config);
            epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(epService, this.GetType(), GetType().FullName);
            }
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            epService.EPAdministrator.Configuration.AddEventType(typeof(OrderBean));
        }
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            _epService = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), GetType().FullName);
            }
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S0));
            _epService.EPAdministrator.Configuration.AddEventType(typeof(MyCountAccessEvent));
            _listener = new SupportUpdateListener();
        }
Ejemplo n.º 14
0
        public void TestJoinUniquePerId()
        {
            String joinStatement = "select * from " +
                                   typeof(SupportMarketDataBean).FullName + "(Symbol='IBM').win:length(3) s0, " +
                                   typeof(SupportMarketDataBean).FullName + "(Symbol='CSCO').win:length(3) s1" +
                                   " where s0.Volume=s1.Volume";

            EPStatement joinView = _epService.EPAdministrator.CreateEPL(joinStatement, "MyJoin");

            joinView.Events += _updateListener.Update;

            SendEvent(setOne[0]);
            SendEvent(setTwo[0]);
            Assert.NotNull(_updateListener.LastNewData);
            _updateListener.Reset();

            joinView.Stop();
            SendEvent(setOne[1]);
            SendEvent(setTwo[1]);
            Assert.IsFalse(_updateListener.IsInvoked);

            joinView.Start();
            SendEvent(setOne[2]);
            Assert.IsFalse(_updateListener.IsInvoked);

            joinView.Stop();
            SendEvent(setOne[3]);
            SendEvent(setOne[4]);
            SendEvent(setTwo[3]);

            joinView.Start();
            SendEvent(setTwo[4]);
            Assert.IsFalse(_updateListener.IsInvoked);

            // assert type-statement reference
            EPServiceProviderSPI spi = (EPServiceProviderSPI)_epService;

            Assert.IsTrue(spi.StatementEventTypeRef.IsInUse(typeof(SupportMarketDataBean).FullName));
            ICollection <String> stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportMarketDataBean).FullName);

            Assert.IsTrue(stmtNames.Contains("MyJoin"));

            joinView.Dispose();

            Assert.IsFalse(spi.StatementEventTypeRef.IsInUse(typeof(SupportMarketDataBean).FullName));
            stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportMarketDataBean).FullName);
            EPAssertionUtil.AssertEqualsAnyOrder(null, stmtNames.ToArray());
            Assert.IsFalse(stmtNames.Contains("MyJoin"));
        }
        private void RunAssertionEventsProcessed(EPServiceProvider epService)
        {
            var         listenerOne   = new SupportListenerTimerHRes();
            var         listenerTwo   = new SupportListenerTimerHRes();
            var         listenerThree = new SupportListenerTimerHRes();
            EPStatement stmtOne       = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(100) from MyMap");

            stmtOne.Events += listenerOne.Update;
            EPStatement stmtTwo = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(100) from SupportBean");

            stmtTwo.Events += listenerTwo.Update;
            EPStatement stmtThree = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(100) from XMLType");

            stmtThree.Events += listenerThree.Update;

            EventSender senderOne   = epService.EPRuntime.GetEventSender("MyMap");
            EventSender senderTwo   = epService.EPRuntime.GetEventSender("SupportBean");
            EventSender senderThree = epService.EPRuntime.GetEventSender("XMLType");

            long start = PerformanceObserver.NanoTime;

            for (int i = 0; i < 2; i++)
            {
                epService.EPRuntime.SendEvent(new Dictionary <string, Object>(), "MyMap");
                senderOne.SendEvent(new Dictionary <string, Object>());
                epService.EPRuntime.SendEvent(new SupportBean());
                senderTwo.SendEvent(new SupportBean());
                epService.EPRuntime.SendEvent(SupportXML.GetDocument("<myevent/>"));
                senderThree.SendEvent(SupportXML.GetDocument("<myevent/>"));
            }
            long end   = PerformanceObserver.NanoTime;
            long delta = (end - start) / 1000000;

            Assert.IsTrue(delta < 500);

            Thread.Sleep(1000);
            Assert.AreEqual(4, listenerOne.NewEvents.Count);
            Assert.AreEqual(4, listenerTwo.NewEvents.Count);
            Assert.AreEqual(4, listenerThree.NewEvents.Count);

            EPServiceProviderSPI spi = (EPServiceProviderSPI)epService;

            Assert.AreEqual(0, spi.ThreadingService.InboundQueue.Count);
            Assert.IsNotNull(spi.ThreadingService.InboundThreadPool);

            stmtOne.Dispose();
            stmtTwo.Dispose();
            stmtThree.Dispose();
        }
Ejemplo n.º 16
0
        public void SetUp()
        {
            EPServiceProviderManager.PurgeAllProviders();

            Configuration config = SupportConfigFactory.GetConfiguration();

            _epService = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            _listener = new SupportUpdateListener();

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Ejemplo n.º 17
0
        public void SetUp()
        {
            var config = SupportConfigFactory.GetConfiguration();

            _epService = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), GetType().FullName);
            }
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S0));
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S1));
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S2));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Setup the esper.
        /// </summary>
        static void SetupEsper()
        {
            Configuration configuration = new Configuration();

            configuration.AddEventType <BidData>();
            configuration.EngineDefaults.ExpressionConfig.IsUdfCache                     = true;
            configuration.EngineDefaults.LoggingConfig.IsEnableExecutionDebug            = false;
            configuration.EngineDefaults.LoggingConfig.IsEnableTimerDebug                = false;
            configuration.EngineDefaults.MetricsReportingConfig.IsEnableMetricsReporting = false;
            configuration.EngineDefaults.MetricsReportingConfig.IsThreading              = false;

            _espServiceProvider = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(configuration);
            _espAdministrator   = _espServiceProvider.EPAdministrator;
            _espRuntime         = _espServiceProvider.EPRuntime;
        }
        public void SetUp()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddEventType("SupportBean", typeof(SupportBean));
            configuration.EngineDefaults.ExecutionConfig.IsPrioritized = true;
            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _spi = (EPServiceProviderSPI)_epService;

            _listener = new SupportUpdateListener();
        }
Ejemplo n.º 20
0
        public void SetUp()
        {
            var configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddEventType <SupportBean>();
            configuration.AddEventType <SupportBean_S0>();
            configuration.EngineDefaults.LoggingConfig.IsEnableExecutionDebug = true;
            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _spi = (EPServiceProviderSPI)_epService;

            _listener = new SupportUpdateListener();
        }
Ejemplo n.º 21
0
 /// <summary>
 /// For initialization of the service to provide statement context.
 /// </summary>
 /// <param name="epStatement">the statement</param>
 /// <param name="epServiceProvider">the engine instance</param>
 /// <param name="isInsertInto">true if this is insert into</param>
 /// <param name="isPattern">true if this is a pattern statement</param>
 /// <param name="isDistinct">true if using distinct</param>
 /// <param name="isForClause">if set to <c>true</c> [is for clause].</param>
 /// <param name="statementMetricHandle">handle for metrics reporting</param>
 public void SetContext(EPStatementSPI epStatement,
                        EPServiceProviderSPI epServiceProvider,
                        bool isInsertInto,
                        bool isPattern,
                        bool isDistinct,
                        bool isForClause,
                        StatementMetricHandle statementMetricHandle)
 {
     _epStatement           = epStatement;
     _epServiceProvider     = epServiceProvider;
     _isInsertInto          = isInsertInto;
     _isPattern             = isPattern;
     _isDistinct            = isDistinct;
     _isForClause           = isForClause;
     _isMakeSynthetic       = isInsertInto || isPattern || isDistinct || isForClause;
     _statementMetricHandle = statementMetricHandle;
 }
Ejemplo n.º 22
0
        public void SetUp()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddEventType <SupportBean>();
            configuration.AddEventType <SupportBean_S0>();
            configuration.AddPlugInVirtualDataWindow("test", "vdw", typeof(SupportVirtualDWFactory).FullName, SupportVirtualDW.ITERATE);    // configure with iteration

            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            _spi = (EPServiceProviderSPI)_epService;
        }
Ejemplo n.º 23
0
        private void TryAssertionHash(EPServiceProvider epService, SupportUpdateListener listener, string ctx, EPStatementSPI statement, HashCodeFunc codeFunc)
        {
            string[] fields = "c0,c1,c2".Split(',');

            epService.EPRuntime.SendEvent(new SupportBean("E1", 5));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "E1", 5 });
            AssertIterator(statement, fields, new[] { new object[] { ctx, "E1", 5 } });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 6));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "E2", 6 });
            AssertIterator(statement, fields, new[] { new object[] { ctx, "E1", 5 }, new object[] { ctx, "E2", 6 } });

            epService.EPRuntime.SendEvent(new SupportBean("E3", 7));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "E3", 7 });
            AssertIterator(statement, fields, new[] { new object[] { ctx, "E1", 5 }, new object[] { ctx, "E3", 7 }, new object[] { ctx, "E2", 6 } });

            epService.EPRuntime.SendEvent(new SupportBean("E4", 8));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "E4", 8 });
            AssertIterator(statement, fields, new[] { new object[] { ctx, "E1", 5 }, new object[] { ctx, "E3", 7 }, new object[] { ctx, "E4", 8 }, new object[] { ctx, "E2", 6 } });

            epService.EPRuntime.SendEvent(new SupportBean("E5", 9));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "E5", 9 });
            AssertIterator(statement, fields, new[] { new object[] { ctx, "E5", 9 }, new object[] { ctx, "E1", 5 }, new object[] { ctx, "E3", 7 }, new object[] { ctx, "E4", 8 }, new object[] { ctx, "E2", 6 } });

            epService.EPRuntime.SendEvent(new SupportBean("E1", 10));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "E1", 15 });
            AssertIterator(statement, fields, new[] { new object[] { ctx, "E5", 9 }, new object[] { ctx, "E1", 15 }, new object[] { ctx, "E3", 7 }, new object[] { ctx, "E4", 8 }, new object[] { ctx, "E2", 6 } });

            epService.EPRuntime.SendEvent(new SupportBean("E4", 11));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "E4", 19 });
            AssertIterator(statement, fields, new[] { new object[] { ctx, "E5", 9 }, new object[] { ctx, "E1", 15 }, new object[] { ctx, "E3", 7 }, new object[] { ctx, "E4", 19 }, new object[] { ctx, "E2", 6 } });

            statement.Stop();
            AgentInstanceAssertionUtil.AssertInstanceCounts(statement.StatementContext, 0, 0, 0, 0);

            EPServiceProviderSPI spi = (EPServiceProviderSPI)epService;

            Assert.AreEqual(1, spi.ContextManagementService.ContextCount);
            epService.EPAdministrator.GetStatement("context").Dispose();
            Assert.AreEqual(1, spi.ContextManagementService.ContextCount);

            statement.Dispose();
            Assert.AreEqual(0, spi.ContextManagementService.ContextCount);
        }
Ejemplo n.º 24
0
        private void RunAssertionLifecycle(EPServiceProvider epService)
        {
            string epl = "@Name('context') create context NineToFive as start (0, 9, *, *, *) end (0, 17, *, *, *)";
            EPServiceProviderSPI     spi               = (EPServiceProviderSPI)epService;
            ContextManagementService ctxMgmtService    = spi.ContextManagementService;
            SchedulingService        schedulingService = spi.SchedulingService;

            Assert.AreEqual(0, ctxMgmtService.ContextCount);
            Assert.AreEqual(0, schedulingService.ScheduleHandleCount);

            // create and destroy
            EPStatement stmtContext = epService.EPAdministrator.CreateEPL(epl);

            Assert.AreEqual(1, ctxMgmtService.ContextCount);
            Assert.AreEqual(0, schedulingService.ScheduleHandleCount);

            stmtContext.Dispose();
            Assert.AreEqual(0, ctxMgmtService.ContextCount);

            // create context, create statement, destroy statement, destroy context
            stmtContext = epService.EPAdministrator.CreateEPL(epl);
            Assert.AreEqual(1, ctxMgmtService.ContextCount);

            EPStatement stmt = epService.EPAdministrator.CreateEPL("@Name('C') context NineToFive select * from SupportBean");

            Assert.AreEqual(1, schedulingService.ScheduleHandleCount);

            stmt.Dispose();
            Assert.AreEqual(0, schedulingService.ScheduleHandleCount);

            stmtContext.Dispose();
            Assert.AreEqual(0, ctxMgmtService.ContextCount);

            // create same context
            epService.EPAdministrator.CreateEPL(epl);
            epService.EPAdministrator.CreateEPL("@Name('C') context NineToFive select * from SupportBean");
            epService.EPAdministrator.CreateEPL("@Name('D') context NineToFive select * from SupportBean");
            epService.EPAdministrator.DestroyAllStatements();
            Assert.AreEqual(0, ctxMgmtService.ContextCount);
            Assert.AreEqual(0, schedulingService.ScheduleHandleCount);

            epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertionStatementStateChange()
        {
            EPServiceProvider stateChangeEngine = EPServiceProviderManager.GetProvider(
                SupportContainer.Instance, this.GetType().Name + "_statechange",
                SupportConfigFactory.GetConfiguration());
            EPServiceProviderSPI spi = (EPServiceProviderSPI)stateChangeEngine;

            var observer = new SupportStmtLifecycleObserver();

            spi.StatementLifecycleSvc.LifecycleEvent += observer.Observe;
            var listener = new SupportStatementStateListener();

            stateChangeEngine.StatementCreate      += listener.OnStatementCreate;
            stateChangeEngine.StatementStateChange += listener.OnStatementStateChange;

            EPStatement stmt = stateChangeEngine.EPAdministrator.CreateEPL("select * from " + typeof(SupportBean).FullName);

            Assert.AreEqual("CREATE;STATECHANGE;", observer.EventsAsString);
            Assert.AreEqual(stmt, listener.AssertOneGetAndResetCreatedEvents());
            Assert.AreEqual(stmt, listener.AssertOneGetAndResetStateChangeEvents());

            observer.Flush();
            stmt.Stop();
            Assert.AreEqual("STATECHANGE;", observer.EventsAsString);
            Assert.AreEqual(stmt.Name, observer.Events[0].Statement.Name);
            Assert.AreEqual(stmt, listener.AssertOneGetAndResetStateChangeEvents());

            observer.Flush();
            stmt.Events += (sender, args) => { };
            Assert.AreEqual("LISTENER_ADD;", observer.EventsAsString);
            Assert.IsNotNull(observer.LastContext);
            Assert.IsTrue(observer.LastContext[0] is UpdateEventHandler);

            observer.Flush();
            stmt.RemoveAllEventHandlers();
            Assert.AreEqual(StatementLifecycleEvent.LifecycleEventType.LISTENER_REMOVE_ALL.ToString() + ";", observer.EventsAsString);

            stmt.Dispose();
            Assert.AreEqual(stmt, listener.AssertOneGetAndResetStateChangeEvents());

            stateChangeEngine.Dispose();
        }
Ejemplo n.º 26
0
        public void TestWithAdapterLoader()
        {
            // Assure destroy order ESPER-489
            Configuration config = SupportConfigFactory.GetConfiguration();

            Properties props = new Properties();

            props["name"] = "val";
            config.AddPluginLoader("MyLoader", typeof(SupportPluginLoader).FullName, props);

            props          = new Properties();
            props["name2"] = "val2";
            config.AddPluginLoader("MyLoader2", typeof(SupportPluginLoader).FullName, props);

            EPServiceProvider service = EPServiceProviderManager.GetProvider("TestAdapterLoader", config);

            Assert.AreEqual(2, SupportPluginLoader.Names.Count);
            Assert.AreEqual(2, SupportPluginLoader.PostInitializes.Count);
            Assert.AreEqual("MyLoader", SupportPluginLoader.Names[0]);
            Assert.AreEqual("MyLoader2", SupportPluginLoader.Names[1]);
            Assert.AreEqual("val", SupportPluginLoader.Props[0].Get("name"));
            Assert.AreEqual("val2", SupportPluginLoader.Props[1].Get("name2"));

            EPServiceProviderSPI spi = (EPServiceProviderSPI)service;
            Object loader            = spi.EngineEnvContext.Lookup("plugin-loader/MyLoader");

            Assert.IsTrue(loader is SupportPluginLoader);
            loader = spi.EngineEnvContext.Lookup("plugin-loader/MyLoader2");
            Assert.IsTrue(loader is SupportPluginLoader);

            SupportPluginLoader.PostInitializes.Clear();
            SupportPluginLoader.Names.Clear();
            service.Initialize();
            Assert.AreEqual(2, SupportPluginLoader.PostInitializes.Count);
            Assert.AreEqual(2, SupportPluginLoader.Names.Count);

            service.Dispose();
            Assert.AreEqual(2, SupportPluginLoader.Destroys.Count);
            Assert.AreEqual("val2", SupportPluginLoader.Destroys[0].Get("name2"));
            Assert.AreEqual("val", SupportPluginLoader.Destroys[1].Get("name"));
        }
Ejemplo n.º 27
0
        public void SetUp()
        {
            var configDB = new ConfigurationDBRef();

            configDB.SetDatabaseDriver(SupportDatabaseService.DbDriverFactoryNative);

            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddDatabaseReference("MyDB", configDB);
            configuration.AddEventType("SupportBean", typeof(SupportBean));
            configuration.AddEventType("SupportBean_S0", typeof(SupportBean_S0));
            configuration.AddEventType("SupportBean_S1", typeof(SupportBean_S1));
            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            _spi = (EPServiceProviderSPI)_epService;
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="epService">the EPServiceProvider for the engine runtime and services</param>
        /// <param name="usingEngineThread">true if the Adapter should set time by the scheduling service in the engine,false if it should set time externally through the calling thread</param>
        /// <param name="usingExternalTimer">true to use esper's external timer mechanism instead of internal timing</param>
        /// <param name="usingTimeSpanEvents"></param>
        protected AbstractCoordinatedAdapter(EPServiceProvider epService, bool usingEngineThread, bool usingExternalTimer, bool usingTimeSpanEvents)
        {
            UsingEngineThread   = usingEngineThread;
            UsingExternalTimer  = usingExternalTimer;
            UsingTimeSpanEvents = usingTimeSpanEvents;
            Sender = new DirectSender();

            if (epService == null)
            {
                return;
            }
            if (!(epService is EPServiceProviderSPI))
            {
                throw new ArgumentException("Invalid epService provided");
            }

            _epService         = (EPServiceProviderSPI)epService;
            _container         = _epService.Container;
            Runtime            = epService.EPRuntime;
            _schedulingService = ((EPServiceProviderSPI)epService).SchedulingService;
        }
Ejemplo n.º 29
0
        public void SetUp()
        {
            var configDB = new ConfigurationDBRef();

            configDB.SetDatabaseDriver(SupportDatabaseService.DbDriverFactoryNative);
            //configDB.SetDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties());

            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddDatabaseReference("MyDB", configDB);
            configuration.AddEventType <SupportBean>();
            configuration.AddEventType <SupportBean_S0>();
            configuration.AddEventType <SupportBean_S1>();
            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName);
            }

            _spi = (EPServiceProviderSPI)_epService;
        }
Ejemplo n.º 30
0
        private void RunAssertionVariantRStreamOMToStmt(EPServiceProvider epService)
        {
            var model = new EPStatementObjectModel();

            model.InsertInto   = InsertIntoClause.Create("Event_1_RSOM", new string[0], StreamSelector.RSTREAM_ONLY);
            model.SelectClause = SelectClause.Create().Add("IntPrimitive", "IntBoxed");
            model.FromClause   = FromClause.Create(FilterStream.Create(typeof(SupportBean).FullName));
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);

            EPStatement stmt = epService.EPAdministrator.Create(model, "s1");

            string epl = "insert rstream into Event_1_RSOM " +
                         "select IntPrimitive, IntBoxed " +
                         "from " + typeof(SupportBean).FullName;

            Assert.AreEqual(epl, model.ToEPL());
            Assert.AreEqual(epl, stmt.Text);

            EPStatementObjectModel modelTwo = epService.EPAdministrator.CompileEPL(model.ToEPL());

            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);
            Assert.AreEqual(epl, modelTwo.ToEPL());

            // assert statement-type reference
            EPServiceProviderSPI spi = (EPServiceProviderSPI)epService;

            Assert.IsTrue(spi.StatementEventTypeRef.IsInUse("Event_1_RSOM"));
            var stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportBean).FullName);

            Assert.IsTrue(stmtNames.Contains("s1"));

            stmt.Dispose();

            Assert.IsFalse(spi.StatementEventTypeRef.IsInUse("Event_1_RSOM"));
            stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportBean).FullName);
            Assert.IsFalse(stmtNames.Contains("s1"));
        }