类com.codahale.metrics.jmx.JmxReporter源码实例Demo

下面列出了怎么用com.codahale.metrics.jmx.JmxReporter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: datacollector   文件: WebServerModule.java
@Provides(type = Type.SET)
ContextConfigurator provideJMX(final MetricRegistry metrics) {
  return new ContextConfigurator() {
    private JmxReporter reporter;
    @Override
    public void init(ServletContextHandler context) {
      context.setAttribute("com.codahale.metrics.servlets.MetricsServlet.registry", metrics);
      ServletHolder servlet = new ServletHolder(new JMXJsonServlet());
      context.addServlet(servlet, "/rest/v1/system/jmx");
    }

    @Override
    public void start() {
      reporter = JmxReporter.forRegistry(metrics).build();
      reporter.start();
    }

    @Override
    public void stop() {
      if(reporter != null) {
        reporter.stop();
        reporter.close();
      }
    }
  };
}
 
源代码2 项目: cxf   文件: CodahaleMetricsProvider.java
public static void setupJMXReporter(Bus b, MetricRegistry reg) {
    InstrumentationManager im = b.getExtension(InstrumentationManager.class);
    if (im != null) {
        JmxReporter reporter = JmxReporter.forRegistry(reg).registerWith(im.getMBeanServer())
            .inDomain("org.apache.cxf")
            .createsObjectNamesWith(new ObjectNameFactory() {
                public ObjectName createName(String type, String domain, String name) {
                    try {
                        return new ObjectName(name);
                    } catch (MalformedObjectNameException e) {
                        throw new RuntimeException(e);
                    }
                }
            })
            .build();
        reporter.start();
    }
}
 
源代码3 项目: ambry   文件: DumpDataTool.java
public static void main(String args[]) throws Exception {
  VerifiableProperties verifiableProperties = ToolUtils.getVerifiableProperties(args);
  MetricRegistry registry = new MetricRegistry();
  StoreToolsMetrics metrics = new StoreToolsMetrics(registry);
  JmxReporter reporter = null;
  try {
    reporter = JmxReporter.forRegistry(registry).build();
    reporter.start();
    DumpDataTool dumpDataTool = new DumpDataTool(verifiableProperties, metrics);
    dumpDataTool.doOperation();
  } finally {
    if (reporter != null) {
      reporter.stop();
    }
  }
}
 
源代码4 项目: ambry   文件: DumpLogTool.java
public static void main(String args[]) throws Exception {
  VerifiableProperties verifiableProperties = ToolUtils.getVerifiableProperties(args);
  MetricRegistry registry = new MetricRegistry();
  StoreToolsMetrics metrics = new StoreToolsMetrics(registry);
  JmxReporter reporter = null;
  try {
    reporter = JmxReporter.forRegistry(registry).build();
    reporter.start();
    DumpLogTool dumpLogTool = new DumpLogTool(verifiableProperties, metrics);
    dumpLogTool.doOperation();
  } finally {
    if (reporter != null) {
      reporter.stop();
    }
  }
}
 
源代码5 项目: airsonic-advanced   文件: MetricsManager.java
private void configureMetricsActivation() {
    if (env.containsProperty("Metrics")) {
        metricsActivatedByConfiguration = Boolean.TRUE;

        // Start a Metrics JMX reporter
        reporter = JmxReporter.forRegistry(metrics)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        reporter.start();
    } else {
        metricsActivatedByConfiguration = Boolean.FALSE;
    }
}
 
源代码6 项目: Bats   文件: DrillMetrics.java
private static JmxReporter getJmxReporter() {
  if (METRICS_JMX_OUTPUT_ENABLED) {
    JmxReporter reporter = JmxReporter.forRegistry(REGISTRY).build();
    reporter.start();

    return reporter;
  }
  return null;
}
 
