Search in sources :

Example 51 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class CoreReplicatedContentMarshalTest method shouldMarshalTokenRequest.

@Test
public void shouldMarshalTokenRequest() throws Exception {
    ByteBuf buffer = Unpooled.buffer();
    ArrayList<StorageCommand> commands = new ArrayList<>();
    LabelTokenRecord before = new LabelTokenRecord(0);
    LabelTokenRecord after = new LabelTokenRecord(0);
    after.setInUse(true);
    after.setCreated();
    after.setNameId(3232);
    commands.add(new Command.LabelTokenCommand(before, after));
    ReplicatedContent message = new ReplicatedTokenRequest(TokenType.LABEL, "theLabel", ReplicatedTokenRequestSerializer.commandBytes(commands));
    assertMarshalingEquality(buffer, message);
}
Also used : ReplicatedTokenRequest(org.neo4j.causalclustering.core.state.machines.token.ReplicatedTokenRequest) StorageCommand(org.neo4j.storageengine.api.StorageCommand) Command(org.neo4j.kernel.impl.transaction.command.Command) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) NetworkFlushableByteBuf(org.neo4j.causalclustering.messaging.NetworkFlushableByteBuf) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) Test(org.junit.Test)

Example 52 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class ProtocolTest method justOneNode.

private Collection<StorageCommand> justOneNode() {
    NodeRecord node = new NodeRecord(0);
    node.setInUse(true);
    return Arrays.<StorageCommand>asList(new NodeCommand(new NodeRecord(node.getId()), node));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) StorageCommand(org.neo4j.storageengine.api.StorageCommand) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)

Example 53 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class PhysicalLogCommandReadersTest method assertCanReadRelGroup.

private void assertCanReadRelGroup(CommandReader reader) throws IOException {
    StorageCommand command = reader.read(channelWithRelGroupRecord());
    assertValidRelGroupCommand(command);
}
Also used : StorageCommand(org.neo4j.storageengine.api.StorageCommand)

Example 54 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class TransactionRecordStateTest method transaction.

private TransactionRepresentation transaction(TransactionRecordState recordState) throws TransactionFailureException {
    List<StorageCommand> commands = new ArrayList<>();
    recordState.extractCommands(commands);
    PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(commands);
    transaction.setHeader(new byte[0], 0, 0, 0, 0, 0, 0);
    return transaction;
}
Also used : StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)

Example 55 with StorageCommand

use of org.neo4j.storageengine.api.StorageCommand in project neo4j by neo4j.

the class TransactionRecordStateTest method shouldPrepareRelevantRecords.

@Test
public void shouldPrepareRelevantRecords() throws Exception {
    // GIVEN
    PrepareTrackingRecordFormats format = new PrepareTrackingRecordFormats(Standard.LATEST_RECORD_FORMATS);
    NeoStores neoStores = neoStoresRule.open(format, GraphDatabaseSettings.dense_node_threshold.name(), "1");
    // WHEN
    TransactionRecordState state = newTransactionRecordState(neoStores);
    state.nodeCreate(0);
    state.relCreate(0, 0, 0, 0);
    state.relCreate(1, 0, 0, 0);
    state.relCreate(2, 0, 0, 0);
    List<StorageCommand> commands = new ArrayList<>();
    state.extractCommands(commands);
    // THEN
    int nodes = 0, rels = 0, groups = 0;
    for (StorageCommand command : commands) {
        if (command instanceof NodeCommand) {
            assertTrue(format.node().prepared(((NodeCommand) command).getAfter()));
            nodes++;
        } else if (command instanceof RelationshipCommand) {
            assertTrue(format.relationship().prepared(((RelationshipCommand) command).getAfter()));
            rels++;
        } else if (command instanceof RelationshipGroupCommand) {
            assertTrue(format.relationshipGroup().prepared(((RelationshipGroupCommand) command).getAfter()));
            groups++;
        }
    }
    assertEquals(1, nodes);
    assertEquals(3, rels);
    assertEquals(1, groups);
}
Also used : NeoStores(org.neo4j.kernel.impl.store.NeoStores) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) RelationshipGroupCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand) RelationshipCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipCommand) NodeCommand(org.neo4j.kernel.impl.transaction.command.Command.NodeCommand) Test(org.junit.Test)

Aggregations

StorageCommand (org.neo4j.storageengine.api.StorageCommand)77 ArrayList (java.util.ArrayList)39 Test (org.junit.jupiter.api.Test)34 CommandReader (org.neo4j.storageengine.api.CommandReader)23 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)22 RepeatedTest (org.junit.jupiter.api.RepeatedTest)19 PhysicalTransactionRepresentation (org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)14 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)10 Test (org.junit.Test)10 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)9 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)9 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)8 Command (org.neo4j.kernel.impl.transaction.command.Command)7 NodeCommand (org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)7 LogEntryCommand (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand)7 SchemaRuleCommand (org.neo4j.internal.recordstorage.Command.SchemaRuleCommand)6 NeoStores (org.neo4j.kernel.impl.store.NeoStores)6 IOException (java.io.IOException)5 PropertyCommand (org.neo4j.internal.recordstorage.Command.PropertyCommand)5 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)5