Search in sources :

Example 11 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project dropwizard by dropwizard.

the class MultipleContentTypeTest method configure.

@Override
protected Application configure() {
    forceSet(TestProperties.CONTAINER_PORT, "0");
    final ViewRenderer renderer = new FreemarkerViewRenderer();
    return DropwizardResourceConfig.forTesting(new MetricRegistry()).register(new ViewMessageBodyWriter(new MetricRegistry(), ImmutableList.of(renderer))).register(new InfoMessageBodyWriter()).register(new ExampleResource());
}
Also used : ViewRenderer(io.dropwizard.views.ViewRenderer) MetricRegistry(com.codahale.metrics.MetricRegistry) ViewMessageBodyWriter(io.dropwizard.views.ViewMessageBodyWriter)

Example 12 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project hadoop by apache.

the class KMSWebApp method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent sce) {
    try {
        String confDir = System.getProperty(KMSConfiguration.KMS_CONFIG_DIR);
        if (confDir == null) {
            throw new RuntimeException("System property '" + KMSConfiguration.KMS_CONFIG_DIR + "' not defined");
        }
        kmsConf = KMSConfiguration.getKMSConf();
        initLogging(confDir);
        UserGroupInformation.setConfiguration(kmsConf);
        LOG.info("-------------------------------------------------------------");
        LOG.info("  Java runtime version : {}", System.getProperty("java.runtime.version"));
        LOG.info("  User: {}", System.getProperty("user.name"));
        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(GENERATE_EEK_METER, new Meter());
        decryptEEKCallsMeter = metricRegistry.register(DECRYPT_EEK_METER, new Meter());
        adminCallsMeter = metricRegistry.register(ADMIN_CALLS_METER, new Meter());
        keyCallsMeter = metricRegistry.register(KEY_CALLS_METER, new Meter());
        invalidCallsMeter = metricRegistry.register(INVALID_CALLS_METER, new Meter());
        unauthorizedCallsMeter = metricRegistry.register(UNAUTHORIZED_CALLS_METER, new Meter());
        unauthenticatedCallsMeter = metricRegistry.register(UNAUTHENTICATED_CALLS_METER, new Meter());
        kmsAudit = new KMSAudit(kmsConf);
        // intializing the KeyProvider
        String providerString = kmsConf.get(KMSConfiguration.KEY_PROVIDER_URI);
        if (providerString == null) {
            throw new IllegalStateException("No KeyProvider has been defined");
        }
        KeyProvider keyProvider = KeyProviderFactory.get(new URI(providerString), kmsConf);
        if (kmsConf.getBoolean(KMSConfiguration.KEY_CACHE_ENABLE, KMSConfiguration.KEY_CACHE_ENABLE_DEFAULT)) {
            long keyTimeOutMillis = kmsConf.getLong(KMSConfiguration.KEY_CACHE_TIMEOUT_KEY, KMSConfiguration.KEY_CACHE_TIMEOUT_DEFAULT);
            long currKeyTimeOutMillis = kmsConf.getLong(KMSConfiguration.CURR_KEY_CACHE_TIMEOUT_KEY, KMSConfiguration.CURR_KEY_CACHE_TIMEOUT_DEFAULT);
            keyProvider = new CachingKeyProvider(keyProvider, keyTimeOutMillis, currKeyTimeOutMillis);
        }
        LOG.info("Initialized KeyProvider " + keyProvider);
        keyProviderCryptoExtension = KeyProviderCryptoExtension.createKeyProviderCryptoExtension(keyProvider);
        keyProviderCryptoExtension = new EagerKeyGeneratorKeyProviderCryptoExtension(kmsConf, keyProviderCryptoExtension);
        if (kmsConf.getBoolean(KMSConfiguration.KEY_AUTHORIZATION_ENABLE, KMSConfiguration.KEY_AUTHORIZATION_ENABLE_DEFAULT)) {
            keyProviderCryptoExtension = new KeyAuthorizationKeyProvider(keyProviderCryptoExtension, kmsAcls);
        }
        LOG.info("Initialized KeyProviderCryptoExtension " + keyProviderCryptoExtension);
        final int defaultBitlength = kmsConf.getInt(KeyProvider.DEFAULT_BITLENGTH_NAME, KeyProvider.DEFAULT_BITLENGTH);
        LOG.info("Default key bitlength is {}", defaultBitlength);
        LOG.info("KMS Started");
    } catch (Throwable ex) {
        System.out.println();
        System.out.println("ERROR: Hadoop KMS could not be started");
        System.out.println();
        System.out.println("REASON: " + ex.toString());
        System.out.println();
        System.out.println("Stacktrace:");
        System.out.println("---------------------------------------------------");
        ex.printStackTrace(System.out);
        System.out.println("---------------------------------------------------");
        System.out.println();
        System.exit(1);
    }
}
Also used : CachingKeyProvider(org.apache.hadoop.crypto.key.CachingKeyProvider) KeyProvider(org.apache.hadoop.crypto.key.KeyProvider) Meter(com.codahale.metrics.Meter) MetricRegistry(com.codahale.metrics.MetricRegistry) URI(java.net.URI) CachingKeyProvider(org.apache.hadoop.crypto.key.CachingKeyProvider)

