Java Code Examples for com.codahale.metrics.jmx.JmxReporter#start()

The following examples show how to use com.codahale.metrics.jmx.JmxReporter#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodahaleMetricsProvider.java    From cxf with Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example 2
Source File: DumpDataTool.java    From ambry with Apache License 2.0 6 votes vote down vote up
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();
    }
  }
}
 
Example 3
Source File: DumpLogTool.java    From ambry with Apache License 2.0 6 votes vote down vote up
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();
    }
  }
}
 
Example 4
Source File: DrillMetrics.java    From Bats with Apache License 2.0 5 votes vote down vote up
private static JmxReporter getJmxReporter() {
  if (METRICS_JMX_OUTPUT_ENABLED) {
    JmxReporter reporter = JmxReporter.forRegistry(REGISTRY).build();
    reporter.start();

    return reporter;
  }
  return null;
}
 
Example 5
Source File: InjectionModule.java    From ja-micro with Apache License 2.0 5 votes vote down vote up
public InjectionModule(ServiceProperties serviceProperties) {
    this.serviceProperties = serviceProperties;
    metricRegistry = new MetricRegistry();
    JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).build();
    reporter.start();
    httpClient = createHttpClient();
}
 
Example 6
Source File: JMXMetrics.java    From replicator with Apache License 2.0 5 votes vote down vote up
@Override
protected JmxReporter getReporter(Map<String, Object> configuration, MetricRegistry registry) {
    JmxReporter reporter = JmxReporter.forRegistry(registry).build();

    reporter.start();

    return reporter;
}
 
Example 7
Source File: ApplicationState.java    From xio with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 8
Source File: ServingServer.java    From FATE-Serving with Apache License 2.0 4 votes vote down vote up
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");
        }
    });
}
 
Example 9
Source File: MetricsConfiguration.java    From JuniperBot with GNU General Public License v3.0 4 votes vote down vote up
@Bean(destroyMethod = "stop")
public JmxReporter jmxReporter() {
    JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).build();
    reporter.start();
    return reporter;
}
 
Example 10
Source File: SingularityS3DownloaderMetrics.java    From Singularity with Apache License 2.0 4 votes vote down vote up
private void startJmxReporter() {
  JmxReporter reporter = JmxReporter.forRegistry(registry).build();
  reporter.start();
}
 
Example 11
Source File: SingularityS3UploaderMetrics.java    From Singularity with Apache License 2.0 4 votes vote down vote up
private void startJmxReporter() {
  JmxReporter reporter = JmxReporter.forRegistry(registry).build();
  reporter.start();
}