use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class OwnerCheckTest method shouldReportNodeStoreReferencingSameChainAsRelationship.
@Test
public void shouldReportNodeStoreReferencingSameChainAsRelationship() throws Exception {
// given
OwnerCheck decorator = new OwnerCheck(true);
RecordCheck<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> relationshipChecker = decorator.decorateRelationshipChecker(dummyRelationshipChecker());
RecordCheck<NeoStoreRecord, ConsistencyReport.NeoStoreConsistencyReport> neoStoreCheck = decorator.decorateNeoStoreChecker(dummyNeoStoreCheck());
RecordAccessStub records = new RecordAccessStub();
NeoStoreRecord master = records.add(new NeoStoreRecord());
master.setNextProp(7);
RelationshipRecord relationship = records.add(inUse(new RelationshipRecord(1, 0, 1, 0)));
relationship.setNextProp(7);
// when
ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
ConsistencyReport.NeoStoreConsistencyReport masterReport = check(ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records);
// then
verifyZeroInteractions(relationshipReport);
verify(masterReport).multipleOwners(relationship);
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class Commands method createRelationship.
public static RelationshipCommand createRelationship(long id, long startNode, long endNode, int type) {
RelationshipRecord before = new RelationshipRecord(id);
before.setInUse(false);
RelationshipRecord after = new RelationshipRecord(id, startNode, endNode, type);
after.setInUse(true);
after.setCreated();
return new RelationshipCommand(before, after);
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord 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.RelationshipRecord in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportRelationshipInconsistenciesFromSingleLog.
@Test
public void shouldReportRelationshipInconsistenciesFromSingleLog() throws IOException {
// Given
File log = logFile(1);
writeTxContent(log, 0, new Command.RelationshipCommand(new RelationshipRecord(42, false, -1, -1, -1, -1, -1, -1, -1, false, false), new RelationshipRecord(42, true, 1, 2, 3, 4, 5, 6, 7, true, true)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.RelationshipCommand(new RelationshipRecord(21, true, 1, 2, 3, 4, 5, 6, 7, true, true), new RelationshipRecord(21, false, -1, -1, -1, -1, -1, -1, -1, false, false)));
writeTxContent(log, 0, new Command.RelationshipCommand(new RelationshipRecord(53, true, 1, 2, 3, 4, 5, 6, 7, true, true), new RelationshipRecord(53, true, 1, 2, 30, 4, 14, 6, 7, true, true)), new Command.RelationshipCommand(new RelationshipRecord(42, true, 1, 2, 3, 9, 5, 6, 7, true, true), new RelationshipRecord(42, true, 1, 2, 3, 4, 5, 6, 7, true, true)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, RELATIONSHIP);
// Then
assertEquals(1, handler.recordInconsistencies.size());
RelationshipRecord seenRecord = (RelationshipRecord) handler.recordInconsistencies.get(0).committed.record();
RelationshipRecord currentRecord = (RelationshipRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(42, seenRecord.getId());
assertEquals(4, seenRecord.getFirstPrevRel());
assertEquals(42, currentRecord.getId());
assertEquals(9, currentRecord.getFirstPrevRel());
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class RelationshipCheckTypeTest method notInUseRecordEquality.
@Test
public void notInUseRecordEquality() {
RelationshipRecord record1 = new RelationshipRecord(1);
record1.initialize(false, 1, 2, 3, 4, 5, 6, 7, 8, true, false);
record1.setSecondaryUnitId(42);
RelationshipRecord record2 = new RelationshipRecord(1);
record2.initialize(false, 11, 22, 33, 44, 55, 66, 77, 88, false, true);
record2.setSecondaryUnitId(24);
RelationshipCheckType check = new RelationshipCheckType();
assertTrue(check.equal(record1, record2));
}
Aggregations