Search in sources :

Example 46 with Monitors

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

the class MasterClientResolverTest method shouldResolveMasterClientFactory.

@Test
public void shouldResolveMasterClientFactory() throws Exception {
    // Given
    LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>();
    MasterClientResolver resolver = new MasterClientResolver(NullLogProvider.getInstance(), ResponseUnpacker.NO_OP_RESPONSE_UNPACKER, mock(InvalidEpochExceptionHandler.class), 1, 1, 1, 1024, Suppliers.singleton(logEntryReader));
    LifeSupport life = new LifeSupport();
    try {
        life.start();
        MasterClient masterClient1 = resolver.instantiate("cluster://localhost", 44, null, new Monitors(), StoreId.DEFAULT, life);
        assertThat(masterClient1, instanceOf(MasterClient320.class));
    } finally {
        life.shutdown();
    }
    IllegalProtocolVersionException illegalProtocolVersionException = new IllegalProtocolVersionException(MasterClient214.PROTOCOL_VERSION.getApplicationProtocol(), MasterClient310.PROTOCOL_VERSION.getApplicationProtocol(), "Protocol is too modern");
    // When
    resolver.handle(illegalProtocolVersionException);
    // Then
    life = new LifeSupport();
    try {
        life.start();
        MasterClient masterClient2 = resolver.instantiate("cluster://localhost", 55, null, new Monitors(), StoreId.DEFAULT, life);
        assertThat(masterClient2, instanceOf(MasterClient214.class));
    } finally {
        life.shutdown();
    }
}
Also used : MasterClient320(org.neo4j.kernel.ha.MasterClient320) Monitors(org.neo4j.kernel.monitoring.Monitors) IllegalProtocolVersionException(org.neo4j.com.IllegalProtocolVersionException) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) MasterClient214(org.neo4j.kernel.ha.MasterClient214) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) Test(org.junit.Test)

Example 47 with Monitors

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

the class DatabaseActions method start.

public void start() throws UnableToStartServerException {
    if (isRunning()) {
        throw new UnableToStartServerException("Already started");
    }
    Config config = model.getConfig();
    Monitors monitors = new Monitors();
    LogProvider userLogProvider = FormattedLogProvider.toOutputStream(System.out);
    GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(userLogProvider).monitors(monitors);
    server = new CommunityNeoServer(config, dependencies, userLogProvider);
    try {
        server.start();
    } catch (ServerStartupException e) {
        server = null;
        Set<Class> causes = extractCauseTypes(e);
        if (causes.contains(StoreLockException.class)) {
            throw new UnableToStartServerException("Unable to lock store. Are you running another Neo4j process against this database?");
        }
        if (causes.contains(BindException.class)) {
            throw new UnableToStartServerException("Unable to bind to port. Are you running another Neo4j process on this computer?");
        }
        throw new UnableToStartServerException(e.getMessage());
    }
}
Also used : LogProvider(org.neo4j.logging.LogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) Set(java.util.Set) HashSet(java.util.HashSet) CommunityNeoServer(org.neo4j.server.CommunityNeoServer) Config(org.neo4j.kernel.configuration.Config) ServerStartupException(org.neo4j.server.ServerStartupException) UnableToStartServerException(org.neo4j.desktop.model.exceptions.UnableToStartServerException) Monitors(org.neo4j.kernel.monitoring.Monitors) GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) StoreLockException(org.neo4j.kernel.StoreLockException) BindException(java.net.BindException)

Example 48 with Monitors

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

the class MonitoredBoltWorkerFactoryTest method shouldSignalReceivedStartAndComplete.

@Test
public void shouldSignalReceivedStartAndComplete() throws Throwable {
    // given
    FakeClock clock = Clocks.fakeClock();
    WorkerFactory delegate = mock(WorkerFactory.class);
    BoltStateMachine machine = mock(BoltStateMachine.class);
    when(delegate.newWorker(anyObject(), anyObject())).thenReturn(new BoltWorker() {

        @Override
        public void enqueue(Job job) {
            clock.forward(1337, TimeUnit.MILLISECONDS);
            try {
                job.perform(machine);
            } catch (BoltConnectionFatality connectionFatality) {
                throw new RuntimeException(connectionFatality);
            }
        }

        @Override
        public void interrupt() {
            throw new RuntimeException();
        }

        @Override
        public void halt() {
            throw new RuntimeException();
        }
    });
    Monitors monitors = new Monitors();
    CountingSessionMonitor monitor = new CountingSessionMonitor();
    monitors.addMonitorListener(monitor);
    MonitoredWorkerFactory workerFactory = new MonitoredWorkerFactory(monitors, delegate, clock);
    BoltWorker worker = workerFactory.newWorker(CONNECTION_DESCRIPTOR);
    // when
    worker.enqueue((stateMachine) -> {
        stateMachine.run("hello", null, nullResponseHandler());
        clock.forward(1338, TimeUnit.MILLISECONDS);
    });
    // then
    assertEquals(1, monitor.messagesReceived);
    assertEquals(1337, monitor.queueTime);
    assertEquals(1338, monitor.processingTime);
}
Also used : FakeClock(org.neo4j.time.FakeClock) MonitoredBoltWorker(org.neo4j.bolt.v1.runtime.MonitoredWorkerFactory.MonitoredBoltWorker) Monitors(org.neo4j.kernel.monitoring.Monitors) Test(org.junit.Test)

Example 49 with Monitors

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

the class ShortestPath method resolveMonitor.

private void resolveMonitor(Node node) {
    if (dataMonitor == null) {
        GraphDatabaseService service = node.getGraphDatabase();
        if (service instanceof GraphDatabaseFacade) {
            Monitors monitors = ((GraphDatabaseFacade) service).getDependencyResolver().resolveDependency(Monitors.class);
            dataMonitor = monitors.newMonitor(DataMonitor.class);
        }
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Monitors(org.neo4j.kernel.monitoring.Monitors) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade)

Example 50 with Monitors

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

the class BackupImplTest method flushStoreFilesWithCorrectCheckpointTriggerName.

@Test
public void flushStoreFilesWithCorrectCheckpointTriggerName() {
    StoreCopyServer storeCopyServer = mock(StoreCopyServer.class);
    when(storeCopyServer.flushStoresAndStreamStoreFiles(anyString(), any(StoreWriter.class), anyBoolean())).thenReturn(RequestContext.EMPTY);
    BackupImpl backup = new BackupImpl(storeCopyServer, new Monitors(), mock(LogicalTransactionStore.class), mock(TransactionIdStore.class), mock(LogFileInformation.class), defaultStoreIdSupplier(), NullLogProvider.getInstance());
    backup.fullBackup(mock(StoreWriter.class), false).close();
    verify(storeCopyServer).flushStoresAndStreamStoreFiles(eq(BackupImpl.FULL_BACKUP_CHECKPOINT_TRIGGER), any(StoreWriter.class), eq(false));
}
Also used : StoreCopyServer(org.neo4j.com.storecopy.StoreCopyServer) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) StoreWriter(org.neo4j.com.storecopy.StoreWriter) LogFileInformation(org.neo4j.kernel.impl.transaction.log.LogFileInformation) Monitors(org.neo4j.kernel.monitoring.Monitors) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) Test(org.junit.Test)

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