use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class BackupService method incrementalWithContext.
/**
* Performs an incremental backup based off the given context. This means
* receiving and applying selectively (i.e. irrespective of the actual state
* of the target db) a set of transactions starting at the desired txId and
* spanning up to the latest of the master
*
* @param targetDb The database that contains a previous full copy
* @param context The context, containing transaction id to start streaming transaction from
* @return A backup context, ready to perform
*/
private BackupOutcome incrementalWithContext(String sourceHostNameOrIp, int sourcePort, GraphDatabaseAPI targetDb, long timeout, RequestContext context) throws IncrementalBackupNotPossibleException {
DependencyResolver resolver = targetDb.getDependencyResolver();
ProgressTxHandler handler = new ProgressTxHandler();
TransactionCommittingResponseUnpacker unpacker = new TransactionCommittingResponseUnpacker(resolver, DEFAULT_BATCH_SIZE, 0);
Monitors monitors = resolver.resolveDependency(Monitors.class);
LogProvider logProvider = resolver.resolveDependency(LogService.class).getInternalLogProvider();
BackupClient client = new BackupClient(sourceHostNameOrIp, sourcePort, null, logProvider, targetDb.storeId(), timeout, unpacker, monitors.newMonitor(ByteCounterMonitor.class, BackupClient.class), monitors.newMonitor(RequestMonitor.class, BackupClient.class), new VersionAwareLogEntryReader<>());
try (Lifespan lifespan = new Lifespan(unpacker, client)) {
try (Response<Void> response = client.incrementalBackup(context)) {
unpacker.unpackResponse(response, handler);
}
} catch (MismatchingStoreIdException e) {
throw new RuntimeException(DIFFERENT_STORE, e);
} catch (RuntimeException | IOException e) {
if (e.getCause() != null && e.getCause() instanceof MissingLogDataException) {
throw new IncrementalBackupNotPossibleException(TOO_OLD_BACKUP, e.getCause());
}
if (e.getCause() != null && e.getCause() instanceof ConnectException) {
throw new RuntimeException(e.getMessage(), e.getCause());
}
throw new RuntimeException("Failed to perform incremental backup.", e);
} catch (Throwable throwable) {
throw new RuntimeException("Unexpected error", throwable);
}
return new BackupOutcome(handler.getLastSeenTransactionId(), true);
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class HazelcastClientTest method shouldReturnEmptyTopologyIfUnableToConnectToHazelcast.
@Test
public void shouldReturnEmptyTopologyIfUnableToConnectToHazelcast() throws Throwable {
// given
HazelcastConnector connector = mock(HazelcastConnector.class);
LogProvider logProvider = mock(LogProvider.class);
Log log = mock(Log.class);
when(logProvider.getLog(any(Class.class))).thenReturn(log);
HazelcastInstance hazelcastInstance = mock(HazelcastInstance.class);
when(connector.connectToHazelcast()).thenThrow(new IllegalStateException());
when(hazelcastInstance.getAtomicReference(anyString())).thenReturn(mock(IAtomicReference.class));
when(hazelcastInstance.getSet(anyString())).thenReturn(new HazelcastSet());
OnDemandJobScheduler jobScheduler = new OnDemandJobScheduler();
HazelcastClient client = new HazelcastClient(connector, jobScheduler, logProvider, config(), myself);
com.hazelcast.core.Cluster cluster = mock(Cluster.class);
when(hazelcastInstance.getCluster()).thenReturn(cluster);
Set<Member> members = asSet(makeMember(1), makeMember(2));
when(cluster.getMembers()).thenReturn(members);
// when
client.start();
jobScheduler.runJob();
CoreTopology topology = client.coreServers();
assertEquals(0, topology.members().size());
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class StoreMigratorFrom20IT method shouldMigrate.
@Test
public void shouldMigrate() throws IOException, ConsistencyCheckIncompleteException {
// WHEN
StoreMigrator storeMigrator = new StoreMigrator(fs, pageCache, getConfig(), NullLogService.getInstance(), schemaIndexProvider);
SchemaIndexMigrator indexMigrator = new SchemaIndexMigrator(fs, schemaIndexProvider, labelScanStoreProvider);
upgrader(indexMigrator, storeMigrator).migrateIfNeeded(find20FormatStoreDirectory(storeDir.directory()));
// THEN
assertEquals(2, monitor.progresses().size());
assertTrue(monitor.isStarted());
assertTrue(monitor.isFinished());
GraphDatabaseService database = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir.absolutePath()).newGraphDatabase();
try {
verifyDatabaseContents(database);
} finally {
// CLEANUP
database.shutdown();
}
LogProvider logProvider = NullLogProvider.getInstance();
StoreFactory storeFactory = new StoreFactory(storeDir.directory(), pageCache, fs, logProvider);
try (NeoStores neoStores = storeFactory.openAllNeoStores(true)) {
verifyNeoStore(neoStores);
}
assertConsistentStore(storeDir.directory());
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class LuceneLabelScanStoreExtension method newInstance.
@Override
public LabelScanStoreProvider newInstance(KernelContext context, Dependencies dependencies) throws Throwable {
Config config = dependencies.getConfig();
boolean ephemeral = config.get(GraphDatabaseFacadeFactory.Configuration.ephemeral);
FileSystemAbstraction fileSystem = dependencies.fileSystem();
DirectoryFactory directoryFactory = directoryFactory(ephemeral, fileSystem);
LuceneLabelScanIndexBuilder indexBuilder = getIndexBuilder(context, directoryFactory, fileSystem, config);
LogProvider logger = dependencies.getLogService().getInternalLogProvider();
Monitor loggingMonitor = new LoggingMonitor(logger.getLog(LuceneLabelScanStore.class), monitor);
LuceneLabelScanStore scanStore = new LuceneLabelScanStore(indexBuilder, new FullLabelStream(dependencies.indexStoreView()), loggingMonitor);
return new LabelScanStoreProvider(NAME, scanStore);
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class ServerBootstrapper method start.
@Override
@SafeVarargs
public final int start(File homeDir, Optional<File> configFile, Pair<String, String>... configOverrides) {
addShutdownHook();
try {
Config config = createConfig(homeDir, configFile, configOverrides);
LogProvider userLogProvider = setupLogging(config);
dependencies = dependencies.userLogProvider(userLogProvider);
log = userLogProvider.getLog(getClass());
config.setLogger(log);
serverAddress = config.httpConnectors().stream().filter(c -> Encryption.NONE.equals(c.encryptionLevel())).findFirst().map((connector) -> config.get(connector.listen_address).toString()).orElse(serverAddress);
checkCompatibility();
server = createNeoServer(config, dependencies, userLogProvider);
server.start();
return OK;
} catch (ServerStartupException e) {
e.describeTo(log);
return WEB_SERVER_STARTUP_ERROR_CODE;
} catch (TransactionFailureException tfe) {
String locationMsg = (server == null) ? "" : " Another process may be using database location " + server.getDatabase().getLocation();
log.error(format("Failed to start Neo4j on %s.", serverAddress) + locationMsg, tfe);
return GRAPH_DATABASE_STARTUP_ERROR_CODE;
} catch (Exception e) {
log.error(format("Failed to start Neo4j on %s.", serverAddress), e);
return WEB_SERVER_STARTUP_ERROR_CODE;
}
}
Aggregations