Search in sources :

Example 81 with MetricRegistry

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

the class SyslogdIT method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    MockLogAppender.resetState();
    InputStream stream = null;
    try {
        stream = ConfigurationTestUtils.getInputStreamForResource(this, "/etc/syslogd-configuration.xml");
        m_config = new SyslogdConfigFactory(stream);
    } finally {
        if (stream != null) {
            IOUtils.closeQuietly(stream);
        }
    }
    // Verify that the test syslogd-configuration.xml file was loaded
    boolean foundBeer = false;
    boolean foundMalt = false;
    assertEquals(10514, m_config.getSyslogPort());
    for (final UeiMatch match : m_config.getUeiList()) {
        if (match.getProcessMatch().isPresent()) {
            final ProcessMatch processMatch = match.getProcessMatch().get();
            if (!foundBeer && "beerd".equals(processMatch.getExpression())) {
                foundBeer = true;
            } else if (!foundMalt && "maltd".equals(processMatch.getExpression())) {
                foundMalt = true;
            }
        }
    }
    assertTrue(foundBeer);
    assertTrue(foundMalt);
    m_syslogSinkConsumer = new SyslogSinkConsumer(new MetricRegistry());
    m_syslogSinkConsumer.setDistPollerDao(m_distPollerDao);
    m_syslogSinkConsumer.setSyslogdConfig(m_config);
    m_syslogSinkConsumer.setEventForwarder(m_eventIpcManager);
    m_syslogSinkModule = m_syslogSinkConsumer.getModule();
    m_messageDispatcherFactory.setConsumer(m_syslogSinkConsumer);
    SyslogReceiverJavaNetImpl receiver = new SyslogReceiverJavaNetImpl(m_config);
    receiver.setDistPollerDao(m_distPollerDao);
    receiver.setMessageDispatcherFactory(m_messageDispatcherFactory);
    m_syslogd.setSyslogReceiver(receiver);
    m_syslogd.init();
    SyslogdTestUtils.startSyslogdGracefully(m_syslogd);
}
Also used : ProcessMatch(org.opennms.netmgt.config.syslogd.ProcessMatch) InputStream(java.io.InputStream) MetricRegistry(com.codahale.metrics.MetricRegistry) UeiMatch(org.opennms.netmgt.config.syslogd.UeiMatch) SyslogdConfigFactory(org.opennms.netmgt.config.SyslogdConfigFactory) Before(org.junit.Before)

Example 82 with MetricRegistry

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

the class EvaluateStatsIT method setUp.

