Search in sources :

Example 36 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.

the class LogEntryParserV2_1Test method shouldParseCommandsUsingAGivenFactory.

@Test
public void shouldParseCommandsUsingAGivenFactory() throws IOException {
    // given
    final Command.NodeCommand nodeCommand = new Command.NodeCommand(new NodeRecord(0), new NodeRecord(0));
    final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
    final InMemoryClosableChannel channel = new InMemoryClosableChannel();
    // ignored data
    // identifier
    channel.putInt(123);
    // actual read data
    nodeCommand.serialize(channel);
    channel.getCurrentPosition(marker);
    // when
    final LogEntryParser<LogEntry> parser = version.entryParser(LogEntryByteCodes.COMMAND);
    final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
    // then
    assertEquals(command, entryOf(logEntry));
    assertFalse(parser.skip());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 37 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.

the class LogEntryParserV2_1Test method shouldParseOnePhaseCommitEntry.

@Test
public void shouldParseOnePhaseCommitEntry() throws IOException {
    // given
    final LogEntryCommit commit = new OnePhaseCommit(version, 42, 21);
    final InMemoryClosableChannel channel = new InMemoryClosableChannel();
    // ignored data
    // identifier
    channel.putInt(123);
    // actual read data
    channel.putLong(commit.getTxId());
    channel.putLong(commit.getTimeWritten());
    channel.getCurrentPosition(marker);
    // when
    final LogEntryParser<LogEntry> parser = version.entryParser(LogEntryByteCodes.TX_1P_COMMIT);
    final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
    // then
    assertEquals(commit, entryOf(logEntry));
    assertFalse(parser.skip());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 38 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.

the class LogEntryParserV2_1Test method shouldParseEmptyEntry.

@Test
public void shouldParseEmptyEntry() throws IOException {
    // when
    final LogEntryParser<LogEntry> parser = version.entryParser(LogEntryByteCodes.EMPTY);
    final LogEntry logEntry = parser.parse(version, new InMemoryClosableChannel(), marker, commandReader);
    // then
    assertNull(logEntry);
    assertFalse(parser.skip());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 39 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.

the class LogEntryParserV2_2Test method shouldParseEmptyEntry.

@Test
public void shouldParseEmptyEntry() throws IOException {
    // when
    final LogEntryParser parser = version.entryParser(LogEntryByteCodes.EMPTY);
    final LogEntry logEntry = parser.parse(version, new InMemoryClosableChannel(), marker, commandReader);
    // then
    assertNull(logEntry);
    assertFalse(parser.skip());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 40 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0Test method readRelationshipCommandWithNonRequiredSecondaryUnit.

@Test
public void readRelationshipCommandWithNonRequiredSecondaryUnit() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipRecord before = new RelationshipRecord(42, true, 1, 2, 3, 4, 5, 6, 7, true, true);
    before.setRequiresSecondaryUnit(false);
    before.setSecondaryUnitId(52);
    RelationshipRecord after = new RelationshipRecord(42, true, 1, 8, 3, 4, 5, 6, 7, true, true);
    new Command.RelationshipCommand(before, after).serialize(channel);
    PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
    Command command = reader.read(channel);
    assertTrue(command instanceof Command.RelationshipCommand);
    Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
    assertEquals(before, relationshipCommand.getBefore());
    verifySecondaryUnit(before, relationshipCommand.getBefore());
    assertEquals(after, relationshipCommand.getAfter());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.Test)

Aggregations

InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)66 Test (org.junit.Test)63 Command (org.neo4j.kernel.impl.transaction.command.Command)8 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)5 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)4 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)3 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)3 CommandReader (org.neo4j.storageengine.api.CommandReader)3 Before (org.junit.Before)2 AddRelationshipCommand (org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand)2 CountsKey (org.neo4j.kernel.impl.store.counts.keys.CountsKey)2 SchemaRecord (org.neo4j.kernel.impl.store.record.SchemaRecord)2 SchemaRuleCommand (org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand)2 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)1 EndOfStreamException (org.neo4j.causalclustering.messaging.EndOfStreamException)1