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();
}
}
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());
}
}
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);
}
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);
}
}
}
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));
}
Aggregations