use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class LogEntryParserV2_1Test method shouldParseTwoPhaseCommitEntryAndMapThemIntoOnePhaseCommit.
@Test
public void shouldParseTwoPhaseCommitEntryAndMapThemIntoOnePhaseCommit() 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_2P_COMMIT);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(commit, entryOf(logEntry));
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class LogEntryParserV2_2Test method shouldParseStartEntry.
@Test
public void shouldParseStartEntry() throws IOException {
// given
final LogEntryStart start = new LogEntryStart(version, 1, 2, 3, 4, new byte[] { 5 }, position);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
channel.putInt(start.getMasterId());
channel.putInt(start.getLocalId());
channel.putLong(start.getTimeWritten());
channel.putLong(start.getLastCommittedTxWhenTransactionStarted());
channel.putInt(start.getAdditionalHeader().length);
channel.put(start.getAdditionalHeader(), start.getAdditionalHeader().length);
channel.getCurrentPosition(marker);
// when
final LogEntryParser parser = version.entryParser(LogEntryByteCodes.TX_START);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(start, logEntry);
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class LogEntryParserV2_2Test method shouldParseCommandsUsingAGivenFactory.
@Test
public void shouldParseCommandsUsingAGivenFactory() throws IOException {
// given
Command.NodeCommand nodeCommand = new Command.NodeCommand(new NodeRecord(0), new NodeRecord(0));
final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
nodeCommand.serialize(channel);
channel.getCurrentPosition(marker);
// when
final LogEntryParser parser = version.entryParser(LogEntryByteCodes.COMMAND);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(command, logEntry);
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class LogEntryParserV2_2Test method shouldParseOnePhaseCommitEntry.
@Test
public void shouldParseOnePhaseCommitEntry() throws IOException {
// given
final LogEntryCommit commit = new OnePhaseCommit(version, 42, 21);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
channel.putLong(commit.getTxId());
channel.putLong(commit.getTimeWritten());
channel.getCurrentPosition(marker);
// when
final LogEntryParser parser = version.entryParser(LogEntryByteCodes.TX_1P_COMMIT);
final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
// then
assertEquals(commit, logEntry);
assertFalse(parser.skip());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class VersionAwareLogEntryReaderTest method shouldParseOldOnePhaseCommit.
@Test
public void shouldParseOldOnePhaseCommit() throws IOException {
// given
LogEntryVersion version = LogEntryVersion.V2_1;
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
final OnePhaseCommit commit = new OnePhaseCommit(42, 456);
channel.put(version.byteCode());
channel.put(LogEntryByteCodes.TX_1P_COMMIT);
// ignored data
// identifier
channel.putInt(123);
// actually used data
channel.putLong(commit.getTxId());
channel.putLong(commit.getTimeWritten());
// when
final LogEntry logEntry = logEntryReader.readLogEntry(channel);
// then
assertTrue(logEntry instanceof IdentifiableLogEntry);
assertEquals(commit, ((IdentifiableLogEntry) logEntry).getEntry());
}
Aggregations