Ejemplo n.º 1
0
        public virtual void TestContainerMetricsFlow()
        {
            string Err = "Error in number of records";
            // Create a dummy MetricsSystem
            MetricsSystem system = Org.Mockito.Mockito.Mock <MetricsSystem>();

            Org.Mockito.Mockito.DoReturn(this).When(system).Register(Matchers.AnyString(), Matchers.AnyString
                                                                         (), Matchers.Any());
            MetricsCollectorImpl collector   = new MetricsCollectorImpl();
            ContainerId          containerId = Org.Mockito.Mockito.Mock <ContainerId>();
            ContainerMetrics     metrics     = ContainerMetrics.ForContainer(containerId, 100, 1);

            metrics.RecordMemoryUsage(1024);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 0, collector.GetRecords().Count);
            Sharpen.Thread.Sleep(110);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 1, collector.GetRecords().Count);
            collector.Clear();
            Sharpen.Thread.Sleep(110);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 1, collector.GetRecords().Count);
            collector.Clear();
            metrics.Finished();
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 1, collector.GetRecords().Count);
            collector.Clear();
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 0, collector.GetRecords().Count);
            Sharpen.Thread.Sleep(110);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 0, collector.GetRecords().Count);
        }
Ejemplo n.º 2
0
        public static MetricsSystem MockMetricsSystem()
        {
            MetricsSystem ms = Org.Mockito.Mockito.Mock <MetricsSystem>();

            DefaultMetricsSystem.SetInstance(ms);
            return(ms);
        }
Ejemplo n.º 3
0
        public virtual void TestContainerMetricsLimit()
        {
            string        Err    = "Error in number of records";
            MetricsSystem system = Org.Mockito.Mockito.Mock <MetricsSystem>();

            Org.Mockito.Mockito.DoReturn(this).When(system).Register(Matchers.AnyString(), Matchers.AnyString
                                                                         (), Matchers.Any());
            MetricsCollectorImpl collector   = new MetricsCollectorImpl();
            ContainerId          containerId = Org.Mockito.Mockito.Mock <ContainerId>();
            ContainerMetrics     metrics     = ContainerMetrics.ForContainer(containerId, 100, 1);
            int    anyPmemLimit = 1024;
            int    anyVmemLimit = 2048;
            int    anyVcores    = 10;
            string anyProcessId = "1234";

            metrics.RecordResourceLimit(anyVmemLimit, anyPmemLimit, anyVcores);
            metrics.RecordProcessId(anyProcessId);
            Sharpen.Thread.Sleep(110);
            metrics.GetMetrics(collector, true);
            NUnit.Framework.Assert.AreEqual(Err, 1, collector.GetRecords().Count);
            MetricsRecord record = collector.GetRecords()[0];

            MetricsRecords.AssertTag(record, ContainerMetrics.ProcessidInfo.Name(), anyProcessId
                                     );
            MetricsRecords.AssertMetric(record, ContainerMetrics.PmemLimitMetricName, anyPmemLimit
                                        );
            MetricsRecords.AssertMetric(record, ContainerMetrics.VmemLimitMetricName, anyVmemLimit
                                        );
            MetricsRecords.AssertMetric(record, ContainerMetrics.VcoreLimitMetricName, anyVcores
                                        );
            collector.Clear();
        }
Ejemplo n.º 4
0
        public static MetricsSource UserSource(MetricsSystem ms, string queue, string user
                                               )
        {
            MetricsSource s = ms.GetSource(QueueMetrics.SourceName(queue).Append(",user=").Append
                                               (user).ToString());

            return(s);
        }
Ejemplo n.º 5
0
        public virtual void TearDown()
        {
            ClusterMetrics.Destroy();
            MetricsSystem ms = DefaultMetricsSystem.Instance();

            if (ms.GetSource("ClusterMetrics") != null)
            {
                DefaultMetricsSystem.Shutdown();
            }
        }
        Create()
        {
            MetricsSystem ms = DefaultMetricsSystem.Instance();

            Org.Apache.Hadoop.Yarn.Server.Sharedcachemanager.Metrics.SharedCacheUploaderMetrics
                metrics = new Org.Apache.Hadoop.Yarn.Server.Sharedcachemanager.Metrics.SharedCacheUploaderMetrics
                              ();
            ms.Register("SharedCacheUploaderRequests", null, metrics);
            return(metrics);
        }
Ejemplo n.º 7
0
        private FSOpDurations()
        {
            registry = new MetricsRegistry(RecordInfo);
            registry.Tag(RecordInfo, "FSOpDurations");
            MetricsSystem ms = DefaultMetricsSystem.Instance();

            if (ms != null)
            {
                ms.Register(RecordInfo.Name(), RecordInfo.Description(), this);
            }
        }
Ejemplo n.º 8
0
        private static void RegisterMetrics()
        {
            registry = new MetricsRegistry(RecordInfo);
            registry.Tag(RecordInfo, "ResourceManager");
            MetricsSystem ms = DefaultMetricsSystem.Instance();

            if (ms != null)
            {
                ms.Register("ClusterMetrics", "Metrics for the Yarn Cluster", Instance);
            }
        }