@PostConstruct
public void postConstruct() {
    if (!constructed.compareAndSet(false, true)) {
        return;
    }
    if (!InternalConfigurations.JMX_REPORTER_ENABLED) {
        return;
    }
    jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
    jmxReporter.start();
    log.debug("Started JMX Metrics Reporting.");
}
 
@Test
public void test_post_construct_twice() {
    final JmxReporterBootstrap jmxReporterBootstrap = new JmxReporterBootstrap(new MetricRegistry());
    jmxReporterBootstrap.postConstruct();
    final JmxReporter firstReporter = jmxReporterBootstrap.jmxReporter;
    jmxReporterBootstrap.postConstruct();
    final JmxReporter secondReporter = jmxReporterBootstrap.jmxReporter;
    assertSame(firstReporter, secondReporter);
}
 
源代码9 项目: airsonic   文件: MetricsManager.java
private void configureMetricsActivation() {
    if (configurationService.containsKey("Metrics")) {
        metricsActivatedByConfiguration = Boolean.TRUE;

        // Start a Metrics JMX reporter
        reporter = JmxReporter.forRegistry(metrics)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        reporter.start();
    } else {
        metricsActivatedByConfiguration = Boolean.FALSE;
    }
}
 
源代码10 项目: ja-micro   文件: InjectionModule.java
public InjectionModule(ServiceProperties serviceProperties) {
    this.serviceProperties = serviceProperties;
    metricRegistry = new MetricRegistry();
    JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).build();
    reporter.start();
    httpClient = createHttpClient();
}
 
源代码11 项目: replicator   文件: JMXMetrics.java
@Override
protected JmxReporter getReporter(Map<String, Object> configuration, MetricRegistry registry) {
    JmxReporter reporter = JmxReporter.forRegistry(registry).build();

    reporter.start();

    return reporter;
}
 
源代码12 项目: riposte   文件: DefaultJMXReporterFactory.java
@Override
public synchronized Reporter getReporter(MetricRegistry registry) {
    if (null == reporter) {
        reporter = JmxReporter.forRegistry(registry).build();
    }
    return reporter;
}
 
源代码13 项目: hudi   文件: JmxReporterServer.java
protected JmxReporterServer(MetricRegistry registry, String host, int port,
    MBeanServer mBeanServer) {
  String serviceUrl =
      "service:jmx:rmi://localhost:" + port + "/jndi/rmi://" + host + ":" + port + "/jmxrmi";
  try {
    JMXServiceURL url = new JMXServiceURL(serviceUrl);
    connector = JMXConnectorServerFactory
        .newJMXConnectorServer(url, null, mBeanServer);
    rmiRegistry = LocateRegistry.createRegistry(port);
    reporter = JmxReporter.forRegistry(registry).registerWith(mBeanServer).build();
  } catch (Exception e) {
    throw new HoodieException("Jmx service url created " + serviceUrl, e);
  }
}
 
源代码14 项目: brooklin   文件: JmxReporterFactory.java
/**
 * Creates a {@link JmxReporter} that generates metrics whose names
 * are decided according to the {@link BrooklinObjectNameFactory}.
 */
public static JmxReporter createJmxReporter(MetricRegistry metricRegistry) {
  Validate.notNull(metricRegistry);

  return JmxReporter.forRegistry(metricRegistry)
      .createsObjectNamesWith(OBJECT_NAME_FACTORY)
      .build();
}
 
源代码15 项目: xio   文件: ApplicationState.java
public ApplicationState(ApplicationConfig config, XioTracing tracing) {
  this.config = config;
  this.tracing = tracing;
  this.metricRegistry = new MetricRegistry();
  JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
  jmxReporter.start();
  this.channelConfiguration = config.serverChannelConfig();
  this.ipFilterConfig = new AtomicReference<>(new IpFilterConfig());
  this.http1FilterConfig = new AtomicReference<>(new Http1FilterConfig());
}
 
