Search in sources :

Example 41 with RelationshipGroupRecord

use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.

the class CheckTxLogsTest method shouldReportRelationshipGroupInconsistenciesFromDifferentLogs.

@Test
public void shouldReportRelationshipGroupInconsistenciesFromDifferentLogs() throws IOException {
    // Given
    File log1 = logFile(1);
    File log2 = logFile(2);
    File log3 = logFile(3);
    writeTxContent(log1, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, -1, -1, -1, -1, -1, -1, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(21, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(21, -1, -1, -1, -1, -1, -1, false)));
    writeTxContent(log2, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 9, 5, 6, true), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)));
    writeTxContent(log3, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(53, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(53, 1, 2, 30, 4, 14, 6, true)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, false)));
    CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
    CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
    // When
    checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, RELATIONSHIP_GROUP);
    // Then
    assertEquals(2, handler.recordInconsistencies.size());
    RelationshipGroupRecord seenRecord1 = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).committed.record();
    RelationshipGroupRecord currentRecord1 = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).current.record();
    assertEquals(42, seenRecord1.getId());
    assertEquals(4, seenRecord1.getFirstLoop());
    assertEquals(42, currentRecord1.getId());
    assertEquals(9, currentRecord1.getFirstLoop());
    RelationshipGroupRecord seenRecord2 = (RelationshipGroupRecord) handler.recordInconsistencies.get(1).committed.record();
    RelationshipGroupRecord currentRecord2 = (RelationshipGroupRecord) handler.recordInconsistencies.get(1).current.record();
    assertEquals(42, seenRecord2.getId());
    assertTrue(seenRecord2.inUse());
    assertEquals(42, currentRecord2.getId());
    assertFalse(currentRecord2.inUse());
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Example 42 with RelationshipGroupRecord

use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.

the class CheckTxLogsTest method shouldReportRelationshipGroupInconsistenciesFromSingleLog.

@Test
public void shouldReportRelationshipGroupInconsistenciesFromSingleLog() throws IOException {
    // Given
    File log = logFile(1);
    writeTxContent(log, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, -1, -1, -1, -1, -1, -1, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(21, 1, 2, 3, 4, 5, 7, true), new RelationshipGroupRecord(21, -1, -1, -1, -1, -1, -1, false)));
    writeTxContent(log, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(53, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(53, 1, 2, 30, 4, 14, 6, true)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 9, 5, 6, true), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)));
    CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
    CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
    // When
    checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, RELATIONSHIP_GROUP);
    // Then
    assertEquals(1, handler.recordInconsistencies.size());
    RelationshipGroupRecord seenRecord = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).committed.record();
    RelationshipGroupRecord currentRecord = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).current.record();
    assertEquals(42, seenRecord.getId());
    assertEquals(4, seenRecord.getFirstLoop());
    assertEquals(42, currentRecord.getId());
    assertEquals(9, currentRecord.getFirstLoop());
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Example 43 with RelationshipGroupRecord

use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.

the class RelationshipGroupCheckTypeTest method inUseRecordEquality.

@Test
public void inUseRecordEquality() {
    RelationshipGroupRecord record1 = new RelationshipGroupRecord(1);
    record1.initialize(true, 1, 2, 3, 4, 5, 6);
    record1.setSecondaryUnitId(42);
    RelationshipGroupRecord record2 = record1.clone();
    RelationshipGroupCheckType check = new RelationshipGroupCheckType();
    assertTrue(check.equal(record1, record2));
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Test(org.junit.Test)

Example 44 with RelationshipGroupRecord

use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.

the class PhysicalLogCommandReaderV2_1 method visitRelationshipGroupCommand.

private Command visitRelationshipGroupCommand(ReadableChannel channel) throws IOException {
    long id = channel.getLong();
    byte inUseByte = channel.get();
    boolean inUse = inUseByte == Record.IN_USE.byteValue();
    if (inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue()) {
        throw new IOException("Illegal in use flag: " + inUseByte);
    }
    int type = shortToUnsignedInt(channel.getShort());
    RelationshipGroupRecord record = new RelationshipGroupRecord(id, type);
    record.setInUse(inUse);
    record.setNext(channel.getLong());
    record.setFirstOut(channel.getLong());
    record.setFirstIn(channel.getLong());
    record.setFirstLoop(channel.getLong());
    record.setOwningNode(channel.getLong());
    return new Command.RelationshipGroupCommand(null, record);
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) IOException(java.io.IOException)

Example 45 with RelationshipGroupRecord

use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.

the class Loaders method relationshipGroupLoader.

public static Loader<Long, RelationshipGroupRecord, Integer> relationshipGroupLoader(final RecordStore<RelationshipGroupRecord> store) {
    return new Loader<Long, RelationshipGroupRecord, Integer>() {

        @Override
        public RelationshipGroupRecord newUnused(Long key, Integer type) {
            RelationshipGroupRecord record = new RelationshipGroupRecord(key);
            record.setType(type);
            return andMarkAsCreated(record);
        }

        @Override
        public RelationshipGroupRecord load(Long key, Integer type) {
            return store.getRecord(key, store.newRecord(), NORMAL);
        }

        @Override
        public void ensureHeavy(RelationshipGroupRecord record) {
        // Not needed
        }

        @Override
        public RelationshipGroupRecord clone(RelationshipGroupRecord record) {
            return record.clone();
        }
    };
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Loader(org.neo4j.kernel.impl.transaction.state.RecordAccess.Loader)

Aggregations

RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)83 Test (org.junit.Test)42 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)24 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)11 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)11 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)11 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)11 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)10 Command (org.neo4j.kernel.impl.transaction.command.Command)5 IOException (java.io.IOException)4 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)4 File (java.io.File)3 Node (org.neo4j.graphdb.Node)3 Relationship (org.neo4j.graphdb.Relationship)3 Transaction (org.neo4j.graphdb.Transaction)3 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)3 NeoStores (org.neo4j.kernel.impl.store.NeoStores)3 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)3 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)3 RelationshipGroupCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand)3