Ejemplo n.º 9
0
        public static Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3Metrics Create(Configuration conf
                                                                         , string gatewayName)
        {
            string        sessionId = conf.Get(DFSConfigKeys.DfsMetricsSessionIdKey);
            MetricsSystem ms        = DefaultMetricsSystem.Instance();
            JvmMetrics    jm        = JvmMetrics.Create(gatewayName, sessionId, ms);

            // Percentile measurement is [50th,75th,90th,95th,99th] currently
            int[] intervals = conf.GetInts(NfsConfigKeys.NfsMetricsPercentilesIntervalsKey);
            return(ms.Register(new Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3Metrics(gatewayName, sessionId
                                                                               , intervals, jm)));
        }
Ejemplo n.º 10
0
        public static Org.Apache.Hadoop.Hdfs.Server.Namenode.Metrics.NameNodeMetrics Create
            (Configuration conf, HdfsServerConstants.NamenodeRole r)
        {
            string        sessionId   = conf.Get(DFSConfigKeys.DfsMetricsSessionIdKey);
            string        processName = r.ToString();
            MetricsSystem ms          = DefaultMetricsSystem.Instance();
            JvmMetrics    jm          = JvmMetrics.Create(processName, sessionId, ms);

            // Percentile measurement is off by default, by watching no intervals
            int[] intervals = conf.GetInts(DFSConfigKeys.DfsMetricsPercentilesIntervalsKey);
            return(ms.Register(new Org.Apache.Hadoop.Hdfs.Server.Namenode.Metrics.NameNodeMetrics
                                   (processName, sessionId, intervals, jm)));
        }
Ejemplo n.º 11
0
        Create()
        {
            MetricsSystem ms = DefaultMetricsSystem.Instance();

            Org.Apache.Hadoop.Yarn.Server.Sharedcachemanager.Metrics.CleanerMetrics metricObject
                = new Org.Apache.Hadoop.Yarn.Server.Sharedcachemanager.Metrics.CleanerMetrics();
            MetricsSourceBuilder sb = MetricsAnnotations.NewSourceBuilder(metricObject);
            MetricsSource        s  = sb.Build();

            ms.Register("cleaner", "The cleaner service of truly shared cache", s);
            metricObject.metricSource = s;
            return(metricObject);
        }
Ejemplo n.º 12
0
        protected internal QueueMetrics(MetricsSystem ms, string queueName, Queue parent,
                                        bool enableUserMetrics, Configuration conf)
        {
            registry       = new MetricsRegistry(RecordInfo);
            this.queueName = queueName;
            this.parent    = parent != null?parent.GetMetrics() : null;

            this.users = enableUserMetrics ? new Dictionary <string, Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.QueueMetrics
                                                             >() : null;
            metricsSystem = ms;
            this.conf     = conf;
            runningTime   = BuildBuckets(conf);
        }
Ejemplo n.º 13
0
        public static Org.Apache.Hadoop.Hdfs.Server.Datanode.Metrics.DataNodeMetrics Create
            (Configuration conf, string dnName)
        {
            string        sessionId = conf.Get(DFSConfigKeys.DfsMetricsSessionIdKey);
            MetricsSystem ms        = DefaultMetricsSystem.Instance();
            JvmMetrics    jm        = JvmMetrics.Create("DataNode", sessionId, ms);
            string        name      = "DataNodeActivity-" + (dnName.IsEmpty() ? "UndefinedDataNodeName" +
                                                             DFSUtil.GetRandom().Next() : dnName.Replace(':', '-'));

            // Percentile measurement is off by default, by watching no intervals
            int[] intervals = conf.GetInts(DFSConfigKeys.DfsMetricsPercentilesIntervalsKey);
            return(ms.Register(name, null, new Org.Apache.Hadoop.Hdfs.Server.Datanode.Metrics.DataNodeMetrics
                                   (name, sessionId, intervals, jm)));
        }
Ejemplo n.º 14
0
        public virtual void TearDown()
        {
            if (hostFile != null && hostFile.Exists())
            {
                hostFile.Delete();
            }
            ClusterMetrics.Destroy();
            if (rm != null)
            {
                rm.Stop();
            }
            MetricsSystem ms = DefaultMetricsSystem.Instance();

            if (ms.GetSource("ClusterMetrics") != null)
            {
                DefaultMetricsSystem.Shutdown();
            }
        }
Ejemplo n.º 15
0
 ForContainer(MetricsSystem ms, ContainerId containerId, long flushPeriodMs, long
              delayMs)
 {
     lock (typeof(ContainerMetrics))
     {
         Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Monitor.ContainerMetrics
             metrics = usageMetrics[containerId];
         if (metrics == null)
         {
             metrics = new Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Monitor.ContainerMetrics
                           (ms, containerId, flushPeriodMs, delayMs).Tag(RecordInfo, containerId);
             // Register with the MetricsSystems
             if (ms != null)
             {
                 metrics = ms.Register(SourceName(containerId), "Metrics for container: " + containerId
                                       , metrics);
             }
             usageMetrics[containerId] = metrics;
         }
         return(metrics);
     }
 }
