コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void metricsRegisteredAfterStartShouldBeIncluded() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MetricsRegisteredAfterStartShouldBeIncluded()
        {
            MetricRegistry registry = new MetricRegistry();
            DynamicAddressPrometheusOutput dynamicOutput = new DynamicAddressPrometheusOutput("localhost", registry, mock(typeof(Log)));

            System.Action <long> callback = l =>
            {
                SortedDictionary <string, Gauge> gauges = new SortedDictionary <string, Gauge>();
                gauges.put("my.event", () => l);
                dynamicOutput.Report(gauges, emptySortedMap(), emptySortedMap(), emptySortedMap(), emptySortedMap());
            };

            registry.register("my.metric", ( Gauge )() => 10);

            dynamicOutput.Init();
            dynamicOutput.Start();

            callback(20);

            string serverAddress = dynamicOutput.ServerAddress;
            string response      = GetResponse(serverAddress);

            assertTrue(response.Contains("my_metric 10.0"));
            assertTrue(response.Contains("my_event 20.0"));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void eventsShouldBeRedirectedToGauges() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void EventsShouldBeRedirectedToGauges()
        {
            MetricRegistry registry = new MetricRegistry();
            DynamicAddressPrometheusOutput dynamicOutput = new DynamicAddressPrometheusOutput("localhost", registry, mock(typeof(Log)));

            System.Action <long> callback = l =>
            {
                SortedDictionary <string, Gauge> gauges = new SortedDictionary <string, Gauge>();
                gauges.put("my.event", () => l);
                dynamicOutput.Report(gauges, emptySortedMap(), emptySortedMap(), emptySortedMap(), emptySortedMap());
            };

            callback(10);

            dynamicOutput.Init();
            dynamicOutput.Start();

            string serverAddress = dynamicOutput.ServerAddress;

            assertTrue(GetResponse(serverAddress).Contains("my_event 10.0"));
            assertTrue(GetResponse(serverAddress).Contains("my_event 10.0"));

            callback(20);
            assertTrue(GetResponse(serverAddress).Contains("my_event 20.0"));
            assertTrue(GetResponse(serverAddress).Contains("my_event 20.0"));
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var db1Metrics = new MetricRegistry();
            var reporter   = ConsoleReporter.ForRegistry(db1Metrics).build();
            var meter      = db1Metrics.Meter("testMeter");
            var randomHist = db1Metrics.Histogram("testHist");
            //var machineMetrics = MachineMetrics.Create(MachineMetricsCategory.All);
            //db1Metrics.Register("MachineMetrics", machineMetrics);

            //reporter.Start(1, TimeUnit.Seconds);
            CsvReporter creporter = CsvReporter.forRegistry(db1Metrics).build("c:\\merchlog");
            //creporter.Start(1, TimeUnit.Seconds);

            Graphite         sender    = new Graphite("ttolley-lap3", 2003);
            GraphiteReporter greporter = GraphiteReporter.ForRegistry(db1Metrics).Build(sender);

            greporter.Start(10, TimeUnit.Seconds);



            //var docsTimedCounterPerSec = db1Metrics.TimedCounter("db1", "docs new indexed/sec", "new Indexed Documents");
            int i = 0;

            db1Metrics.Gauge <int>("testGauge", () => i);
            Random r       = new Random();
            var    counter = db1Metrics.Counter("testCounter");

            for (; i < 10000; i++)
            {
                meter.Mark();
                counter.Increment(i);
                randomHist.Update(r.Next(101));
                Thread.Sleep(100);
            }
            Console.WriteLine("Done counting");
            for (i = 0; i < 10; i++)
            {
                Thread.Sleep(60000);
            }


            //Console.WriteLine(docsTimedCounterPerSec.CurrentValue);

            /*var RequestsPerSecondHistogram = db1Metrics.Histogram("db1.Request Per Second Histogram");
             * for (int i = 0; i < 100; i++)
             * {
             *  RequestsPerSecondCounter.Mark();
             *  RequestsPerSecondHistogram.Update((long)RequestsPerSecondCounter.CurrentValue);
             *  Thread.Sleep(10);
             * }
             * StringBuilder sb = new StringBuilder();
             * double[] res;
             * var perc = RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);
             * res = perc;
             * RequestsPerSecondHistogram.LogJson(sb,perc);
             * Console.WriteLine(sb);
             * Console.WriteLine(RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999));
             * // RequestsPerSecondHistogram.Update((long)documentDatabase.WorkContext.MetricsCounters.RequestsPerSecondCounter.CurrentValue); //??
             */
        }
コード例 #4
0
ファイル: Tryout.cs プロジェクト: thattolleyguy/metrics-net
        static void Main(string[] args)
        {
            var db1Metrics = new MetricRegistry();
            var reporter = ConsoleReporter.ForRegistry(db1Metrics).build();
            var meter = db1Metrics.Meter("testMeter");
            var randomHist = db1Metrics.Histogram("testHist");
            //var machineMetrics = MachineMetrics.Create(MachineMetricsCategory.All);
            //db1Metrics.Register("MachineMetrics", machineMetrics);

            //reporter.Start(1, TimeUnit.Seconds);
            CsvReporter creporter = CsvReporter.forRegistry(db1Metrics).build("c:\\merchlog");
            //creporter.Start(1, TimeUnit.Seconds);

            Graphite sender = new Graphite("ttolley-lap3", 2003);
            GraphiteReporter greporter = GraphiteReporter.ForRegistry(db1Metrics).Build(sender);
            greporter.Start(10, TimeUnit.Seconds);




            //var docsTimedCounterPerSec = db1Metrics.TimedCounter("db1", "docs new indexed/sec", "new Indexed Documents");
            int i = 0;
            db1Metrics.Gauge<int>("testGauge", () => i);
            Random r = new Random();
            var counter = db1Metrics.Counter("testCounter");
            for (; i < 10000; i++)
            {
                meter.Mark();
                counter.Increment(i);
                randomHist.Update(r.Next(101));
                Thread.Sleep(100);

            }
            Console.WriteLine("Done counting");
            for(i=0;i<10;i++)
            {
                Thread.Sleep(60000);
            }

            
            //Console.WriteLine(docsTimedCounterPerSec.CurrentValue);

            /*var RequestsPerSecondHistogram = db1Metrics.Histogram("db1.Request Per Second Histogram");
            for (int i = 0; i < 100; i++)
            {
                RequestsPerSecondCounter.Mark();
                RequestsPerSecondHistogram.Update((long)RequestsPerSecondCounter.CurrentValue);
                Thread.Sleep(10);
            }
            StringBuilder sb = new StringBuilder();
            double[] res;
            var perc = RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);
            res = perc;
            RequestsPerSecondHistogram.LogJson(sb,perc);
            Console.WriteLine(sb);
            Console.WriteLine(RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999));
           // RequestsPerSecondHistogram.Update((long)documentDatabase.WorkContext.MetricsCounters.RequestsPerSecondCounter.CurrentValue); //??
           */
        }
コード例 #5
0
 internal RotatableCsvReporter(MetricRegistry registry, Locale locale, TimeUnit rateUnit, TimeUnit durationUnit, Clock clock, File directory, System.Func <File, RotatingFileOutputStreamSupplier.RotationListener, RotatingFileOutputStreamSupplier> fileSupplierStreamCreator) : base(registry, "csv-reporter", MetricFilter.ALL, rateUnit, durationUnit)
 {
     this._locale    = locale;
     this._clock     = clock;
     this._directory = directory;
     this._fileSupplierStreamCreator = fileSupplierStreamCreator;
     this._writers = new ConcurrentDictionary <File, CsvRotatableWriter>();
 }
コード例 #6
0
 internal Builder(MetricRegistry registry)
 {
     this.Registry     = registry;
     this.Locale       = Locale.Default;
     this.RateUnit     = TimeUnit.SECONDS;
     this.DurationUnit = TimeUnit.MILLISECONDS;
     this.Clock        = Clock.defaultClock();
 }
コード例 #7
0
 public Builder(MetricRegistry registry)
 {
     this.registry     = registry;
     this.rateUnit     = TimeUnit.Seconds;
     this.durationUnit = TimeUnit.Milliseconds;
     this.clock        = Clock.DefaultClock;
     this.filter       = MetricFilters.ALL;
 }
コード例 #8
0
 public GraphiteOutput(HostnamePort hostnamePort, long period, MetricRegistry registry, Log logger, string prefix)
 {
     this._hostnamePort = hostnamePort;
     this._period       = period;
     this._registry     = registry;
     this._logger       = logger;
     this._prefix       = prefix;
 }
コード例 #9
0
 internal PrometheusOutput(HostnamePort hostnamePort, MetricRegistry registry, Log logger, ConnectorPortRegister portRegister)
 {
     this._hostnamePort  = hostnamePort;
     this._registry      = registry;
     this._logger        = logger;
     this._portRegister  = portRegister;
     this._eventRegistry = new MetricRegistry();
 }
コード例 #10
0
ファイル: GaugeTests.cs プロジェクト: thattolleyguy/nmetrics
 public static void Can_use_gauge_metric()
 {
     var queue = new Queue<int>();
     var metrics = new MetricRegistry();
     var gauge = metrics.Gauge("GaugeTests", () => queue.Count);
     queue.Enqueue(5);
     Assert.AreEqual(1, gauge.Value);
 }
コード例 #11
0
        public void Can_inc()
        {
            MetricRegistry _metrics = new MetricRegistry();
            var counter = _metrics.Counter("CounterTests.Can_count");
            Assert.IsNotNull(counter);

            counter.Increment();
            Assert.AreEqual(1, counter.Count);
        }
コード例 #12
0
 internal Builder(MetricRegistry registry)
 {
     this.registry = registry;
     this.clock = Clock.DefaultClock;
     this.prefix = null;
     this.rateUnit = TimeUnit.Seconds;
     this.durationUnit = TimeUnit.Milliseconds;
     this.filter = MetricFilters.ALL;
 }
コード例 #13
0
 internal Builder(MetricRegistry registry)
 {
     this.registry = registry;
     this.output = Console.Out;
     this.clock = Clock.DefaultClock;
     this.rateUnit = TimeUnit.Seconds;
     this.durationUnit = TimeUnit.Milliseconds;
     this.filter = MetricFilters.ALL;
 }
コード例 #14
0
        public void Can_dec_multiple()
        {
            MetricRegistry _metrics = new MetricRegistry();
            var counter = _metrics.Counter("CounterTests.Can_count");
            Assert.IsNotNull(counter);

            counter.Decrement(8);
            Assert.AreEqual(-8, counter.Count);
        }
コード例 #15
0
 internal Builder(MetricRegistry registry)
 {
     this.registry     = registry;
     this.output       = Console.Out;
     this.clock        = Clock.DefaultClock;
     this.rateUnit     = TimeUnit.Seconds;
     this.durationUnit = TimeUnit.Milliseconds;
     this.filter       = MetricFilters.ALL;
 }
コード例 #16
0
 internal CsvOutput(Config config, MetricRegistry registry, Log logger, KernelContext kernelContext, FileSystemAbstraction fileSystem, JobScheduler scheduler)
 {
     this._config        = config;
     this._registry      = registry;
     this._logger        = logger;
     this._kernelContext = kernelContext;
     this._fileSystem    = fileSystem;
     this._scheduler     = scheduler;
 }
コード例 #17
0
        public static void Can_use_gauge_metric()
        {
            var queue   = new Queue <int>();
            var metrics = new MetricRegistry();
            var gauge   = metrics.Gauge("GaugeTests", () => queue.Count);

            queue.Enqueue(5);
            Assert.AreEqual(1, gauge.Value);
        }
コード例 #18
0
ファイル: KMSWebApp.cs プロジェクト: orf53975/hadoop.net
 public virtual void ContextDestroyed(ServletContextEvent sce)
 {
     kmsAudit.Shutdown();
     kmsAcls.StopReloader();
     jmxReporter.Stop();
     jmxReporter.Close();
     metricRegistry = null;
     Log.Info("KMS Stopped");
 }
コード例 #19
0
 public Neo4jMetricsBuilder(MetricRegistry registry, EventReporter reporter, Config config, LogService logService, KernelContext kernelContext, Dependencies dependencies, LifeSupport life)
 {
     this._registry      = registry;
     this._reporter      = reporter;
     this._config        = config;
     this._logService    = logService;
     this._kernelContext = kernelContext;
     this._dependencies  = dependencies;
     this._life          = life;
 }
コード例 #20
0
 public override IInterceptor CreateInterceptor(IProxyRequest request)
 {
     if (timer == null)
     {
         MetricName     metricName = Utils.BuildName(request, Name, Absolute);
         MetricRegistry registry   = request.Context.Kernel.Get <MetricRegistry>();
         timer = registry.Timer(metricName);
     }
     return(new TimingInterceptor(timer));
 }
コード例 #21
0
        public void Can_inc_multiple()
        {
            MetricRegistry _metrics = new MetricRegistry();
            var            counter  = _metrics.Counter("CounterTests.Can_count");

            Assert.IsNotNull(counter);

            counter.Increment(100);
            Assert.AreEqual(100, counter.Count);
        }
コード例 #22
0
 public CsvReporter(MetricRegistry registry,
                    string directory,
                    TimeUnit rateUnit,
                    TimeUnit durationUnit,
                    Clock clock,
                    MetricFilter filter) : base(registry, "csv-reporter", filter, rateUnit, durationUnit)
 {
     this.directory = directory;
     this.clock     = clock;
 }
コード例 #23
0
        public void Can_dec()
        {
            MetricRegistry _metrics = new MetricRegistry();
            var            counter  = _metrics.Counter("CounterTests.Can_count");

            Assert.IsNotNull(counter);

            counter.Decrement();
            Assert.AreEqual(-1, counter.Count);
        }
コード例 #24
0
 private ConsoleReporter(MetricRegistry registry,
                         TextWriter output,
                         Clock clock,
                         TimeUnit rateUnit,
                         TimeUnit durationUnit,
                         MetricFilter filter) :
     base(registry, "console-reporter", filter, rateUnit, durationUnit)
 {
     this.output = output;
     this.clock  = clock;
 }
コード例 #25
0
        public CsvReporter(MetricRegistry registry,
                            string directory,
                            TimeUnit rateUnit,
                            TimeUnit durationUnit,
                            Clock clock,
                            MetricFilter filter) : base(registry, "csv-reporter", filter, rateUnit, durationUnit)
        {

            this.directory = directory;
            this.clock = clock;
        }
コード例 #26
0
 public override IInterceptor CreateInterceptor(IProxyRequest request)
 {
     if (interceptor == null)
     {
         MetricName     metricName = Utils.BuildName(request, Name, Absolute);
         MetricRegistry registry   = request.Context.Kernel.Get <MetricRegistry>();
         Counter        counter    = registry.Counter(metricName);
         interceptor = new CountingInterceptor(counter, Monotonic);
     }
     return(interceptor);
 }
コード例 #27
0
 public LogRotationMetrics(EventReporter reporter, MetricRegistry registry, Monitors monitors, System.Func <LogRotationMonitor> logRotationMonitorSupplier)
 {
     this._registry = registry;
     this._monitors = monitors;
     this._logRotationMonitorSupplier = logRotationMonitorSupplier;
     this._listener = durationMillis =>
     {
         SortedDictionary <string, Gauge> gauges = new SortedDictionary <string, Gauge>();
         gauges.put(LogRotationDuration, () => durationMillis);
         reporter.Report(gauges, emptySortedMap(), emptySortedMap(), emptySortedMap(), emptySortedMap());
     };
 }
コード例 #28
0
 public CheckPointingMetrics(EventReporter reporter, MetricRegistry registry, Monitors monitors, System.Func <CheckPointerMonitor> checkPointerMonitorSupplier)
 {
     this._registry = registry;
     this._monitors = monitors;
     this._checkPointerMonitorSupplier = checkPointerMonitorSupplier;
     this._listener = durationMillis =>
     {
         SortedDictionary <string, Gauge> gauges = new SortedDictionary <string, Gauge>();
         gauges.put(CheckPointDuration, () => durationMillis);
         reporter.Report(gauges, emptySortedMap(), emptySortedMap(), emptySortedMap(), emptySortedMap());
     };
 }
コード例 #29
0
 private GraphiteReporter(MetricRegistry registry,
                          GraphiteSender graphite,
                          Clock clock,
                          String prefix,
                          TimeUnit rateUnit,
                          TimeUnit durationUnit,
                          MetricFilter filter) : base(registry, "graphite-reporter", filter, rateUnit, durationUnit)
 {
     this.graphite = graphite;
     this.clock    = clock;
     this.prefix   = MetricName.build(prefix);
 }
コード例 #30
0
 /// <summary>
 /// Creates a new <see cref="ScheduledReporter"/> instance
 /// </summary>
 /// <param name="registry">the <see cref="MetricRegistry"/> containing the metrics this reporter will report</param>
 /// <param name="name">the reporter's name</param>
 /// <param name="filter">the filter for which metrics to report</param>
 /// <param name="rateUnit">a unit of time</param>
 /// <param name="durationUnit">a unit of time</param>
 protected ScheduledReporter(MetricRegistry registry,
                             string name,
                             MetricFilter filter,
                             TimeUnit rateUnit,
                             TimeUnit durationUnit)
 {
     this.registry = registry;
     this.filter = filter;
     this.rateFactor = rateUnit.ToSeconds(1);
     this.rateUnit = calculateRateUnit(rateUnit);
     this.durationFactor = 1.0 / durationUnit.ToNanos(1);
     this.durationUnit = durationUnit.ToString().ToLowerInvariant();
 }
コード例 #31
0
 /// <summary>
 /// Creates a new <see cref="ScheduledReporter"/> instance
 /// </summary>
 /// <param name="registry">the <see cref="MetricRegistry"/> containing the metrics this reporter will report</param>
 /// <param name="name">the reporter's name</param>
 /// <param name="filter">the filter for which metrics to report</param>
 /// <param name="rateUnit">a unit of time</param>
 /// <param name="durationUnit">a unit of time</param>
 protected ScheduledReporter(MetricRegistry registry,
                             string name,
                             MetricFilter filter,
                             TimeUnit rateUnit,
                             TimeUnit durationUnit)
 {
     this.registry       = registry;
     this.filter         = filter;
     this.rateFactor     = rateUnit.ToSeconds(1);
     this.rateUnit       = calculateRateUnit(rateUnit);
     this.durationFactor = 1.0 / durationUnit.ToNanos(1);
     this.durationUnit   = durationUnit.ToString().ToLowerInvariant();
 }
コード例 #32
0
        public ServerMetrics(MetricRegistry registry, LogService logService, DependencySatisfier satisfier)
        {
            Log userLog = logService.GetUserLog(this.GetType());

            this._registry         = registry;
            this._serverThreadView = new ServerThreadViewAnonymousInnerClass(this, userLog);
            satisfier.SatisfyDependency((ServerThreadViewSetter)_serverThreadView =>
            {
                Debug.Assert(ServerMetrics.this._serverThreadView != null);
                ServerMetrics.this._serverThreadView = _serverThreadView;
                userLog.Info("Server thread metrics have been registered successfully");
            });
        }
コード例 #33
0
        public override IInterceptor CreateInterceptor(IProxyRequest request)
        {
            if (meterInterceptor == null)
            {
                MetricName     metricName = Utils.BuildName(request, Name, Absolute);
                MetricRegistry registry   = request.Context.Kernel.Get <MetricRegistry>();
                Meter          meter      = registry.Meter(metricName);
                Type           t          = typeof(Exception);
                if (ExceptionType != null && ExceptionType.IsSubclassOf(t))
                {
                    t = ExceptionType;
                }
                meterInterceptor = new ExceptionMeteringInterceptor(meter, t);
            }


            return(meterInterceptor);
        }
コード例 #34
0
        public static void Main(string[] args)
        {
            Console.WriteLine(typeof(Exception).IsAssignableFrom(typeof(ArgumentNullException)));
            Console.WriteLine(typeof(ArgumentNullException).IsAssignableFrom(typeof(Exception)));


            IKernel        kernel   = new StandardKernel();
            MetricRegistry registry = new MetricRegistry();

            kernel.Bind <MetricRegistry>().ToConstant <MetricRegistry>(registry);


            Tryout          t        = kernel.Get <Tryout>();
            ConsoleReporter reporter = ConsoleReporter.ForRegistry(registry).build();

            reporter.Start(1, TimeUnit.Seconds);

            Graphite         sender    = new Graphite("ttolley-lap3", 2003);
            GraphiteReporter greporter = GraphiteReporter.ForRegistry(registry).Build(sender);

            greporter.Start(10, TimeUnit.Seconds);

            int    i = 0;
            Random r = new Random();

            for (; i < 10000; i++)
            {
                try {
                    t.Test(r.Next(101));
                }
                catch
                {
                    // Do nothing
                }
            }

            Console.WriteLine("Done counting");
            for (i = 0; i < 10; i++)
            {
                Thread.Sleep(60000);
            }
        }
コード例 #35
0
ファイル: Tryout.cs プロジェクト: thattolleyguy/metrics-net
        public static void Main(string[] args)
        {
            Console.WriteLine(typeof(Exception).IsAssignableFrom(typeof(ArgumentNullException)));
            Console.WriteLine(typeof(ArgumentNullException).IsAssignableFrom(typeof(Exception)));


            IKernel kernel = new StandardKernel();
            MetricRegistry registry = new MetricRegistry();
            kernel.Bind<MetricRegistry>().ToConstant<MetricRegistry>(registry);


            Tryout t = kernel.Get<Tryout>();
            ConsoleReporter reporter = ConsoleReporter.ForRegistry(registry).build();
            reporter.Start(1, TimeUnit.Seconds);

            Graphite sender = new Graphite("ttolley-lap3", 2003);
            GraphiteReporter greporter = GraphiteReporter.ForRegistry(registry).Build(sender);
            greporter.Start(10, TimeUnit.Seconds);

            int i = 0;
            Random r = new Random();
            for (; i < 10000; i++)
            {
                try {
                    t.Test(r.Next(101));
                }
                catch
                {
                    // Do nothing
                }

            }

            Console.WriteLine("Done counting");
            for (i = 0; i < 10; i++)
            {
                Thread.Sleep(60000);
            }


        }
コード例 #36
0
        private ConsoleReporter(MetricRegistry registry,
                                TextWriter output,
                                Clock clock,
                                TimeUnit rateUnit,
                                TimeUnit durationUnit,
                                MetricFilter filter) :
            base(registry, "console-reporter", filter, rateUnit, durationUnit)
        {
            this.output = output;
            this.clock = clock;

        }
コード例 #37
0
 internal DynamicAddressPrometheusOutput(string host, MetricRegistry registry, Log logger) : base(new HostnamePort(host), registry, logger, mock(typeof(ConnectorPortRegister)))
 {
 }
コード例 #38
0
 public void SetUp()
 {
     registry = new MetricRegistry();
 }
コード例 #39
0
 public void SetUp()
 {
     registry = new MetricRegistry();
 }
コード例 #40
0
 /// <summary>
 /// Creates a new <see cref="Builder"/> for <see cref="ConsoleReporter"/>
 /// </summary>
 /// <param name="registry">the registry to report</param>
 /// <returns>a new <see cref="Builder"/> for <see cref="ConsoleReporter"/></returns>
 public static Builder ForRegistry(MetricRegistry registry)
 {
     return(new Builder(registry));
 }
コード例 #41
0
     /**
 * Returns a new {@link Builder} for {@link CsvReporter}.
 *
 * @param registry the registry to report
 * @return a {@link Builder} instance for a {@link CsvReporter}
 */
     public static Builder forRegistry(MetricRegistry registry)
     {
         return new Builder(registry);
     }
コード例 #42
0
        private GraphiteReporter(MetricRegistry registry,
                         GraphiteSender graphite,
                         Clock clock,
                         String prefix,
                         TimeUnit rateUnit,
                         TimeUnit durationUnit,
                         MetricFilter filter) : base(registry, "graphite-reporter", filter, rateUnit, durationUnit)
        {

            this.graphite = graphite;
            this.clock = clock;
            this.prefix = MetricName.build(prefix);
        }
コード例 #43
0
ファイル: KMSWebApp.cs プロジェクト: orf53975/hadoop.net
 public virtual void ContextInitialized(ServletContextEvent sce)
 {
     try
     {
         string confDir = Runtime.GetProperty(KMSConfiguration.KmsConfigDir);
         if (confDir == null)
         {
             throw new RuntimeException("System property '" + KMSConfiguration.KmsConfigDir +
                                        "' not defined");
         }
         kmsConf = KMSConfiguration.GetKMSConf();
         InitLogging(confDir);
         Log.Info("-------------------------------------------------------------");
         Log.Info("  Java runtime version : {}", Runtime.GetProperty("java.runtime.version"
                                                                     ));
         Log.Info("  KMS Hadoop Version: " + VersionInfo.GetVersion());
         Log.Info("-------------------------------------------------------------");
         kmsAcls = new KMSACLs();
         kmsAcls.StartReloader();
         metricRegistry = new MetricRegistry();
         jmxReporter    = JmxReporter.ForRegistry(metricRegistry).Build();
         jmxReporter.Start();
         generateEEKCallsMeter  = metricRegistry.Register(GenerateEekMeter, new Meter());
         decryptEEKCallsMeter   = metricRegistry.Register(DecryptEekMeter, new Meter());
         adminCallsMeter        = metricRegistry.Register(AdminCallsMeter, new Meter());
         keyCallsMeter          = metricRegistry.Register(KeyCallsMeter, new Meter());
         invalidCallsMeter      = metricRegistry.Register(InvalidCallsMeter, new Meter());
         unauthorizedCallsMeter = metricRegistry.Register(UnauthorizedCallsMeter, new Meter
                                                              ());
         unauthenticatedCallsMeter = metricRegistry.Register(UnauthenticatedCallsMeter, new
                                                             Meter());
         kmsAudit = new KMSAudit(kmsConf.GetLong(KMSConfiguration.KmsAuditAggregationWindow
                                                 , KMSConfiguration.KmsAuditAggregationWindowDefault));
         // this is required for the the JMXJsonServlet to work properly.
         // the JMXJsonServlet is behind the authentication filter,
         // thus the '*' ACL.
         sce.GetServletContext().SetAttribute(HttpServer2.ConfContextAttribute, kmsConf);
         sce.GetServletContext().SetAttribute(HttpServer2.AdminsAcl, new AccessControlList
                                                  (AccessControlList.WildcardAclValue));
         // intializing the KeyProvider
         string providerString = kmsConf.Get(KMSConfiguration.KeyProviderUri);
         if (providerString == null)
         {
             throw new InvalidOperationException("No KeyProvider has been defined");
         }
         KeyProvider keyProvider = KeyProviderFactory.Get(new URI(providerString), kmsConf
                                                          );
         if (kmsConf.GetBoolean(KMSConfiguration.KeyCacheEnable, KMSConfiguration.KeyCacheEnableDefault
                                ))
         {
             long keyTimeOutMillis = kmsConf.GetLong(KMSConfiguration.KeyCacheTimeoutKey, KMSConfiguration
                                                     .KeyCacheTimeoutDefault);
             long currKeyTimeOutMillis = kmsConf.GetLong(KMSConfiguration.CurrKeyCacheTimeoutKey
                                                         , KMSConfiguration.CurrKeyCacheTimeoutDefault);
             keyProvider = new CachingKeyProvider(keyProvider, keyTimeOutMillis, currKeyTimeOutMillis
                                                  );
         }
         Log.Info("Initialized KeyProvider " + keyProvider);
         keyProviderCryptoExtension = KeyProviderCryptoExtension.CreateKeyProviderCryptoExtension
                                          (keyProvider);
         keyProviderCryptoExtension = new EagerKeyGeneratorKeyProviderCryptoExtension(kmsConf
                                                                                      , keyProviderCryptoExtension);
         if (kmsConf.GetBoolean(KMSConfiguration.KeyAuthorizationEnable, KMSConfiguration.
                                KeyAuthorizationEnableDefault))
         {
             keyProviderCryptoExtension = new KeyAuthorizationKeyProvider(keyProviderCryptoExtension
                                                                          , kmsAcls);
         }
         Log.Info("Initialized KeyProviderCryptoExtension " + keyProviderCryptoExtension);
         int defaultBitlength = kmsConf.GetInt(KeyProvider.DefaultBitlengthName, KeyProvider
                                               .DefaultBitlength);
         Log.Info("Default key bitlength is {}", defaultBitlength);
         Log.Info("KMS Started");
     }
     catch (Exception ex)
     {
         System.Console.Out.WriteLine();
         System.Console.Out.WriteLine("ERROR: Hadoop KMS could not be started");
         System.Console.Out.WriteLine();
         System.Console.Out.WriteLine("REASON: " + ex.ToString());
         System.Console.Out.WriteLine();
         System.Console.Out.WriteLine("Stacktrace:");
         System.Console.Out.WriteLine("---------------------------------------------------"
                                      );
         Runtime.PrintStackTrace(ex, System.Console.Out);
         System.Console.Out.WriteLine("---------------------------------------------------"
                                      );
         System.Console.Out.WriteLine();
         System.Environment.Exit(1);
     }
 }