源代码16 项目: knox   文件: JmxMetricsReporter.java
@Override
public void start(MetricsContext metricsContext) throws MetricsReporterException {
  MetricRegistry registry = (MetricRegistry) metricsContext.getProperty(
      DefaultMetricsService.METRICS_REGISTRY);
  jmxReporter = JmxReporter.forRegistry(registry).build();
  jmxReporter.start();
}
 
源代码17 项目: flexy-pool   文件: JmxMetricReporter.java
/**
 * The JMX Reporter is activated only if the jmxEnabled property is set. If the jmxAutoStart property is enabled,
 * the JMX Reporter will start automatically.
 *
 * @param configurationProperties configuration properties
 * @param metricRegistry metric registry
 * @return {@link JmxMetricReporter}
 */
@Override
public JmxMetricReporter init(ConfigurationProperties configurationProperties, MetricRegistry metricRegistry) {
    if (configurationProperties.isJmxEnabled()) {
        jmxReporter = JmxReporter
                .forRegistry(metricRegistry)
                .inDomain(getClass().getName() + "." + configurationProperties.getUniqueName())
                .build();
    }
    if(configurationProperties.isJmxAutoStart()) {
        start();
    }
    return this;
}
 
源代码18 项目: FATE-Serving   文件: ServingServer.java
private void start(String[] args) throws Exception {
    this.initialize();
    applicationContext = SpringApplication.run(SpringConfig.class, args);
    ApplicationHolder.applicationContext = applicationContext;
    int port = Integer.parseInt(Configuration.getProperty(Dict.PROPERTY_SERVER_PORT));
    //TODO: Server custom configuration

    int processors = Runtime.getRuntime().availableProcessors();

    Integer corePoolSize = Configuration.getPropertyInt("serving.core.pool.size", processors);
    Integer maxPoolSize = Configuration.getPropertyInt("serving.max.pool.size", processors * 2);
    Integer aliveTime = Configuration.getPropertyInt("serving.pool.alive.time", 1000);
    Integer queueSize = Configuration.getPropertyInt("serving.pool.queue.size", 10);
    Executor executor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, aliveTime.longValue(), TimeUnit.MILLISECONDS,
            new SynchronousQueue(), new NamedThreadFactory("ServingServer", true));

    FateServerBuilder serverBuilder = (FateServerBuilder) ServerBuilder.forPort(port);
    serverBuilder.keepAliveTime(100,TimeUnit.MILLISECONDS);
    serverBuilder.executor(executor);
    //new ServiceOverloadProtectionHandle()
    serverBuilder.addService(ServerInterceptors.intercept(applicationContext.getBean(InferenceService.class), new ServiceExceptionHandler(), new ServiceOverloadProtectionHandle()), InferenceService.class);
    serverBuilder.addService(ServerInterceptors.intercept(applicationContext.getBean(ModelService.class), new ServiceExceptionHandler(), new ServiceOverloadProtectionHandle()), ModelService.class);
    serverBuilder.addService(ServerInterceptors.intercept(applicationContext.getBean(ProxyService.class), new ServiceExceptionHandler(), new ServiceOverloadProtectionHandle()), ProxyService.class);
    server = serverBuilder.build();
    logger.info("server started listening on port: {}, use configuration: {}", port, this.confPath);
    server.start();
    String userRegisterString = Configuration.getProperty(Dict.USE_REGISTER,"true");
    useRegister = Boolean.valueOf(userRegisterString);
    if(useRegister) {
        logger.info("serving-server is using register center");
    }
    else{
        logger.warn("serving-server not use register center");
    }
    if (useRegister) {
        ZookeeperRegistry zookeeperRegistry = applicationContext.getBean(ZookeeperRegistry.class);
        zookeeperRegistry.subProject(Dict.PROPERTY_PROXY_ADDRESS);
        zookeeperRegistry.subProject(Dict.PROPERTY_FLOW_ADDRESS);

        BaseModel.routerService = applicationContext.getBean(RouterService.class);
        FateServer.serviceSets.forEach(servie -> {
            try {
                String serviceName = servie.serviceName();
                String weightKey = serviceName + ".weight";
                HashMap properties = Configuration.getProperties();
                if (properties.get(weightKey) != null) {
                    int weight = Integer.valueOf(properties.get(weightKey).toString());
                    if (weight > 0) {
                        zookeeperRegistry.getServieWeightMap().put(weightKey, weight);
                    }
                }
            } catch (Throwable e) {
                logger.error("parse interface weight error", e);
            }

        });

        zookeeperRegistry.register(FateServer.serviceSets);

    }

    ModelService modelService = applicationContext.getBean(ModelService.class);
    modelService.restore();

    ConsoleReporter reporter = applicationContext.getBean(ConsoleReporter.class);
    reporter.start(1, TimeUnit.MINUTES);

    JmxReporter jmxReporter = applicationContext.getBean(JmxReporter.class);
    jmxReporter.start();

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            logger.info("*** shutting down gRPC server since JVM is shutting down");
            ServingServer.this.stop();
            logger.info("*** server shut down");
        }
    });
}
 
