Search in sources :

Example 76 with Monitors

use of org.neo4j.kernel.monitoring.Monitors in project neo4j by neo4j.

the class LoggingListenerTest method shouldBeAbleToOutputMultipleMethodArguments.

@Test
public void shouldBeAbleToOutputMultipleMethodArguments() {
    // Given
    Monitors monitors = new Monitors();
    AssertableLogProvider logProvider = new AssertableLogProvider();
    InterestingMonitor2 aMonitor = monitors.newMonitor(InterestingMonitor2.class);
    LoggingListener listener = new LoggingListener(Collections.<Class<?>, Logger>singletonMap(InterestingMonitor2.class, logProvider.getLog(InterestingMonitor2.class).debugLogger()));
    monitors.addMonitorListener(listener, listener.predicate);
    // When
    aMonitor.doubleTouch("APA", 42);
    // Then
    logProvider.assertExactly(inLog(InterestingMonitor2.class).debug("doubleTouch(String:APA,int:42)"));
}
Also used : Monitors(org.neo4j.kernel.monitoring.Monitors) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 77 with Monitors

use of org.neo4j.kernel.monitoring.Monitors in project neo4j by neo4j.

the class LoggingListenerTest method shouldBeAbleToListenToMultipleMonitors.

@Test
public void shouldBeAbleToListenToMultipleMonitors() {
    // Given
    Monitors monitors = new Monitors();
    AssertableLogProvider logProvider = new AssertableLogProvider();
    InterestingMonitor1 aMonitor = monitors.newMonitor(InterestingMonitor1.class);
    InterestingMonitor2 bMonitor = monitors.newMonitor(InterestingMonitor2.class);
    Map<Class<?>, Logger> classes = new HashMap<>(2);
    classes.put(InterestingMonitor1.class, logProvider.getLog(InterestingMonitor1.class).debugLogger());
    classes.put(InterestingMonitor2.class, logProvider.getLog(InterestingMonitor2.class).warnLogger());
    LoggingListener listener = new LoggingListener(classes);
    monitors.addMonitorListener(listener, listener.predicate);
    // When
    aMonitor.touch();
    bMonitor.touch();
    // Then
    logProvider.assertExactly(inLog(InterestingMonitor1.class).debug("touch()"), inLog(InterestingMonitor2.class).warn("touch()"));
}
Also used : HashMap(java.util.HashMap) Monitors(org.neo4j.kernel.monitoring.Monitors) Logger(org.neo4j.logging.Logger) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 78 with Monitors

use of org.neo4j.kernel.monitoring.Monitors in project neo4j by neo4j.

the class MonitorLoggingAcceptanceTest method shouldBeAbleToLoadPropertiesFromAFile.

@Test
public void shouldBeAbleToLoadPropertiesFromAFile() throws InterruptedException {
    AssertableLogProvider logProvider = new AssertableLogProvider();
    GraphDatabaseAPI dbAPI = (GraphDatabaseAPI) new TestGraphDatabaseFactory().setInternalLogProvider(logProvider).newImpermanentDatabase();
    Monitors monitors = dbAPI.getDependencyResolver().resolveDependency(Monitors.class);
    AMonitor aMonitor = monitors.newMonitor(AMonitor.class);
    aMonitor.doStuff();
    logProvider.assertAtLeastOnce(inLog(AMonitor.class).warn("doStuff()"));
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Monitors(org.neo4j.kernel.monitoring.Monitors) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 79 with Monitors

use of org.neo4j.kernel.monitoring.Monitors in project neo4j by neo4j.

the class CommunityServerBuilder method build.

public CommunityNeoServer build() throws IOException {
    if (dataDir == null && persistent) {
        throw new IllegalStateException("Must specify path");
    }
    final Optional<File> configFile = buildBefore();
    Log log = logProvider.getLog(getClass());
    Config config = ConfigLoader.loadServerConfig(configFile);
    config.setLogger(log);
    return build(configFile, config, GraphDatabaseDependencies.newDependencies().userLogProvider(logProvider).monitors(new Monitors()));
}
Also used : Log(org.neo4j.logging.Log) Config(org.neo4j.kernel.configuration.Config) Monitors(org.neo4j.kernel.monitoring.Monitors) File(java.io.File)

Aggregations

Monitors (org.neo4j.kernel.monitoring.Monitors)79 Test (org.junit.Test)53 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)12 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)11 File (java.io.File)10 ByteBuffer (java.nio.ByteBuffer)9 StoreId (org.neo4j.causalclustering.identity.StoreId)9 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)9 LogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)9 ByteCounterMonitor (org.neo4j.kernel.monitoring.ByteCounterMonitor)9 IOException (java.io.IOException)8 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)8 BlockLogBuffer (org.neo4j.com.BlockLogBuffer)8 Config (org.neo4j.kernel.configuration.Config)8 PageCache (org.neo4j.io.pagecache.PageCache)7 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)7 DependencyResolver (org.neo4j.graphdb.DependencyResolver)6 URI (java.net.URI)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 ClusterConfiguration (org.neo4j.cluster.protocol.cluster.ClusterConfiguration)5