Search in sources :

Example 1 with CHECK_TYPES

use of org.neo4j.tools.txlog.checktypes.CheckTypes.CHECK_TYPES in project neo4j by neo4j.

the class CheckTxLogsTest method shouldReportNoInconsistenciesIfTxIdSequenceIsStriclyIncreasingAndHasNoGaps.

@Test
public void shouldReportNoInconsistenciesIfTxIdSequenceIsStriclyIncreasingAndHasNoGaps() throws Exception {
    // given
    Function<Long, Command.NodeCommand> newNodeCommandFunction = (i) -> new Command.NodeCommand(new NodeRecord(i, false, false, -1, -1, -1), new NodeRecord(i, true, false, -1, -1, -1));
    writeTxContent(logFile(1), 40L, newNodeCommandFunction.apply(1L));
    writeTxContent(logFile(1), 41L, newNodeCommandFunction.apply(2L));
    writeTxContent(logFile(1), 42L, newNodeCommandFunction.apply(3L));
    writeTxContent(logFile(2), 43L, newNodeCommandFunction.apply(4L));
    writeTxContent(logFile(2), 44L, newNodeCommandFunction.apply(5L));
    writeTxContent(logFile(2), 45L, newNodeCommandFunction.apply(6L));
    CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
    CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
    // when
    checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, CHECK_TYPES);
    // then
    assertTrue(handler.txIdSequenceInconsistencies.isEmpty());
}
Also used : Arrays(java.util.Arrays) PropertyType(org.neo4j.kernel.impl.store.PropertyType) PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) CheckTypes(org.neo4j.tools.txlog.checktypes.CheckTypes) PROPERTY(org.neo4j.tools.txlog.checktypes.CheckTypes.PROPERTY) Function(java.util.function.Function) ArrayList(java.util.ArrayList) NEO_STORE(org.neo4j.tools.txlog.checktypes.CheckTypes.NEO_STORE) Assert.assertThat(org.junit.Assert.assertThat) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Command(org.neo4j.kernel.impl.transaction.command.Command) StoreChannel(org.neo4j.io.fs.StoreChannel) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) RELATIONSHIP_GROUP(org.neo4j.tools.txlog.checktypes.CheckTypes.RELATIONSHIP_GROUP) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ThrowingConsumer(org.neo4j.function.ThrowingConsumer) Matchers.lessThan(org.hamcrest.Matchers.lessThan) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) CHECK_TYPES(org.neo4j.tools.txlog.checktypes.CheckTypes.CHECK_TYPES) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) LogHeaderWriter(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) List(java.util.List) Rule(org.junit.Rule) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RELATIONSHIP(org.neo4j.tools.txlog.checktypes.CheckTypes.RELATIONSHIP) Assert.assertFalse(org.junit.Assert.assertFalse) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) LOG_HEADER_SIZE(org.neo4j.kernel.impl.transaction.log.entry.LogHeader.LOG_HEADER_SIZE) NODE(org.neo4j.tools.txlog.checktypes.CheckTypes.NODE) NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) TransactionLogWriter(org.neo4j.kernel.impl.transaction.log.TransactionLogWriter) SuppressOutput(org.neo4j.test.rule.SuppressOutput) Assert.assertEquals(org.junit.Assert.assertEquals) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Example 2 with CHECK_TYPES

use of org.neo4j.tools.txlog.checktypes.CheckTypes.CHECK_TYPES in project neo4j by neo4j.

the class CheckTxLogsTest method shouldReportAnInconsistencyIfTxIdSequenceHasGaps.

@Test
public void shouldReportAnInconsistencyIfTxIdSequenceHasGaps() throws Exception {
    // given
    Function<Long, Command.NodeCommand> newNodeCommandFunction = (i) -> new Command.NodeCommand(new NodeRecord(i, false, false, -1, -1, -1), new NodeRecord(i, true, false, -1, -1, -1));
    writeTxContent(logFile(1), 40L, newNodeCommandFunction.apply(1L));
    writeTxContent(logFile(1), 41L, newNodeCommandFunction.apply(2L));
    writeTxContent(logFile(1), 42L, newNodeCommandFunction.apply(3L));
    writeTxContent(logFile(2), 44L, newNodeCommandFunction.apply(4L));
    writeTxContent(logFile(2), 45L, newNodeCommandFunction.apply(5L));
    CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
    CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
    // when
    checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, CHECK_TYPES);
    // then
    System.out.println(handler.txIdSequenceInconsistencies);
    assertEquals(1, handler.txIdSequenceInconsistencies.size());
    assertEquals(42, handler.txIdSequenceInconsistencies.get(0).lastSeenTxId);
    assertEquals(44, handler.txIdSequenceInconsistencies.get(0).currentTxId);
}
Also used : Arrays(java.util.Arrays) PropertyType(org.neo4j.kernel.impl.store.PropertyType) PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) CheckTypes(org.neo4j.tools.txlog.checktypes.CheckTypes) PROPERTY(org.neo4j.tools.txlog.checktypes.CheckTypes.PROPERTY) Function(java.util.function.Function) ArrayList(java.util.ArrayList) NEO_STORE(org.neo4j.tools.txlog.checktypes.CheckTypes.NEO_STORE) Assert.assertThat(org.junit.Assert.assertThat) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Command(org.neo4j.kernel.impl.transaction.command.Command) StoreChannel(org.neo4j.io.fs.StoreChannel) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) RELATIONSHIP_GROUP(org.neo4j.tools.txlog.checktypes.CheckTypes.RELATIONSHIP_GROUP) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ThrowingConsumer(org.neo4j.function.ThrowingConsumer) Matchers.lessThan(org.hamcrest.Matchers.lessThan) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) CHECK_TYPES(org.neo4j.tools.txlog.checktypes.CheckTypes.CHECK_TYPES) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) LogHeaderWriter(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) List(java.util.List) Rule(org.junit.Rule) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RELATIONSHIP(org.neo4j.tools.txlog.checktypes.CheckTypes.RELATIONSHIP) Assert.assertFalse(org.junit.Assert.assertFalse) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) LOG_HEADER_SIZE(org.neo4j.kernel.impl.transaction.log.entry.LogHeader.LOG_HEADER_SIZE) NODE(org.neo4j.tools.txlog.checktypes.CheckTypes.NODE) NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) TransactionLogWriter(org.neo4j.kernel.impl.transaction.log.TransactionLogWriter) SuppressOutput(org.neo4j.test.rule.SuppressOutput) Assert.assertEquals(org.junit.Assert.assertEquals) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Example 3 with CHECK_TYPES