源代码19 项目: FATE-Serving   文件: SpringConfig.java
@Bean
public JmxReporter jmxReporter(MetricRegistry metrics) {
    return JmxReporter.forRegistry(metrics).build();
}
 
private void initJmxReporter(String domain) {
    jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY_INSTANCE).inDomain(domain).build();
}
 
源代码21 项目: micrometer   文件: JmxMeterRegistry.java
public JmxMeterRegistry(JmxConfig config, Clock clock, HierarchicalNameMapper nameMapper, MetricRegistry metricRegistry,
                        JmxReporter jmxReporter) {
    super(config, metricRegistry, nameMapper, clock);
    this.reporter = jmxReporter;
    this.reporter.start();
}
 
源代码22 项目: micrometer   文件: JmxMeterRegistry.java
private static JmxReporter defaultJmxReporter(JmxConfig config, MetricRegistry metricRegistry) {
    return JmxReporter.forRegistry(metricRegistry)
            .inDomain(config.domain())
            .build();
}
 
源代码23 项目: styx   文件: JmxReporterService.java
public JmxReporterService(String domain, MetricRegistry metricRegistry) {
    this.reporter = JmxReporter.forRegistry(metricRegistry)
            .inDomain(domain)
            .build();
}
 
源代码24 项目: dremio-oss   文件: JmxConfigurator.java
@Override
public void configureAndStart(String name, MetricRegistry registry, MetricFilter filter) {
  reporter = JmxReporter.forRegistry(registry).convertRatesTo(rateUnit).convertDurationsTo(durationUnit).filter(filter).build();
  reporter.start();
}
 
源代码25 项目: JuniperBot   文件: MetricsConfiguration.java
@Bean(destroyMethod = "stop")
public JmxReporter jmxReporter() {
    JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).build();
    reporter.start();
    return reporter;
}
 
源代码26 项目: enkan   文件: MetricsComponent.java
public MetricsComponent() {
    metricRegistry = new MetricRegistry();
    reporter = JmxReporter.forRegistry(metricRegistry).build();
}
 
源代码27 项目: hudi   文件: JmxReporterServer.java
public JmxReporter getReporter() {
  return reporter;
}
 
源代码28 项目: james-project   文件: DropWizardMetricFactory.java
@Inject
public DropWizardMetricFactory(MetricRegistry metricRegistry) {
    this.metricRegistry = metricRegistry;
    this.jmxReporter = JmxReporter.forRegistry(metricRegistry)
        .build();
}
 
源代码29 项目: foxtrot   文件: MetricUtil.java
private MetricUtil() {
    JmxReporter.forRegistry(metrics)
            .convertRatesTo(TimeUnit.MINUTES)
            .build()
            .start();
}
 
private void startJmxReporter() {
  JmxReporter reporter = JmxReporter.forRegistry(registry).build();
  reporter.start();
}
 
 类所在包
 类方法
 同包方法