Ejemplo n.º 16
0
 ForQueue(MetricsSystem ms, string queueName, Queue parent, bool enableUserMetrics
          , Configuration conf)
 {
     lock (typeof(QueueMetrics))
     {
         Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.QueueMetrics metrics = queueMetrics
                                                                                        [queueName];
         if (metrics == null)
         {
             metrics = new Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.QueueMetrics
                           (ms, queueName, parent, enableUserMetrics, conf).Tag(QueueInfo, queueName);
             // Register with the MetricsSystems
             if (ms != null)
             {
                 metrics = ms.Register(SourceName(queueName).ToString(), "Metrics for queue: " + queueName
                                       , metrics);
             }
             queueMetrics[queueName] = metrics;
         }
         return(metrics);
     }
 }
Ejemplo n.º 17
0
 internal ContainerMetrics(MetricsSystem ms, ContainerId containerId, long flushPeriodMs
                           , long delayMs)
 {
     // Use a multiplier of 1000 to avoid losing too much precision when
     // converting to integers
     // This tracks overall CPU percentage of the machine in terms of percentage
     // of 1 core similar to top
     // Thus if you use 2 cores completely out of 4 available cores this value
     // will be 200
     // Metrics publishing status
     // true if period elapsed
     // true if container finished
     // unregister
     // lazily initialized
     // Create a timer to unregister container metrics,
     // whose associated thread run as a daemon.
     this.recordInfo        = Interns.Info(SourceName(containerId), RecordInfo.Description());
     this.registry          = new MetricsRegistry(recordInfo);
     this.metricsSystem     = ms;
     this.containerId       = containerId;
     this.flushPeriodMs     = flushPeriodMs;
     this.unregisterDelayMs = delayMs < 0 ? 0 : delayMs;
     ScheduleTimerTaskIfRequired();
     this.pMemMBsStat = registry.NewStat(PmemUsageMetricName, "Physical memory stats",
                                         "Usage", "MBs", true);
     this.cpuCoreUsagePercent = registry.NewStat(PhyCpuUsageMetricName, "Physical Cpu core percent usage stats"
                                                 , "Usage", "Percents", true);
     this.milliVcoresUsed = registry.NewStat(VcoreUsageMetricName, "1000 times Vcore usage"
                                             , "Usage", "MilliVcores", true);
     this.pMemLimitMbs = registry.NewGauge(PmemLimitMetricName, "Physical memory limit in MBs"
                                           , 0);
     this.vMemLimitMbs = registry.NewGauge(VmemLimitMetricName, "Virtual memory limit in MBs"
                                           , 0);
     this.cpuVcoreLimit = registry.NewGauge(VcoreLimitMetricName, "CPU limit in number of vcores"
                                            , 0);
 }
Ejemplo n.º 18
0
 public virtual TestFileSink.MyMetrics2 RegisterWith(MetricsSystem ms)
 {
     return(ms.Register("m2", null, this));
 }
Ejemplo n.º 19
0
 public static MRAppMetrics Create(MetricsSystem ms)
 {
     JvmMetrics.InitSingleton("MRAppMaster", null);
     return(ms.Register(new MRAppMetrics()));
 }
Ejemplo n.º 20
0
 public static JvmMetrics Create(string processName, string sessionId, MetricsSystem
                                 ms)
 {
     return(ms.Register(JvmMetricsInfo.JvmMetrics.ToString(), JvmMetricsInfo.JvmMetrics
                        .Description(), new JvmMetrics(processName, sessionId)));
 }
Ejemplo n.º 21
0
		public static MetricsSystem SetInstance(MetricsSystem ms)
		{
			return DefaultMetricsSystem.Instance.SetImpl(ms);
		}
Ejemplo n.º 22
0
		internal MetricsSystem SetImpl(MetricsSystem ms)
		{
			return DefaultMetricsSystem.impl.GetAndSet(ms);
		}
Ejemplo n.º 23
0
        public static MetricsSource QueueSource(MetricsSystem ms, string queue)
        {
            MetricsSource s = ms.GetSource(QueueMetrics.SourceName(queue).ToString());

            return(s);
        }
Ejemplo n.º 24
0
 public virtual void SetUp()
 {
     ms = new MetricsSystemImpl();
     QueueMetrics.ClearQueueMetrics();
 }
Ejemplo n.º 25
0
 internal static NodeManagerMetrics Create(MetricsSystem ms)
 {
     JvmMetrics.Create("NodeManager", null, ms);
     return(ms.Register(new NodeManagerMetrics()));
 }
Ejemplo n.º 26
0
		internal ShuffleHandler(MetricsSystem ms)
			: base("httpshuffle")
		{
			metrics = ms.Register(new ShuffleHandler.ShuffleMetrics());
		}
Ejemplo n.º 27
0
 internal FSQueueMetrics(MetricsSystem ms, string queueName, Queue parent, bool enableUserMetrics
                         , Configuration conf)
     : base(ms, queueName, parent, enableUserMetrics, conf)
 {
 }