use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.
the class InconsistencyReportReaderTest method shouldReadBasicEntities.
@Test
public void shouldReadBasicEntities() throws Exception {
// GIVEN
ByteArrayOutputStream out = new ByteArrayOutputStream(1_000);
FormattedLog log = FormattedLog.toOutputStream(out);
InconsistencyMessageLogger logger = new InconsistencyMessageLogger(log);
long nodeId = 5;
long relationshipGroupId = 10;
long relationshipId = 15;
long propertyId = 20;
logger.error(RecordType.NODE, new NodeRecord(nodeId), "Some error", "something");
logger.error(RecordType.RELATIONSHIP, new RelationshipRecord(relationshipId), "Some error", "something");
logger.error(RecordType.RELATIONSHIP_GROUP, new RelationshipGroupRecord(relationshipGroupId), "Some error", "something");
logger.error(RecordType.PROPERTY, new PropertyRecord(propertyId), "Some error", "something");
String text = out.toString();
PrimitiveLongSet nodes = Primitive.longSet();
PrimitiveLongSet relationships = Primitive.longSet();
PrimitiveLongSet relationshipGroups = Primitive.longSet();
PrimitiveLongSet properties = Primitive.longSet();
// WHEN
InconsistencyReportReader reader = new InconsistencyReportReader(new Inconsistencies() {
@Override
public void relationshipGroup(long id) {
relationshipGroups.add(id);
}
@Override
public void relationship(long id) {
relationships.add(id);
}
@Override
public void property(long id) {
properties.add(id);
}
@Override
public void node(long id) {
nodes.add(id);
}
});
reader.read(new StringReader(text));
// THEN
assertEquals(asSet(iterator(nodeId)), nodes);
assertEquals(asSet(iterator(relationshipId)), relationships);
assertEquals(asSet(iterator(relationshipGroupId)), relationshipGroups);
assertEquals(asSet(iterator(propertyId)), properties);
}
use of org.neo4j.kernel.impl.store.record.NodeRecord 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());
}
use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportNodeInconsistenciesFromDifferentLogs.
@Test
public void shouldReportNodeInconsistenciesFromDifferentLogs() throws IOException {
// Given
File log1 = logFile(1);
File log2 = logFile(2);
File log3 = logFile(3);
writeTxContent(log1, 0, new Command.NodeCommand(new NodeRecord(42, false, false, -1, -1, 1), new NodeRecord(42, true, false, 42, -1, 1)), new Command.PropertyCommand(propertyRecord(5, true, -1, -1, 777), propertyRecord(5, true, -1, -1, 777, 888)), new Command.NodeCommand(new NodeRecord(1, true, true, 2, -1, 1), new NodeRecord(1, true, false, -1, -1, 1)));
writeTxContent(log2, 0, new Command.NodeCommand(new NodeRecord(2, false, false, -1, -1, 1), new NodeRecord(2, true, false, -1, -1, 1)));
writeTxContent(log3, 0, new Command.NodeCommand(new NodeRecord(42, true, true, 42, -1, 1), new NodeRecord(42, true, true, 42, 10, 1)), new Command.NodeCommand(new NodeRecord(2, true, false, -1, -1, 5), new NodeRecord(2, false, false, -1, -1, 5)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
boolean success = checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, NODE);
// Then
assertFalse(success);
assertEquals(2, handler.recordInconsistencies.size());
NodeRecord seenRecord1 = (NodeRecord) handler.recordInconsistencies.get(0).committed.record();
NodeRecord currentRecord1 = (NodeRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(42, seenRecord1.getId());
assertFalse(seenRecord1.isDense());
assertEquals(42, currentRecord1.getId());
assertTrue(currentRecord1.isDense());
NodeRecord seenRecord2 = (NodeRecord) handler.recordInconsistencies.get(1).committed.record();
NodeRecord currentRecord2 = (NodeRecord) handler.recordInconsistencies.get(1).current.record();
assertEquals(2, seenRecord2.getId());
assertEquals(1, seenRecord2.getLabelField());
assertEquals(2, currentRecord2.getId());
assertEquals(5, currentRecord2.getLabelField());
}
use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportTransactionIdAndInconsistencyCount.
@Test
public void shouldReportTransactionIdAndInconsistencyCount() throws IOException {
// Given
File log = logFile(1);
writeTxContent(log, 0, new Command.NodeCommand(new NodeRecord(42, false, false, -1, -1, 1), new NodeRecord(42, true, false, 42, -1, 1)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.NodeCommand(new NodeRecord(1, true, true, 2, -1, 1), new NodeRecord(1, true, false, -1, -1, 1)), new Command.NodeCommand(new NodeRecord(5, true, true, 2, -1, 1), new NodeRecord(5, true, false, -1, -1, 1)));
writeTxContent(log, 1, new Command.NodeCommand(new NodeRecord(2, false, false, -1, -1, 1), new NodeRecord(2, true, false, -1, -1, 1)), new Command.NodeCommand(// inconsistent
new NodeRecord(5, true, true, 2, -1, 1), new NodeRecord(5, true, false, -1, -1, 1)), new Command.NodeCommand(new NodeRecord(1, true, false, -1, -1, 1), new NodeRecord(1, true, true, 2, 1, 1)), new Command.NodeCommand(// inconsistent
new NodeRecord(42, true, false, 24, -1, 1), new NodeRecord(42, true, false, 24, 5, 1)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, NODE);
// Then
assertEquals(2, handler.recordInconsistencies.size());
assertEquals(0, handler.recordInconsistencies.get(0).committed.txId());
assertEquals(1, handler.recordInconsistencies.get(0).current.txId());
assertEquals(0, handler.recordInconsistencies.get(1).committed.txId());
assertEquals(1, handler.recordInconsistencies.get(1).current.txId());
}
use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.
the class NodeCheckTypeTest method notInUseRecordEquality.
@Test
public void notInUseRecordEquality() {
NodeRecord record1 = new NodeRecord(1);
record1.initialize(false, 1, true, 2, 3);
record1.setSecondaryUnitId(42);
NodeRecord record2 = new NodeRecord(1);
record2.initialize(false, 11, true, 22, 33);
record2.setSecondaryUnitId(24);
NodeCheckType check = new NodeCheckType();
assertTrue(check.equal(record1, record2));
}
Aggregations