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)));
}
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());
}
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());
}
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);
}
use of org.neo4j.kernel.impl.logging.LogService in project neo4j by neo4j.
the class NonUniqueIndexTests method newEmbeddedGraphDatabaseWithSlowJobScheduler.
private GraphDatabaseService newEmbeddedGraphDatabaseWithSlowJobScheduler() {
GraphDatabaseFactoryState graphDatabaseFactoryState = new GraphDatabaseFactoryState();
graphDatabaseFactoryState.setUserLogProvider(NullLogService.getInstance().getUserLogProvider());
return new GraphDatabaseFacadeFactory(DatabaseInfo.COMMUNITY, CommunityEditionModule::new) {
@Override
protected PlatformModule createPlatform(File storeDir, Config config, Dependencies dependencies, GraphDatabaseFacade graphDatabaseFacade) {
return new PlatformModule(storeDir, config, databaseInfo, dependencies, graphDatabaseFacade) {
@Override
protected Neo4jJobScheduler createJobScheduler() {
return newSlowJobScheduler();
}
@Override
protected LogService createLogService(LogProvider userLogProvider) {
return NullLogService.getInstance();
}
};
}
}.newFacade(directory.graphDbDir(), Config.embeddedDefaults(), graphDatabaseFactoryState.databaseDependencies());
}
Aggregations