示例#1
0
        /// <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?>();
        }
示例#2
0
        /// <summary>Account row output. </summary>
        /// <param name="handle">statement handle</param>
        /// <param name="numIStream">num rows insert stream</param>
        /// <param name="numRStream">num rows remove stream</param>
        public void AccountOutput(StatementMetricHandle handle,
                                  int numIStream,
                                  int numRStream)
        {
            StatementMetricArray array = _groupMetrics[handle.GroupNum];

            using (array.RWLock.AcquireReadLock())
            {
                StatementMetric metric = array.GetAddMetric(handle.Index);
                metric.AddNumOutputIStream(numIStream);
                metric.AddNumOutputRStream(numRStream);
            }
        }
示例#3
0
        /// <summary>
        /// Account statement times.
        /// </summary>
        /// <param name="handle">statement handle</param>
        /// <param name="cpu">time</param>
        /// <param name="wall">time</param>
        /// <param name="numInput">The num input.</param>
        public void AccountTimes(StatementMetricHandle handle,
                                 long cpu,
                                 long wall,
                                 int numInput)
        {
            StatementMetricArray array = _groupMetrics[handle.GroupNum];

            using (array.RWLock.AcquireReadLock())
            {
                StatementMetric metric = array.GetAddMetric(handle.Index);
                metric.IncrementTime(cpu, wall);
                metric.AddNumInput(numInput);
            }
        }
示例#4
0
        public void TestFlowReportInactive()
        {
            var rep = new StatementMetricArray("uri", "name", 3, true);

            Assert.AreEqual(0, rep.AddStatementGetIndex("001"));
            Assert.AreEqual(1, rep.AddStatementGetIndex("002"));
            Assert.AreEqual(2, rep.AddStatementGetIndex("003"));
            rep.RemoveStatement("002");

            StatementMetric[] flushed = rep.FlushMetrics();
            for (int i = 0; i < 3; i++)
            {
                Assert.IsNotNull(flushed[i]);
            }
        }
示例#5
0
        public void TestFlowReportActive()
        {
            var rep = new StatementMetricArray("uri", "name", 3, false);

            Assert.AreEqual(0, rep.SizeLastElement);

            Assert.AreEqual(0, rep.AddStatementGetIndex("001"));
            Assert.AreEqual(1, rep.SizeLastElement);

            Assert.AreEqual(1, rep.AddStatementGetIndex("002"));
            Assert.AreEqual(2, rep.AddStatementGetIndex("003"));
            Assert.AreEqual(3, rep.SizeLastElement);

            rep.RemoveStatement("002");

            Assert.AreEqual(3, rep.AddStatementGetIndex("004"));
            Assert.AreEqual(4, rep.AddStatementGetIndex("005"));

            rep.RemoveStatement("005");
            Assert.AreEqual(5, rep.AddStatementGetIndex("006"));

            var metrics = new StatementMetric[6];

            for (int i = 0; i < 6; i++)
            {
                metrics[i] = rep.GetAddMetric(i);
            }

            StatementMetric[] flushed = rep.FlushMetrics();
            ArrayAssertionUtil.AssertSameExactOrder(metrics, flushed);

            Assert.AreEqual(1, rep.AddStatementGetIndex("007"));
            Assert.AreEqual(4, rep.AddStatementGetIndex("008"));

            rep.RemoveStatement("001");
            rep.RemoveStatement("003");
            rep.RemoveStatement("004");
            rep.RemoveStatement("006");
            rep.RemoveStatement("007");
            Assert.AreEqual(6, rep.SizeLastElement);
            rep.RemoveStatement("008");
            Assert.AreEqual(6, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.AreEqual(6, flushed.Length);
            Assert.AreEqual(0, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.IsNull(flushed);
            Assert.AreEqual(0, rep.SizeLastElement);

            Assert.AreEqual(0, rep.AddStatementGetIndex("009"));
            Assert.AreEqual(1, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.AreEqual(6, flushed.Length);
            for (int i = 0; i < flushed.Length; i++)
            {
                Assert.IsNull(flushed[i]);
            }
            Assert.AreEqual(1, rep.SizeLastElement);
        }