use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class VersionAwareLogEntryReaderTest method shouldReturnNullWhenNotEnoughDataInTheChannel.
@Test
public void shouldReturnNullWhenNotEnoughDataInTheChannel() throws IOException {
// given
LogEntryVersion version = LogEntryVersion.CURRENT;
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
// when
final LogEntry logEntry = logEntryReader.readLogEntry(channel);
// then
assertNull(logEntry);
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class VersionAwareLogEntryReaderTest method shouldParseOldDoneSkipItAndReadTheOneAfter.
@Test
public void shouldParseOldDoneSkipItAndReadTheOneAfter() throws IOException {
// given
LogEntryVersion version = LogEntryVersion.V2_1;
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
final OnePhaseCommit commit = new OnePhaseCommit(42, 456);
// PREPARE
channel.put(version.byteCode());
channel.put(LogEntryByteCodes.DONE);
// ignored data
// identifier
channel.putInt(123);
// 2P COMMIT
channel.put(version.byteCode());
channel.put(LogEntryByteCodes.TX_2P_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());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class VersionAwareLogEntryReaderTest method shouldParseOldTwoPhaseCommit.
@Test
public void shouldParseOldTwoPhaseCommit() 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_2P_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());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class RelationshipGroupCommandV2_2Test method assertSerializationWorksFor.
private void assertSerializationWorksFor(Command.RelationshipGroupCommand cmd) throws IOException {
InMemoryClosableChannel channel = new InMemoryClosableChannel();
cmd.serialize(channel);
CommandReader commandReader = new PhysicalLogCommandReaderV2_2();
Command.RelationshipGroupCommand result = (Command.RelationshipGroupCommand) commandReader.read(channel);
RelationshipGroupRecord recordBefore = cmd.getBefore();
RelationshipGroupRecord recordAfter = result.getAfter();
// Then
assertThat(recordBefore.getFirstIn(), equalTo(recordAfter.getFirstIn()));
assertThat(recordBefore.getFirstOut(), equalTo(recordAfter.getFirstOut()));
assertThat(recordBefore.getFirstLoop(), equalTo(recordAfter.getFirstLoop()));
assertThat(recordBefore.getNext(), equalTo(recordAfter.getNext()));
assertThat(recordBefore.getOwningNode(), equalTo(recordAfter.getOwningNode()));
assertThat(recordBefore.getPrev(), equalTo(recordAfter.getPrev()));
assertThat(recordBefore.getType(), equalTo(recordAfter.getType()));
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class SchemaRuleCommandTest method shouldWriteSchemaRuleToLog.
@Test
public void shouldWriteSchemaRuleToLog() throws Exception {
// GIVEN
SchemaRecord beforeRecords = serialize(rule, id, false, false);
SchemaRecord afterRecords = serialize(rule, id, true, true);
SchemaRuleCommand command = new SchemaRuleCommand(beforeRecords, afterRecords, rule);
InMemoryClosableChannel buffer = new InMemoryClosableChannel();
when(neoStores.getSchemaStore()).thenReturn(schemaStore);
// WHEN
command.serialize(buffer);
Command readCommand = reader.read(buffer);
// THEN
assertThat(readCommand, instanceOf(SchemaRuleCommand.class));
assertSchemaRule((SchemaRuleCommand) readCommand);
}
Aggregations