Search in sources :

Example 1 with LegacyLogs

use of org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs 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 2 with LegacyLogs

use of org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs 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 3 with LegacyLogs

use of org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs 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)

Aggregations

File (java.io.File)3 Test (org.junit.Test)3 PageCache (org.neo4j.io.pagecache.PageCache)3 Config (org.neo4j.kernel.configuration.Config)3 LogService (org.neo4j.kernel.impl.logging.LogService)3 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)3 SimpleLogService (org.neo4j.kernel.impl.logging.SimpleLogService)3 TransactionId (org.neo4j.kernel.impl.store.TransactionId)3 LegacyLogs (org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs)3