Search in sources :

Example 21 with LogService

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);
}
Also used : Config(org.neo4j.kernel.configuration.Config) LegacyLogs(org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) TransactionId(org.neo4j.kernel.impl.store.TransactionId) Test(org.junit.Test)

Example 22 with LogService

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());
}
Also used : Properties(java.util.Properties) LogService(org.neo4j.kernel.impl.logging.LogService)

Example 23 with LogService

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);
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) SchemaIndexMigrator(org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) Test(org.junit.Test)

Aggregations

LogService (org.neo4j.kernel.impl.logging.LogService)23 File (java.io.File)16 Test (org.junit.Test)13 PageCache (org.neo4j.io.pagecache.PageCache)12 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)12 Config (org.neo4j.kernel.configuration.Config)10 SilentMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)7 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)6 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)6 LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)6 TransactionId (org.neo4j.kernel.impl.store.TransactionId)5 IOException (java.io.IOException)4 LegacyLogs (org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs)4 LogProvider (org.neo4j.logging.LogProvider)4 SimpleLogService (org.neo4j.kernel.impl.logging.SimpleLogService)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)3 Monitors (org.neo4j.kernel.monitoring.Monitors)3 List (java.util.List)2 Supplier (java.util.function.Supplier)2