/**
 * Sets up the test.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    System.setProperty("org.opennms.rrd.storeByGroup", "true");
    registry = new MetricRegistry();
    stats = new EvaluateStats(registry, 5, 10);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) Before(org.junit.Before)

Example 83 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project HikariCP by brettwooldridge.

the class TestMetrics method testMetricRegistrySubclassIsAllowed.

@Test
public void testMetricRegistrySubclassIsAllowed() {
    try (HikariDataSource ds = newHikariDataSource()) {
        ds.setMaximumPoolSize(1);
        ds.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
        ds.setMetricRegistry(new MetricRegistry() {

            @Override
            public Timer timer(String name) {
                return super.timer(name);
            }
        });
    }
}
Also used : TestElf.newHikariDataSource(com.zaxxer.hikari.pool.TestElf.newHikariDataSource) HikariDataSource(com.zaxxer.hikari.HikariDataSource) Timer(com.codahale.metrics.Timer) MetricRegistry(com.codahale.metrics.MetricRegistry) Test(org.junit.Test)

Example 84 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project grakn by graknlabs.

the class PostProcessingTest method setupPostProcessor.

@Before
public void setupPostProcessor() {
    MetricRegistry metricRegistry = new MetricRegistry();
    RedisIndexStorage indexStorage = RedisIndexStorage.create(engine.getJedisPool(), metricRegistry);
    IndexPostProcessor indexPostProcessor = IndexPostProcessor.create(engine.server().lockProvider(), indexStorage);
    RedisCountStorage countStorage = RedisCountStorage.create(engine.getJedisPool(), metricRegistry);
    CountPostProcessor countPostProcessor = CountPostProcessor.create(engine.config(), engine.factory(), engine.server().lockProvider(), metricRegistry, countStorage);
    session = engine.sessionWithNewKeyspace();
    postProcessor = PostProcessor.create(indexPostProcessor, countPostProcessor);
}
Also used : RedisIndexStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisIndexStorage) IndexPostProcessor(ai.grakn.engine.task.postprocessing.IndexPostProcessor) MetricRegistry(com.codahale.metrics.MetricRegistry) RedisCountStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) Before(org.junit.Before)

Example 85 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project grakn by graknlabs.

the class EngineContext method startGraknEngineServer.

private GraknEngineServer startGraknEngineServer(RedisWrapper redisWrapper) throws IOException {
    EngineID id = EngineID.me();
    GraknEngineStatus status = new GraknEngineStatus();
    MetricRegistry metricRegistry = new MetricRegistry();
    // distributed locks
    LockProvider lockProvider = new JedisLockProvider(redisWrapper.getJedisPool());
    graknKeyspaceStore = GraknKeyspaceStoreImpl.create(new GraknSystemKeyspaceSession(config));
    // tx-factory
    engineGraknTxFactory = EngineGraknTxFactory.create(lockProvider, config, graknKeyspaceStore);
    // post-processing
    IndexStorage indexStorage = RedisIndexStorage.create(redisWrapper.getJedisPool(), metricRegistry);
    CountStorage countStorage = RedisCountStorage.create(redisWrapper.getJedisPool(), metricRegistry);
    IndexPostProcessor indexPostProcessor = IndexPostProcessor.create(lockProvider, indexStorage);
    CountPostProcessor countPostProcessor = CountPostProcessor.create(config, engineGraknTxFactory, lockProvider, metricRegistry, countStorage);
    PostProcessor postProcessor = PostProcessor.create(indexPostProcessor, countPostProcessor);
    GrpcOpenRequestExecutor requestExecutor = new GrpcOpenRequestExecutorImpl(engineGraknTxFactory);
    Server server = ServerBuilder.forPort(0).addService(new GrpcGraknService(requestExecutor, postProcessor)).build();
    GrpcServer grpcServer = GrpcServer.create(server);
    GraknTestUtil.allocateSparkPort(config);
    QueueSanityCheck queueSanityCheck = new RedisSanityCheck(redisWrapper);
    GraknEngineServer graknEngineServer = GraknEngineServerFactory.createGraknEngineServer(id, config, status, spark, Collections.emptyList(), grpcServer, engineGraknTxFactory, metricRegistry, queueSanityCheck, lockProvider, postProcessor, graknKeyspaceStore);
    graknEngineServer.start();
    // Read the automatically allocated ports and write them back into the config
    config.setConfigProperty(GraknConfigKey.GRPC_PORT, server.getPort());
    return graknEngineServer;
}
Also used : GraknSystemKeyspaceSession(ai.grakn.engine.GraknSystemKeyspaceSession) EngineID(ai.grakn.engine.util.EngineID) GraknEngineServer(ai.grakn.engine.GraknEngineServer) Server(io.grpc.Server) GrpcServer(ai.grakn.engine.rpc.GrpcServer) GrpcOpenRequestExecutorImpl(ai.grakn.engine.rpc.GrpcOpenRequestExecutorImpl) IndexPostProcessor(ai.grakn.engine.task.postprocessing.IndexPostProcessor) MetricRegistry(com.codahale.metrics.MetricRegistry) GrpcOpenRequestExecutor(ai.grakn.grpc.GrpcOpenRequestExecutor) GraknEngineServer(ai.grakn.engine.GraknEngineServer) GrpcServer(ai.grakn.engine.rpc.GrpcServer) GraknEngineStatus(ai.grakn.engine.GraknEngineStatus) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) JedisLockProvider(ai.grakn.engine.lock.JedisLockProvider) LockProvider(ai.grakn.engine.lock.LockProvider) JedisLockProvider(ai.grakn.engine.lock.JedisLockProvider) IndexStorage(ai.grakn.engine.task.postprocessing.IndexStorage) RedisIndexStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisIndexStorage) QueueSanityCheck(ai.grakn.engine.data.QueueSanityCheck) CountStorage(ai.grakn.engine.task.postprocessing.CountStorage) RedisCountStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage) RedisSanityCheck(ai.grakn.engine.data.RedisSanityCheck) IndexPostProcessor(ai.grakn.engine.task.postprocessing.IndexPostProcessor) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) PostProcessor(ai.grakn.engine.task.postprocessing.PostProcessor) GrpcGraknService(ai.grakn.engine.rpc.GrpcGraknService)

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