use of org.neo4j.tools.txlog.checktypes.CheckTypes.CHECK_TYPES in project neo4j by neo4j.

the class CheckTxLogsTest method shouldReportAnInconsistencyIfTxIdSequenceIsNotStrictlyIncreasing.

@Test
public void shouldReportAnInconsistencyIfTxIdSequenceIsNotStrictlyIncreasing() throws Exception {
    // given
    Function<Long, Command.NodeCommand> newNodeCommandFunction = (i) -> new Command.NodeCommand(new NodeRecord(i, false, false, -1, -1, -1), new NodeRecord(i, true, false, -1, -1, -1));
    writeTxContent(logFile(1), 40L, newNodeCommandFunction.apply(1L));
    writeTxContent(logFile(1), 41L, newNodeCommandFunction.apply(2L));
    writeTxContent(logFile(1), 42L, newNodeCommandFunction.apply(3L));
    writeTxContent(logFile(2), 42L, newNodeCommandFunction.apply(4L));
    writeTxContent(logFile(2), 43L, newNodeCommandFunction.apply(5L));
    CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
    CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
    // when
    checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, CHECK_TYPES);
    // then
    assertEquals(1, handler.txIdSequenceInconsistencies.size());
    assertEquals(42, handler.txIdSequenceInconsistencies.get(0).lastSeenTxId);
    assertEquals(42, handler.txIdSequenceInconsistencies.get(0).currentTxId);
}
Also used : Arrays(java.util.Arrays) PropertyType(org.neo4j.kernel.impl.store.PropertyType) PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) CheckTypes(org.neo4j.tools.txlog.checktypes.CheckTypes) PROPERTY(org.neo4j.tools.txlog.checktypes.CheckTypes.PROPERTY) Function(java.util.function.Function) ArrayList(java.util.ArrayList) NEO_STORE(org.neo4j.tools.txlog.checktypes.CheckTypes.NEO_STORE) Assert.assertThat(org.junit.Assert.assertThat) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Command(org.neo4j.kernel.impl.transaction.command.Command) StoreChannel(org.neo4j.io.fs.StoreChannel) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) RELATIONSHIP_GROUP(org.neo4j.tools.txlog.checktypes.CheckTypes.RELATIONSHIP_GROUP) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ThrowingConsumer(org.neo4j.function.ThrowingConsumer) Matchers.lessThan(org.hamcrest.Matchers.lessThan) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) CHECK_TYPES(org.neo4j.tools.txlog.checktypes.CheckTypes.CHECK_TYPES) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) LogHeaderWriter(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) List(java.util.List) Rule(org.junit.Rule) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RELATIONSHIP(org.neo4j.tools.txlog.checktypes.CheckTypes.RELATIONSHIP) Assert.assertFalse(org.junit.Assert.assertFalse) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) LOG_HEADER_SIZE(org.neo4j.kernel.impl.transaction.log.entry.LogHeader.LOG_HEADER_SIZE) NODE(org.neo4j.tools.txlog.checktypes.CheckTypes.NODE) NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) TransactionLogWriter(org.neo4j.kernel.impl.transaction.log.TransactionLogWriter) SuppressOutput(org.neo4j.test.rule.SuppressOutput) Assert.assertEquals(org.junit.Assert.assertEquals) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Aggregations

File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3 List (java.util.List)3 Function (java.util.function.Function)3 Matchers.lessThan (org.hamcrest.Matchers.lessThan)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertFalse (org.junit.Assert.assertFalse)3 Assert.assertThat (org.junit.Assert.assertThat)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Rule (org.junit.Rule)3 Test (org.junit.Test)3 ThrowingConsumer (org.neo4j.function.ThrowingConsumer)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)3 StoreChannel (org.neo4j.io.fs.StoreChannel)3 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)3 PropertyType (org.neo4j.kernel.impl.store.PropertyType)3 NeoStoreRecord (org.neo4j.kernel.impl.store.record.NeoStoreRecord)3 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)3