/// <summary>Ctor. </summary> /// <param name="engineURI">engine URI</param> /// <param name="specification">specifies statement groups</param> public StatementMetricRepository(String engineURI, ConfigurationMetricsReporting specification) { _specification = specification; int numGroups = specification.StatementGroups.Count + 1; // +1 for default group (remaining stmts) _groupMetrics = new StatementMetricArray[numGroups]; // default group _groupMetrics[0] = new StatementMetricArray(engineURI, "group-default", 100, false); // initialize all other groups int countGroups = 1; foreach (var entry in specification.StatementGroups) { ConfigurationMetricsReporting.StmtGroupMetrics config = entry.Value; int initialNumStmts = config.NumStatements; if (initialNumStmts < 10) { initialNumStmts = 10; } _groupMetrics[countGroups] = new StatementMetricArray(engineURI, "group-" + countGroups, initialNumStmts, config.IsReportInactive); countGroups++; } _statementGroups = new Dictionary <String, int?>(); }
public override void Configure(Configuration configuration) { ApplyMetricsConfig(configuration, -1, 7000, true); var groupOne = new ConfigurationMetricsReporting.StmtGroupMetrics(); groupOne.Interval = 8000; groupOne.AddIncludeLike("%GroupOne%"); groupOne.IsReportInactive = true; configuration.EngineDefaults.MetricsReporting.AddStmtGroup("GroupOneStatements", groupOne); var groupTwo = new ConfigurationMetricsReporting.StmtGroupMetrics(); groupTwo.Interval = 6000; groupTwo.IsDefaultInclude = true; groupTwo.AddExcludeLike("%Default%"); groupTwo.AddExcludeLike("%Metrics%"); configuration.EngineDefaults.MetricsReporting.AddStmtGroup("GroupTwoNonDefaultStatements", groupTwo); var groupThree = new ConfigurationMetricsReporting.StmtGroupMetrics(); groupThree.Interval = -1; groupThree.AddIncludeLike("%Metrics%"); configuration.EngineDefaults.MetricsReporting.AddStmtGroup("MetricsStatements", groupThree); }
public void TestEnabledDisableStatement() { var fields = new String[] { "StatementName" }; var statements = new EPStatement[5]; var config = GetConfig(-1, 10000, true); var configOne = new ConfigurationMetricsReporting.StmtGroupMetrics(); configOne.Interval = -1; configOne.AddIncludeLike("%@METRIC%"); config.EngineDefaults.MetricsReportingConfig.AddStmtGroup("metrics", configOne); _epService = EPServiceProviderManager.GetProvider("MyURI", config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } SendTimer(1000); statements[0] = _epService.EPAdministrator.CreateEPL("select * from " + typeof(StatementMetric).FullName, "MyStatement@METRIC"); statements[0].Events += _listenerStmtMetric.Update; statements[1] = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive=1).win:keepall() where 2=2", "stmtone"); SendEvent("E1", 1, CpuGoalOneNano); statements[2] = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive>0).std:lastevent() where 1=1", "stmttwo"); SendEvent("E2", 1, CpuGoalOneNano); SendTimer(11000); EPAssertionUtil.AssertPropsPerRow(_listenerStmtMetric.GetNewDataListFlattened(), fields, new Object[][] { new Object[] { "stmtone" }, new Object[] { "stmttwo" } }); _listenerStmtMetric.Reset(); SendEvent("E1", 1, CpuGoalOneNano); SendTimer(21000); EPAssertionUtil.AssertPropsPerRow(_listenerStmtMetric.GetNewDataListFlattened(), fields, new Object[][] { new Object[] { "stmtone" }, new Object[] { "stmttwo" } }); _listenerStmtMetric.Reset(); _epService.EPAdministrator.Configuration.SetMetricsReportingStmtDisabled("stmtone"); SendEvent("E1", 1, CpuGoalOneNano); SendTimer(31000); EPAssertionUtil.AssertPropsPerRow(_listenerStmtMetric.GetNewDataListFlattened(), fields, new Object[][] { new Object[] { "stmttwo" } }); _listenerStmtMetric.Reset(); _epService.EPAdministrator.Configuration.SetMetricsReportingStmtEnabled("stmtone"); _epService.EPAdministrator.Configuration.SetMetricsReportingStmtDisabled("stmttwo"); SendEvent("E1", 1, CpuGoalOneNano); SendTimer(41000); EPAssertionUtil.AssertPropsPerRow(_listenerStmtMetric.GetNewDataListFlattened(), fields, new Object[][] { new Object[] { "stmtone" } }); _listenerStmtMetric.Reset(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public override void Configure(Configuration configuration) { ApplyMetricsConfig(configuration, -1, 10000, true); var configOne = new ConfigurationMetricsReporting.StmtGroupMetrics(); configOne.Interval = -1; configOne.AddIncludeLike("%@METRIC%"); configuration.EngineDefaults.MetricsReporting.AddStmtGroup("metrics", configOne); }
public override void Configure(Configuration configuration) { ApplyMetricsConfig(configuration, -1, -1, true); var configOne = new ConfigurationMetricsReporting.StmtGroupMetrics(); configOne.Interval = 10000; configOne.AddIncludeLike("%cpuStmt%"); configOne.AddIncludeLike("%wallStmt%"); configuration.EngineDefaults.MetricsReporting.AddStmtGroup("nonmetrics", configOne); // exclude metrics themselves from reporting var configTwo = new ConfigurationMetricsReporting.StmtGroupMetrics(); configTwo.Interval = -1; configOne.AddExcludeLike("%metrics%"); configuration.EngineDefaults.MetricsReporting.AddStmtGroup("metrics", configTwo); }
public void TestStatementMetrics() { Configuration config = GetConfig(-1, -1, true); // report on all statements every 10 seconds ConfigurationMetricsReporting.StmtGroupMetrics configOne = new ConfigurationMetricsReporting.StmtGroupMetrics(); configOne.Interval = 10000; configOne.AddIncludeLike("%cpuStmt%"); configOne.AddIncludeLike("%wallStmt%"); config.EngineDefaults.MetricsReportingConfig.AddStmtGroup("nonmetrics", configOne); // exclude metrics themselves from reporting ConfigurationMetricsReporting.StmtGroupMetrics configTwo = new ConfigurationMetricsReporting.StmtGroupMetrics(); configTwo.Interval = -1; configOne.AddExcludeLike("%metrics%"); config.EngineDefaults.MetricsReportingConfig.AddStmtGroup("metrics", configTwo); _epService = EPServiceProviderManager.GetProvider("MyURI", config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } SendTimer(1000); EPStatement[] statements = new EPStatement[5]; statements[0] = _epService.EPAdministrator.CreateEPL("select * from " + typeof(StatementMetric).FullName, "stmt_metrics"); statements[0].Events += _listener.Update; statements[1] = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive=1).win:keepall() where MyMetricFunctions.TakeCpuTime(LongPrimitive)", "cpuStmtOne"); statements[1].Events += _listenerTwo.Update; statements[2] = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive=2).win:keepall() where MyMetricFunctions.TakeCpuTime(LongPrimitive)", "cpuStmtTwo"); statements[2].Events += _listenerTwo.Update; statements[3] = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive=3).win:keepall() where MyMetricFunctions.TakeWallTime(LongPrimitive)", "wallStmtThree"); statements[3].Events += _listenerTwo.Update; statements[4] = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive=4).win:keepall() where MyMetricFunctions.TakeWallTime(LongPrimitive)", "wallStmtFour"); statements[4].Events += _listenerTwo.Update; SendEvent("E1", 1, CpuGoalOneNano); SendEvent("E2", 2, CpuGoalTwoNano); SendEvent("E3", 3, WallGoalOneMsec); SendEvent("E4", 4, WallGoalTwoMsec); SendTimer(10999); Assert.IsFalse(_listener.IsInvoked); SendTimer(11000); RunAssertion(11000); SendEvent("E1", 1, CpuGoalOneNano); SendEvent("E2", 2, CpuGoalTwoNano); SendEvent("E3", 3, WallGoalOneMsec); SendEvent("E4", 4, WallGoalTwoMsec); SendTimer(21000); RunAssertion(21000); // destroy all application stmts for (int i = 1; i < 5; i++) { statements[i].Dispose(); } SendTimer(31000); Assert.IsFalse(_listener.IsInvoked); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestStatementGroups() { Configuration config = GetConfig(-1, 7000, true); ConfigurationMetricsReporting.StmtGroupMetrics groupOne = new ConfigurationMetricsReporting.StmtGroupMetrics(); groupOne.Interval = 8000; groupOne.AddIncludeLike("%GroupOne%"); groupOne.IsReportInactive = true; config.EngineDefaults.MetricsReportingConfig.AddStmtGroup("GroupOneStatements", groupOne); ConfigurationMetricsReporting.StmtGroupMetrics groupTwo = new ConfigurationMetricsReporting.StmtGroupMetrics(); groupTwo.Interval = 6000; groupTwo.IsDefaultInclude = true; groupTwo.AddExcludeLike("%Default%"); groupTwo.AddExcludeLike("%Metrics%"); config.EngineDefaults.MetricsReportingConfig.AddStmtGroup("GroupTwoNonDefaultStatements", groupTwo); ConfigurationMetricsReporting.StmtGroupMetrics groupThree = new ConfigurationMetricsReporting.StmtGroupMetrics(); groupThree.Interval = -1; groupThree.AddIncludeLike("%Metrics%"); config.EngineDefaults.MetricsReportingConfig.AddStmtGroup("MetricsStatements", groupThree); _epService = EPServiceProviderManager.GetProvider("MyURI", config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } SendTimer(0); _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive = 1).win:keepall()", "GroupOne"); EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive = 2).win:keepall()", "GroupTwo"); stmt.Subscriber = new SupportSubscriber(); _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive = 3).win:keepall()", "Default"); // no listener stmt = _epService.EPAdministrator.CreateEPL("select * from " + typeof(StatementMetric).FullName, "StmtMetrics"); stmt.Events += _listener.Update; SendTimer(6000); SendTimer(7000); Assert.IsFalse(_listener.IsInvoked); SendTimer(8000); String[] fields = "StatementName,OutputIStreamCount,NumInput".Split(','); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "GroupOne", 0L, 0L }); SendTimer(12000); SendTimer(14000); SendTimer(15999); Assert.IsFalse(_listener.IsInvoked); SendTimer(16000); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "GroupOne", 0L, 0L }); // should report as groupTwo _epService.EPRuntime.SendEvent(new SupportBean("E1", 2)); SendTimer(17999); Assert.IsFalse(_listener.IsInvoked); SendTimer(18000); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "GroupTwo", 1L, 1L }); // should report as groupTwo _epService.EPRuntime.SendEvent(new SupportBean("E1", 3)); SendTimer(20999); Assert.IsFalse(_listener.IsInvoked); SendTimer(21000); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "Default", 0L, 1L }); // turn off group 1 _epService.EPAdministrator.Configuration.SetMetricsReportingInterval("GroupOneStatements", -1); SendTimer(24000); Assert.IsFalse(_listener.IsInvoked); // turn on group 1 _epService.EPAdministrator.Configuration.SetMetricsReportingInterval("GroupOneStatements", 1000); SendTimer(25000); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "GroupOne", 0L, 0L }); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }