Search in sources :

Example 1 with LogService

use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.

the class StoreMigratorIT method shouldComputeTheLastTxInfoCorrectly.

@Test
public void shouldComputeTheLastTxInfoCorrectly() throws Exception {
    // given
    File storeDirectory = directory.graphDbDir();
    File prepare = directory.directory("prepare");
    MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, storeDirectory, prepare);
    // and a state of the migration saying that it has done the actual migration
    LogService logService = NullLogService.getInstance();
    PageCache pageCache = pageCacheRule.getPageCache(fs);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), selectFormat());
    String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(storeDirectory).storeVersion();
    SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
    StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
    File migrationDir = new File(storeDirectory, StoreUpgrader.MIGRATION_DIRECTORY);
    fs.mkdir(migrationDir);
    // when
    migrator.migrate(storeDirectory, migrationDir, progressMonitor.startSection("section"), versionToMigrateFrom, upgradableDatabase.currentVersion());
    // then
    assertTrue(txIdComparator.apply(migrator.readLastTxInformation(migrationDir)));
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) File(java.io.File) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 2 with LogService

use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.

the class StoreMigratorTest method shouldGenerateTransactionInformationWhenLogsAreEmpty.

@Test
public void shouldGenerateTransactionInformationWhenLogsAreEmpty() throws Exception {
    // given
    long txId = 1;
    PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
    File storeDir = directory.graphDbDir();
    File neoStore = new File(storeDir, DEFAULT_NAME);
    neoStore.createNewFile();
    Config config = mock(Config.class);
    LogService logService = new SimpleLogService(NullLogProvider.getInstance(), NullLogProvider.getInstance());
    LegacyLogs legacyLogs = mock(LegacyLogs.class);
    // when
    // ... transaction info not in neo store
    assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_ID));
    assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_CHECKSUM));
    assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP));
    // ... and transaction not in log
    when(legacyLogs.getTransactionInformation(storeDir, txId)).thenReturn(Optional.empty());
    // ... and with migrator
    StoreMigrator migrator = new StoreMigrator(fileSystemRule.get(), pageCache, config, logService, schemaIndexProvider);
    TransactionId actual = migrator.extractTransactionIdInformation(neoStore, storeDir, txId);
    // then
    assertEquals(txId, actual.transactionId());
    assertEquals(TransactionIdStore.BASE_TX_CHECKSUM, actual.checksum());
    assertEquals(TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP, actual.commitTimestamp());
}
Also used : SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) 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 3 with LogService

use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.

the class StoreMigratorTest method shouldGenerateTransactionInformationWhenLogsNotPresent.

@Test
public void shouldGenerateTransactionInformationWhenLogsNotPresent() throws Exception {
    // given
    long txId = 42;
    PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
    File storeDir = directory.graphDbDir();
    File neoStore = new File(storeDir, DEFAULT_NAME);
    neoStore.createNewFile();
    Config config = mock(Config.class);
    LogService logService = new SimpleLogService(NullLogProvider.getInstance(), NullLogProvider.getInstance());
    LegacyLogs legacyLogs = mock(LegacyLogs.class);
    // when
    // ... transaction info not in neo store
    assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_ID));
    assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_CHECKSUM));
    assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP));
    // ... and transaction not in log
    when(legacyLogs.getTransactionInformation(storeDir, txId)).thenReturn(Optional.empty());
    // ... and with migrator
    StoreMigrator migrator = new StoreMigrator(fileSystemRule.get(), pageCache, config, logService, schemaIndexProvider);
    TransactionId actual = migrator.extractTransactionIdInformation(neoStore, storeDir, txId);
    // then
    assertEquals(txId, actual.transactionId());
    assertEquals(TransactionIdStore.UNKNOWN_TX_CHECKSUM, actual.checksum());
    assertEquals(TransactionIdStore.UNKNOWN_TX_COMMIT_TIMESTAMP, actual.commitTimestamp());
}
Also used : SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) 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 4 with LogService

use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.

the class StoreMigratorTest method shouldExtractTransactionInformationFromMetaDataStore.

@Test
public void shouldExtractTransactionInformationFromMetaDataStore() 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);
    // when
    // ... data in record
    setRecord(pageCache, neoStore, LAST_TRANSACTION_ID, txId);
    setRecord(pageCache, neoStore, LAST_TRANSACTION_CHECKSUM, checksum);
    setRecord(pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP, timestamp);
    // ... and with migrator
    StoreMigrator migrator = new StoreMigrator(fileSystemRule.get(), pageCache, config, logService, NO_INDEX_PROVIDER);
    TransactionId actual = migrator.extractTransactionIdInformation(neoStore, storeDir, txId);
    // then
    assertEquals(expected, actual);
}
Also used : Config(org.neo4j.kernel.configuration.Config) 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 5 with LogService

use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.

the class EditionModule method setupSecurityModule.

protected static void setupSecurityModule(PlatformModule platformModule, Log log, Procedures procedures, String key) {
    for (SecurityModule candidate : Service.load(SecurityModule.class)) {
        if (candidate.matches(key)) {
            try {
                candidate.setup(new SecurityModule.Dependencies() {

                    @Override
                    public LogService logService() {
                        return platformModule.logging;
                    }

                    @Override
                    public Config config() {
                        return platformModule.config;
                    }

                    @Override
                    public Procedures procedures() {
                        return procedures;
                    }

                    @Override
                    public JobScheduler scheduler() {
                        return platformModule.jobScheduler;
                    }

                    @Override
                    public FileSystemAbstraction fileSystem() {
                        return platformModule.fileSystem;
                    }

                    @Override
                    public LifeSupport lifeSupport() {
                        return platformModule.life;
                    }

                    @Override
                    public DependencySatisfier dependencySatisfier() {
                        return platformModule.dependencies;
                    }
                });
                return;
            } catch (Exception e) {
                String errorMessage = "Failed to load security module.";
                log.error(errorMessage);
                throw new RuntimeException(errorMessage, e);
            }
        }
    }
    String errorMessage = "Failed to load security module with key '" + key + "'.";
    log.error(errorMessage);
    throw new IllegalArgumentException(errorMessage);
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) Procedures(org.neo4j.kernel.impl.proc.Procedures) KernelException(org.neo4j.kernel.api.exceptions.KernelException) SecurityModule(org.neo4j.kernel.api.security.SecurityModule) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DependencySatisfier(org.neo4j.kernel.impl.util.DependencySatisfier) LogService(org.neo4j.kernel.impl.logging.LogService)

Aggregations

LogService (org.neo4j.kernel.impl.logging.LogService)24 File (java.io.File)15 Test (org.junit.Test)12 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 LogProvider (org.neo4j.logging.LogProvider)5 IOException (java.io.IOException)4 LegacyLogs (org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs)4 Monitors (org.neo4j.kernel.monitoring.Monitors)4 NullLogProvider (org.neo4j.logging.NullLogProvider)4 DependencyResolver (org.neo4j.graphdb.DependencyResolver)3 SimpleLogService (org.neo4j.kernel.impl.logging.SimpleLogService)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)3