Example 13 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project opennms by OpenNMS.

the class VacuumdIT method setUp.

@Before
public void setUp() throws Exception {
    m_network.createStandardNetwork();
    InputStream is = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/vacuumd/vacuumd-configuration.xml");
    try {
        VacuumdConfigFactory.setInstance(new VacuumdConfigFactory(is));
    } finally {
        IOUtils.closeQuietly(is);
    }
    m_eventdIpcMgr.setEventWriter(m_database);
    EventExpander expander = new EventExpander(new MetricRegistry());
    expander.setEventConfDao(new EmptyEventConfDao());
    m_eventdIpcMgr.setEventExpander(expander);
    Vacuumd.destroySingleton();
    m_vacuumd = Vacuumd.getSingleton();
    m_vacuumd.setEventManager(m_eventdIpcMgr);
    m_vacuumd.init();
    // Insert some empty nodes to avoid foreign-key violations on subsequent events/alarms
    OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "default-1");
    node.setId(1);
    m_nodeDao.save(node);
    node = new OnmsNode(m_locationDao.getDefaultLocation(), "default-2");
    node.setId(2);
    m_nodeDao.save(node);
    m_nodeDao.flush();
    MockUtil.println("------------ Finished setup for: " + this.getClass().getName() + " --------------------------");
}
Also used : VacuumdConfigFactory(org.opennms.netmgt.config.VacuumdConfigFactory) OnmsNode(org.opennms.netmgt.model.OnmsNode) EventExpander(org.opennms.netmgt.eventd.EventExpander) InputStream(java.io.InputStream) MetricRegistry(com.codahale.metrics.MetricRegistry) EmptyEventConfDao(org.opennms.netmgt.dao.mock.MockEventIpcManager.EmptyEventConfDao) Before(org.junit.Before)

Example 14 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project graylog2-server by Graylog2.

the class SearchesTest method setUp.

@Before
public void setUp() throws Exception {
    when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(INDEX_RANGES);
    metricRegistry = new MetricRegistry();
    searches = new Searches(new Configuration(), indexRangeService, client, metricRegistry, streamService, mock(Indices.class));
}
Also used : Configuration(org.graylog2.Configuration) MetricRegistry(com.codahale.metrics.MetricRegistry) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) Before(org.junit.Before)

Example 15 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project graylog2-server by Graylog2.

the class IndicesGetAllMessageFieldsTest method setUp.

@Before
public void setUp() throws Exception {
    elasticsearchRule.getDatabaseOperation().deleteAll();
    indices = new Indices(client, new IndexMapping(), new Messages(client, new MetricRegistry()), mock(NodeId.class), new NullAuditEventSender());
}
Also used : NullAuditEventSender(org.graylog2.audit.NullAuditEventSender) IndexMapping(org.graylog2.indexer.IndexMapping) Messages(org.graylog2.indexer.messages.Messages) MetricRegistry(com.codahale.metrics.MetricRegistry) Before(org.junit.Before)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)505 Test (org.junit.Test)177 Before (org.junit.Before)61 Test (org.junit.jupiter.api.Test)45 VerifiableProperties (com.github.ambry.config.VerifiableProperties)42 ArrayList (java.util.ArrayList)33 Counter (com.codahale.metrics.Counter)30 File (java.io.File)29 Properties (java.util.Properties)28 List (java.util.List)23 Metric (com.codahale.metrics.Metric)22 Map (java.util.Map)22 IOException (java.io.IOException)21 HashMap (java.util.HashMap)20 Size (com.github.joschi.jadconfig.util.Size)17 CountDownLatch (java.util.concurrent.CountDownLatch)17 TimeUnit (java.util.concurrent.TimeUnit)17 Timer (com.codahale.metrics.Timer)15 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)15 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)15