use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.
the class StoreMigratorTest method shouldExtractTransactionInformationFromLegacyLogsWhenCantFindInStore.
@Test
public void shouldExtractTransactionInformationFromLegacyLogsWhenCantFindInStore() throws Exception {
// given
// ... variables
long txId = 42;
long checksum = 123456789123456789L;
long timestamp = 919191919191919191L;
TransactionId expected = new TransactionId(txId, checksum, timestamp);
// ... and files
PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
File storeDir = directory.graphDbDir();
File neoStore = new File(storeDir, DEFAULT_NAME);
neoStore.createNewFile();
// ... and mocks
Config config = mock(Config.class);
LogService logService = mock(LogService.class);
LegacyLogs legacyLogs = mock(LegacyLogs.class);
when(legacyLogs.getTransactionInformation(storeDir, txId)).thenReturn(Optional.of(expected));
// when
// ... neoStore is empty and with migrator
StoreMigrator migrator = new StoreMigrator(fileSystemRule.get(), pageCache, config, logService, schemaIndexProvider, legacyLogs);
TransactionId actual = migrator.extractTransactionIdInformation(neoStore, storeDir, txId);
// then
assertEquals(expected, actual);
}
use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.
the class MonitorLoggingExtensionFactory method newInstance.
@Override
public Lifecycle newInstance(KernelContext context, Dependencies dependencies) throws Throwable {
LogService logService = dependencies.getLogService();
Properties props = loadProperties(logService);
return new MonitorLoggingExtension(props, logService, dependencies.getMonitors());
}
use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.
the class StoreUpgraderInterruptionTestIT method shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration.
@Test
public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration() throws IOException, ConsistencyCheckIncompleteException {
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, workingDirectory, prepareDirectory);
PageCache pageCache = pageCacheRule.getPageCache(fs);
StoreVersionCheck check = new StoreVersionCheck(pageCache);
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, check, new LegacyStoreVersionCheck(fs), Standard.LATEST_RECORD_FORMATS);
SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
LogService logService = NullLogService.getInstance();
StoreMigrator failingStoreMigrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider) {
@Override
public void migrate(File sourceStoreDir, File targetStoreDir, MigrationProgressMonitor.Section progressMonitor, String versionToMigrateFrom, String versionToMigrateTo) throws IOException {
super.migrate(sourceStoreDir, targetStoreDir, progressMonitor, versionToMigrateFrom, versionToMigrateTo);
throw new RuntimeException("This upgrade is failing");
}
};
assertEquals(!StandardV2_3.STORE_VERSION.equals(version), allLegacyStoreFilesHaveVersion(fs, workingDirectory, version));
try {
newUpgrader(upgradableDatabase, pageCache, progressMonitor, createIndexMigrator(), failingStoreMigrator).migrateIfNeeded(workingDirectory);
fail("Should throw exception");
} catch (RuntimeException e) {
assertEquals("This upgrade is failing", e.getMessage());
}
assertEquals(!StandardV2_3.STORE_VERSION.equals(version), allLegacyStoreFilesHaveVersion(fs, workingDirectory, version));
progressMonitor = new SilentMigrationProgressMonitor();
StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
SchemaIndexMigrator indexMigrator = createIndexMigrator();
newUpgrader(upgradableDatabase, pageCache, progressMonitor, indexMigrator, migrator).migrateIfNeeded(workingDirectory);
assertTrue(checkNeoStoreHasDefaultFormatVersion(check, workingDirectory));
assertTrue(allStoreFilesHaveNoTrailer(fs, workingDirectory));
// Since consistency checker is in read only mode we need to start/stop db to generate label scan store.
startStopDatabase(workingDirectory);
assertConsistentStore(workingDirectory);
}
Aggregations