com.codahale.metrics.jmx.JmxReporter Java Examples
The following examples show how to use
com.codahale.metrics.jmx.JmxReporter.
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: DumpLogTool.java From ambry with Apache License 2.0 | 6 votes |
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 #2
Source File: DumpDataTool.java From ambry with Apache License 2.0 | 6 votes |
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: CodahaleMetricsProvider.java From cxf with Apache License 2.0 | 6 votes |
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 #4
Source File: WebServerModule.java From datacollector with Apache License 2.0 | 6 votes |
@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(); } } }; }
Example #5
Source File: DrillMetrics.java From Bats with Apache License 2.0 | 5 votes |
private static JmxReporter getJmxReporter() { if (METRICS_JMX_OUTPUT_ENABLED) { JmxReporter reporter = JmxReporter.forRegistry(REGISTRY).build(); reporter.start(); return reporter; } return null; }
Example #6
Source File: JmxMetricReporter.java From flexy-pool with Apache License 2.0 | 5 votes |
/** * 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; }
Example #7
Source File: JmxMetricsReporter.java From knox with Apache License 2.0 | 5 votes |
@Override public void start(MetricsContext metricsContext) throws MetricsReporterException { MetricRegistry registry = (MetricRegistry) metricsContext.getProperty( DefaultMetricsService.METRICS_REGISTRY); jmxReporter = JmxReporter.forRegistry(registry).build(); jmxReporter.start(); }
Example #8
Source File: ApplicationState.java From xio with Apache License 2.0 | 5 votes |
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 #9
Source File: JmxReporterFactory.java From brooklin with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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(); }
Example #10
Source File: JmxReporterServer.java From hudi with Apache License 2.0 | 5 votes |
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); } }
Example #11
Source File: DefaultJMXReporterFactory.java From riposte with Apache License 2.0 | 5 votes |
@Override public synchronized Reporter getReporter(MetricRegistry registry) { if (null == reporter) { reporter = JmxReporter.forRegistry(registry).build(); } return reporter; }
Example #12
Source File: JMXMetrics.java From replicator with Apache License 2.0 | 5 votes |
@Override protected JmxReporter getReporter(Map<String, Object> configuration, MetricRegistry registry) { JmxReporter reporter = JmxReporter.forRegistry(registry).build(); reporter.start(); return reporter; }
Example #13
Source File: MetricsManager.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
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; } }
Example #14
Source File: JmxReporterBootstrap.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@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."); }
Example #15
Source File: InjectionModule.java From ja-micro with Apache License 2.0 | 5 votes |
public InjectionModule(ServiceProperties serviceProperties) { this.serviceProperties = serviceProperties; metricRegistry = new MetricRegistry(); JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).build(); reporter.start(); httpClient = createHttpClient(); }
Example #16
Source File: MetricsManager.java From airsonic with GNU General Public License v3.0 | 5 votes |
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; } }
Example #17
Source File: JmxReporterBootstrapTest.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@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); }
Example #18
Source File: CassandraConnectorTask.java From debezium-incubator with Apache License 2.0 | 4 votes |
private void initJmxReporter(String domain) { jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY_INSTANCE).inDomain(domain).build(); }
Example #19
Source File: RestServer.java From ambry with Apache License 2.0 | 4 votes |
/** * Creates an instance of RestServer. * @param verifiableProperties the properties that define the behavior of the RestServer and its components. * @param clusterMap the {@link ClusterMap} instance that needs to be used. * @param notificationSystem the {@link NotificationSystem} instance that needs to be used. * @param sslFactory the {@link SSLFactory} to be used. This can be {@code null} if no components require SSL support. * @param addedChannelHandlers a list of {@link ChannelHandler} to add to the {@link io.netty.channel.ChannelInitializer} before * the final handler. * @throws InstantiationException if there is any error instantiating an instance of RestServer. */ public RestServer(VerifiableProperties verifiableProperties, ClusterMap clusterMap, NotificationSystem notificationSystem, SSLFactory sslFactory, List<ChannelHandler> addedChannelHandlers) throws Exception { if (verifiableProperties == null || clusterMap == null || notificationSystem == null) { throw new IllegalArgumentException("Null arg(s) received during instantiation of RestServer"); } MetricRegistry metricRegistry = clusterMap.getMetricRegistry(); RestServerConfig restServerConfig = new RestServerConfig(verifiableProperties); reporter = JmxReporter.forRegistry(metricRegistry).build(); RestRequestMetricsTracker.setDefaults(metricRegistry); restServerState = new RestServerState(restServerConfig.restServerHealthCheckUri); restServerMetrics = new RestServerMetrics(metricRegistry, restServerState); AccountServiceFactory accountServiceFactory = Utils.getObj(restServerConfig.restServerAccountServiceFactory, verifiableProperties, clusterMap.getMetricRegistry()); accountService = accountServiceFactory.getAccountService(); SSLFactory routerSslFactory; if (new RouterConfig(verifiableProperties).routerEnableHttp2NetworkClient) { routerSslFactory = new NettySslHttp2Factory(new SSLConfig(verifiableProperties)); } else { routerSslFactory = sslFactory; } RouterFactory routerFactory = Utils.getObj(restServerConfig.restServerRouterFactory, verifiableProperties, clusterMap, notificationSystem, routerSslFactory, accountService); router = routerFactory.getRouter(); // setup the router for the account service if (accountService instanceof HelixAccountService) { ((HelixAccountService) accountService).setupRouter(router); } // setup restRequestService RestRequestServiceFactory restRequestServiceFactory = Utils.getObj(restServerConfig.restServerRestRequestServiceFactory, verifiableProperties, clusterMap, router, accountService); restRequestService = restRequestServiceFactory.getRestRequestService(); if (restRequestService == null) { throw new InstantiationException("RestRequestService is null"); } RestRequestResponseHandlerFactory restHandlerFactory = Utils.getObj(restServerConfig.restServerRequestResponseHandlerFactory, restServerConfig.restServerRequestHandlerScalingUnitCount, metricRegistry, restRequestService); restRequestHandler = restHandlerFactory.getRestRequestHandler(); restResponseHandler = restHandlerFactory.getRestResponseHandler(); publicAccessLogger = new PublicAccessLogger(restServerConfig.restServerPublicAccessLogRequestHeaders.split(","), restServerConfig.restServerPublicAccessLogResponseHeaders.split(",")); NioServerFactory nioServerFactory = Utils.getObj(restServerConfig.restServerNioServerFactory, verifiableProperties, metricRegistry, restRequestHandler, publicAccessLogger, restServerState, sslFactory, restServerConfig.restServerEnableAddedChannelHandlers ? addedChannelHandlers : null); nioServer = nioServerFactory.getNioServer(); if (accountService == null || router == null || restResponseHandler == null || restRequestHandler == null || nioServer == null) { throw new InstantiationException("Some of the server components were null"); } nettyInternalMetrics = new NettyInternalMetrics(metricRegistry, new NettyConfig(verifiableProperties)); logger.trace("Instantiated RestServer"); }
Example #20
Source File: VcrServer.java From ambry with Apache License 2.0 | 4 votes |
/** * Start the VCR Server. * @throws InstantiationException if an error was encountered during startup. */ public void startup() throws InstantiationException { try { logger.info("starting"); clusterMap = clusterAgentsFactory.getClusterMap(); logger.info("Initialized clusterMap"); logger.info("Setting up JMX."); long startTime = SystemTime.getInstance().milliseconds(); registry = clusterMap.getMetricRegistry(); reporter = JmxReporter.forRegistry(registry).build(); reporter.start(); logger.info("creating configs"); NetworkConfig networkConfig = new NetworkConfig(properties); StoreConfig storeConfig = new StoreConfig(properties); ServerConfig serverConfig = new ServerConfig(properties); ReplicationConfig replicationConfig = new ReplicationConfig(properties); CloudConfig cloudConfig = new CloudConfig(properties); ConnectionPoolConfig connectionPoolConfig = new ConnectionPoolConfig(properties); ClusterMapConfig clusterMapConfig = new ClusterMapConfig(properties); SSLConfig sslConfig = new SSLConfig(properties); // verify the configs properties.verify(); virtualReplicatorCluster = ((VirtualReplicatorClusterFactory) Utils.getObj(cloudConfig.virtualReplicatorClusterFactoryClass, cloudConfig, clusterMapConfig, clusterMap)).getVirtualReplicatorCluster(); // initialize cloud destination if (cloudDestinationFactory == null) { cloudDestinationFactory = Utils.getObj(cloudConfig.cloudDestinationFactoryClass, properties, registry); } scheduler = Utils.newScheduler(serverConfig.serverSchedulerNumOfthreads, false); StoreKeyFactory storeKeyFactory = Utils.getObj(storeConfig.storeKeyFactory, clusterMap); connectionPool = new BlockingChannelConnectionPool(connectionPoolConfig, sslConfig, clusterMapConfig, registry); connectionPool.start(); StoreKeyConverterFactory storeKeyConverterFactory = Utils.getObj(serverConfig.serverStoreKeyConverterFactory, properties, registry); cloudDestination = cloudDestinationFactory.getCloudDestination(); VcrMetrics vcrMetrics = new VcrMetrics(registry); CloudStorageManager cloudStorageManager = new CloudStorageManager(properties, vcrMetrics, cloudDestination, clusterMap); vcrReplicationManager = new VcrReplicationManager(cloudConfig, replicationConfig, clusterMapConfig, storeConfig, cloudStorageManager, storeKeyFactory, clusterMap, virtualReplicatorCluster, cloudDestination, scheduler, connectionPool, vcrMetrics, notificationSystem, storeKeyConverterFactory, serverConfig.serverMessageTransformer); vcrReplicationManager.start(); DataNodeId currentNode = virtualReplicatorCluster.getCurrentDataNodeId(); ArrayList<Port> ports = new ArrayList<Port>(); ports.add(new Port(networkConfig.port, PortType.PLAINTEXT)); if (currentNode.hasSSLPort()) { ports.add(new Port(cloudConfig.vcrSslPort, PortType.SSL)); } networkServer = new SocketServer(networkConfig, sslConfig, registry, ports); //todo fix enableDataPrefetch ServerMetrics serverMetrics = new ServerMetrics(registry, VcrRequests.class, VcrServer.class); requests = new VcrRequests(cloudStorageManager, networkServer.getRequestResponseChannel(), clusterMap, currentNode, registry, serverMetrics, new FindTokenHelper(storeKeyFactory, replicationConfig), notificationSystem, vcrReplicationManager, storeKeyFactory, true, storeKeyConverterFactory); requestHandlerPool = new RequestHandlerPool(serverConfig.serverRequestHandlerNumOfThreads, networkServer.getRequestResponseChannel(), requests); networkServer.start(); long processingTime = SystemTime.getInstance().milliseconds() - startTime; logger.info("VCR startup time in Ms {}", processingTime); } catch (Exception e) { logger.error("Error during VCR startup", e); throw new InstantiationException("failure during VCR startup " + e); } }
Example #21
Source File: SingularityS3UploaderMetrics.java From Singularity with Apache License 2.0 | 4 votes |
private void startJmxReporter() { JmxReporter reporter = JmxReporter.forRegistry(registry).build(); reporter.start(); }
Example #22
Source File: SingularityS3DownloaderMetrics.java From Singularity with Apache License 2.0 | 4 votes |
private void startJmxReporter() { JmxReporter reporter = JmxReporter.forRegistry(registry).build(); reporter.start(); }
Example #23
Source File: MetricUtil.java From foxtrot with Apache License 2.0 | 4 votes |
private MetricUtil() { JmxReporter.forRegistry(metrics) .convertRatesTo(TimeUnit.MINUTES) .build() .start(); }
Example #24
Source File: ServingServer.java From FATE-Serving with Apache License 2.0 | 4 votes |
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 #25
Source File: SpringConfig.java From FATE-Serving with Apache License 2.0 | 4 votes |
@Bean public JmxReporter jmxReporter(MetricRegistry metrics) { return JmxReporter.forRegistry(metrics).build(); }
Example #26
Source File: JmxConfigurator.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public void configureAndStart(String name, MetricRegistry registry, MetricFilter filter) { reporter = JmxReporter.forRegistry(registry).convertRatesTo(rateUnit).convertDurationsTo(durationUnit).filter(filter).build(); reporter.start(); }
Example #27
Source File: DropWizardMetricFactory.java From james-project with Apache License 2.0 | 4 votes |
@Inject public DropWizardMetricFactory(MetricRegistry metricRegistry) { this.metricRegistry = metricRegistry; this.jmxReporter = JmxReporter.forRegistry(metricRegistry) .build(); }
Example #28
Source File: JmxMeterRegistry.java From micrometer with Apache License 2.0 | 4 votes |
public JmxMeterRegistry(JmxConfig config, Clock clock, HierarchicalNameMapper nameMapper, MetricRegistry metricRegistry, JmxReporter jmxReporter) { super(config, metricRegistry, nameMapper, clock); this.reporter = jmxReporter; this.reporter.start(); }
Example #29
Source File: JmxMeterRegistry.java From micrometer with Apache License 2.0 | 4 votes |
private static JmxReporter defaultJmxReporter(JmxConfig config, MetricRegistry metricRegistry) { return JmxReporter.forRegistry(metricRegistry) .inDomain(config.domain()) .build(); }
Example #30
Source File: JmxReporterServer.java From hudi with Apache License 2.0 | 4 votes |
public JmxReporter getReporter() { return reporter; }