/** * Registers the JVM metrics to the metric registry and start to report * the registry metrics via JMX. */ public void registerMetrics() { if (metricsAreRegistered) { return; } getMetricRegistry().register("jvm.attribute", new JvmAttributeGaugeSet()); getMetricRegistry().register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory .getPlatformMBeanServer())); getMetricRegistry().register("jvm.classloader", new ClassLoadingGaugeSet()); getMetricRegistry().register("jvm.filedescriptor", new FileDescriptorRatioGauge()); getMetricRegistry().register("jvm.gc", new GarbageCollectorMetricSet()); getMetricRegistry().register("jvm.memory", new MemoryUsageGaugeSet()); getMetricRegistry().register("jvm.threads", new ThreadStatesGaugeSet()); JmxReporter.forRegistry(metricRegistry).build().start(); metricsAreRegistered = true; }
@Override protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception { final Environment environment = new Environment(bootstrap.getApplication().getName(), bootstrap.getObjectMapper(), bootstrap.getValidatorFactory(), bootstrap.getMetricRegistry(), bootstrap.getClassLoader(), bootstrap.getHealthCheckRegistry()); configuration.getMetricsFactory().configure(environment.lifecycle(), bootstrap.getMetricRegistry()); configuration.getServerFactory().configure(environment); bootstrap.run(configuration, environment); application.run(configuration, environment); run(environment, namespace, configuration); }
@Override @SuppressWarnings("unchecked") public void run(Bootstrap<?> wildcardBootstrap, Namespace namespace) throws Exception { final Bootstrap<T> bootstrap = (Bootstrap<T>) wildcardBootstrap; configuration = parseConfiguration(bootstrap.getConfigurationFactoryFactory(), bootstrap.getConfigurationSourceProvider(), bootstrap.getValidatorFactory().getValidator(), namespace.getString("file"), getConfigurationClass(), bootstrap.getObjectMapper()); try { if (configuration != null) { configuration.getLoggingFactory().configure(bootstrap.getMetricRegistry(), bootstrap.getApplication().getName()); } run(bootstrap, namespace, configuration); } finally { if (!asynchronous) { cleanup(); } } }
/** * Registers the JVM metrics to the metric registry and start to report * the registry metrics via JMX. */ public void registerMetrics() { if (metricsAreRegistered) { return; } getMetricRegistry().register("jvm.attribute", new JvmAttributeGaugeSet()); getMetricRegistry().register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory .getPlatformMBeanServer())); getMetricRegistry().register("jvm.classloader", new ClassLoadingGaugeSet()); getMetricRegistry().register("jvm.filedescriptor", new FileDescriptorRatioGauge()); getMetricRegistry().register("jvm.gc", new GarbageCollectorMetricSet()); getMetricRegistry().register("jvm.memory", new MemoryUsageGaugeSet()); getMetricRegistry().register("jvm.threads", new ThreadStatesGaugeSet()); JmxReporter.forRegistry(metricRegistry).build().start(); metricsAreRegistered = true; }
@Override protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception { final Environment environment = new Environment(bootstrap.getApplication().getName(), bootstrap.getObjectMapper(), bootstrap.getValidatorFactory().getValidator(), bootstrap.getMetricRegistry(), bootstrap.getClassLoader(), bootstrap.getHealthCheckRegistry()); configuration.getMetricsFactory().configure(environment.lifecycle(), bootstrap.getMetricRegistry()); configuration.getServerFactory().configure(environment); bootstrap.run(configuration, environment); application.run(configuration, environment); run(environment, namespace, configuration); }
@Override @SuppressWarnings("unchecked") public void run(Bootstrap<?> wildcardBootstrap, Namespace namespace) throws Exception { final Bootstrap<T> bootstrap = (Bootstrap<T>) wildcardBootstrap; configuration = parseConfiguration(bootstrap.getConfigurationFactoryFactory(), bootstrap.getConfigurationSourceProvider(), bootstrap.getValidatorFactory().getValidator(), namespace.getString("file"), getConfigurationClass(), bootstrap.getObjectMapper()); try { if (configuration != null) { configuration.getLoggingFactory().configure(bootstrap.getMetricRegistry(), bootstrap.getApplication().getName()); } run(bootstrap, namespace, configuration); } finally { if (!asynchronous) { cleanup(); } } }
@Override public void initialize(Bootstrap<?> bootstrap) { // add shared metrics registry to be used by Jobs, since defaultRegistry // has been removed SharedMetricRegistries.add(Job.DROPWIZARD_JOBS_KEY, bootstrap.getMetricRegistry()); }
/** * Implements com.yammer.dropwizard.Bundle#initialize() */ @Override public void initialize(Bootstrap<?> bootstrap) { this.jaxwsEnvironment.setInstrumentedInvokerBuilder( new InstrumentedInvokerFactory(bootstrap.getMetricRegistry())); }
@Override public void configure(Binder binder) { binder.install(new MetricsInstrumentationModule(getBootstrap().getMetricRegistry())); binder.install(new SingularityMainModule(getConfiguration())); binder.install(new SingularityDataModule()); binder.install(new SingularitySchedulerModule()); binder.install(new SingularityResourceModule(getConfiguration().getUiConfiguration())); binder.install(new SingularityTranscoderModule()); binder.install(new SingularityHistoryModule(getConfiguration())); binder.install(new SingularityMesosModule()); binder.install(new SingularityZkMigrationsModule()); binder.install(new SingularityMesosClientModule()); binder.install(new SingularityJerseyModule()); // API Docs getEnvironment().jersey().register(SingularityOpenApiResource.class); binder.install(new SingularityEventModule(getConfiguration())); }
@Override public void initialize(Bootstrap<?> bootstrap) { try { HystrixPlugins.getInstance().registerMetricsPublisher(new YammerMetricsPublisher(bootstrap.getMetricRegistry())); } catch (Exception err) { LOGGER.warn("Failed to register YammerMetricsPublisher with HystrixPlugins. This is what MetricsPublisher is currently registered: {}", HystrixPlugins.getInstance().getMetricsPublisher().getClass(), err); } executionHook.ifPresent(HystrixPlugins.getInstance()::registerCommandExecutionHook); }
@Override public void initialize(Bootstrap<?> bootstrap) { try { HystrixPlugins.getInstance().registerMetricsPublisher(new YammerMetricsPublisher(bootstrap.getMetricRegistry())); } catch (Exception err) { LOGGER.warn("Failed to register YammerMetricsPublisher with HystrixPlugins. This is what MetricsPublisher is currently registered: {}", HystrixPlugins.getInstance().getMetricsPublisher().getClass(), err); } executionHook.ifPresent(HystrixPlugins.getInstance()::registerCommandExecutionHook); }
@Override protected void run(Bootstrap<EmoConfiguration> bootstrap, Namespace namespace, EmoConfiguration configuration) throws Exception { String serviceName = namespace.getString("service"); CuratorFramework curator = configuration.getZooKeeperConfiguration().newCurator(); curator.start(); ZooKeeperHostDiscovery hostDiscovery = new ZooKeeperHostDiscovery(curator, serviceName, bootstrap.getMetricRegistry()); for (ServiceEndPoint endPoint : hostDiscovery.getHosts()) { System.out.println(endPoint.getId()); } hostDiscovery.close(); curator.close(); } }
@Override protected void run(final Bootstrap<T> bootstrap, final Namespace namespace, final T configuration) throws Exception { final PooledDataSourceFactory datasourceFactory = databaseConfiguration.getDataSourceFactory(configuration); final FlywayFactory flywayFactory = flywayConfiguration.getFlywayFactory(configuration); final Flyway flyway = flywayFactory.build(datasourceFactory.build(bootstrap.getMetricRegistry(), "Flyway")); try { run(namespace, flyway); } catch (FlywayException e) { LOG.error("Error while running database command", e); throw e; } }
@Override protected void run(Bootstrap<EmoConfiguration> bootstrap, Namespace namespace, EmoConfiguration emoConfiguration) throws Exception { _outputOnly = namespace.getBoolean("output_only"); DdlConfiguration ddlConfiguration = parseDdlConfiguration(toFile(namespace.getString("config-ddl"))); CuratorFramework curator = null; if (!_outputOnly) { curator = emoConfiguration.getZooKeeperConfiguration().newCurator(); curator.start(); } try { createKeyspacesIfNecessary(emoConfiguration, ddlConfiguration, curator, bootstrap.getMetricRegistry()); } finally { Closeables.close(curator, true); } }
MetricRegistry metricRegistry = bootstrap.getMetricRegistry(); Client client = createDefaultJerseyClient(config.getHttpClientConfiguration(), metricRegistry, "");
@Override public void initialize(final Bootstrap<StreamRegistryConfiguration> bootstrap) { // EnvironmentVariableSubstitutor enables EnvVariables to be substituted into the configuration before initialization bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false) ) ); bootstrap.addBundle(new SwaggerBundle<StreamRegistryConfiguration>() { @Override protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(StreamRegistryConfiguration configuration) { return configuration.getSwaggerBundleConfiguration(); } }); metricRegistry = bootstrap.getMetricRegistry(); }
@Override public void initialize(Bootstrap<EmoConfiguration> bootstrap) { bootstrap.addCommand(new CreateKeyspacesCommand()); bootstrap.addCommand(new RegisterCassandraCommand()); bootstrap.addCommand(new ListCassandraCommand()); bootstrap.addCommand(new UnregisterCassandraCommand()); bootstrap.addCommand(new PurgeDatabusEventsCommand()); bootstrap.addCommand(new AllTablesReportCommand()); bootstrap.addCommand(new EncryptConfigurationApiKeyCommand()); EmoServiceObjectMapperFactory.configure(bootstrap.getObjectMapper()); bootstrap.getMetricRegistry().register("jvm.gc.totals", new EmoGarbageCollectorMetricSet()); }
.commandExecutionHook(new ExceptionLoggingCommandHook( ImmutableList.of( new DBIExceptionLogger(bootstrap.getMetricRegistry()), new SQLExceptionLogger(bootstrap.getMetricRegistry()), new DefaultExceptionLogger())))) .build();
@Override public void configure(Binder binder) { binder.install(new MetricsInstrumentationModule(getBootstrap().getMetricRegistry())); binder.install(new SingularityMainModule(getConfiguration())); binder.install(new SingularityDataModule()); binder.install(new SingularitySchedulerModule()); binder.install(new SingularityResourceModule(getConfiguration().getUiConfiguration())); binder.install(new SingularityTranscoderModule()); binder.install(new SingularityHistoryModule(getConfiguration())); binder.install(new SingularityMesosModule()); binder.install(new SingularityZkMigrationsModule()); binder.install(new SingularityMesosClientModule()); binder.install(new SingularityJerseyModule()); // API Docs getEnvironment().jersey().register(SingularityOpenApiResource.class); binder.install(new SingularityEventModule(getConfiguration())); }