Exemplo n.º 1
0
        /// <summary>
        /// Test that capacity metrics are exported and pass
        /// basic sanity tests.
        /// </summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestCapacityMetrics()
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(NsMetrics);
            long capacityTotal      = MetricsAsserts.GetLongGauge("CapacityTotal", rb);

            System.Diagnostics.Debug.Assert((capacityTotal != 0));
            long capacityUsed       = MetricsAsserts.GetLongGauge("CapacityUsed", rb);
            long capacityRemaining  = MetricsAsserts.GetLongGauge("CapacityRemaining", rb);
            long capacityUsedNonDFS = MetricsAsserts.GetLongGauge("CapacityUsedNonDFS", rb);

            System.Diagnostics.Debug.Assert((capacityUsed + capacityRemaining + capacityUsedNonDFS
                                             == capacityTotal));
        }
Exemplo n.º 2
0
        public virtual void TestTransactionAndCheckpointMetrics()
        {
            long lastCkptTime = MetricsAsserts.GetLongGauge("LastCheckpointTime", MetricsAsserts.GetMetrics
                                                                (NsMetrics));

            MetricsAsserts.AssertGauge("LastCheckpointTime", lastCkptTime, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("LastWrittenTransactionId", 1L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("TransactionsSinceLastCheckpoint", 1L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("TransactionsSinceLastLogRoll", 1L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            fs.Mkdirs(new Path(TestRootDirPath, "/tmp"));
            UpdateMetrics();
            MetricsAsserts.AssertGauge("LastCheckpointTime", lastCkptTime, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("LastWrittenTransactionId", 2L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("TransactionsSinceLastCheckpoint", 2L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("TransactionsSinceLastLogRoll", 2L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            cluster.GetNameNodeRpc().RollEditLog();
            UpdateMetrics();
            MetricsAsserts.AssertGauge("LastCheckpointTime", lastCkptTime, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("LastWrittenTransactionId", 4L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("TransactionsSinceLastCheckpoint", 4L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("TransactionsSinceLastLogRoll", 1L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            cluster.GetNameNodeRpc().SetSafeMode(HdfsConstants.SafeModeAction.SafemodeEnter,
                                                 false);
            cluster.GetNameNodeRpc().SaveNamespace();
            cluster.GetNameNodeRpc().SetSafeMode(HdfsConstants.SafeModeAction.SafemodeLeave,
                                                 false);
            UpdateMetrics();
            long newLastCkptTime = MetricsAsserts.GetLongGauge("LastCheckpointTime", MetricsAsserts.GetMetrics
                                                                   (NsMetrics));

            NUnit.Framework.Assert.IsTrue(lastCkptTime < newLastCkptTime);
            MetricsAsserts.AssertGauge("LastWrittenTransactionId", 6L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("TransactionsSinceLastCheckpoint", 1L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertGauge("TransactionsSinceLastLogRoll", 1L, MetricsAsserts.GetMetrics
                                           (NsMetrics));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Wait for the named gauge value from the metrics source to reach the
        /// desired value.
        /// </summary>
        /// <remarks>
        /// Wait for the named gauge value from the metrics source to reach the
        /// desired value.
        /// There's an initial delay then a spin cycle of sleep and poll. Because
        /// all the tests use a shared FS instance, these tests are not independent;
        /// that's why the initial sleep is in there.
        /// </remarks>
        /// <param name="source">metrics source</param>
        /// <param name="name">gauge name</param>
        /// <param name="expected">expected value</param>
        /// <returns>the last metrics record polled</returns>
        /// <exception cref="System.Exception">if something went wrong.</exception>
        private MetricsRecordBuilder WaitForDnMetricValue(string source, string name, long
                                                          expected)
        {
            MetricsRecordBuilder rb;
            long gauge;

            //initial wait.
            WaitForDeletion();
            //lots of retries are allowed for slow systems; fast ones will still
            //exit early
            int retries = (DatanodeCount + 1) * WaitGaugeValueRetries;

            rb    = MetricsAsserts.GetMetrics(source);
            gauge = MetricsAsserts.GetLongGauge(name, rb);
            while (gauge != expected && (--retries > 0))
            {
                Sharpen.Thread.Sleep(DfsReplicationInterval * 500);
                rb    = MetricsAsserts.GetMetrics(source);
                gauge = MetricsAsserts.GetLongGauge(name, rb);
            }
            //at this point the assertion is valid or the retry count ran out
            MetricsAsserts.AssertGauge(name, expected, rb);
            return(rb);
        }