use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0Test method readPropertyCommandWithNonRequiredSecondaryUnit.
@Test
public void readPropertyCommandWithNonRequiredSecondaryUnit() throws IOException {
InMemoryClosableChannel channel = new InMemoryClosableChannel();
PropertyRecord before = new PropertyRecord(1);
PropertyRecord after = new PropertyRecord(2);
after.setRequiresSecondaryUnit(false);
after.setSecondaryUnitId(78);
new Command.PropertyCommand(before, after).serialize(channel);
PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
Command command = reader.read(channel);
assertTrue(command instanceof Command.PropertyCommand);
Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command;
// Then
assertEquals(before.getNextProp(), neoStoreCommand.getBefore().getNextProp());
assertEquals(after.getNextProp(), neoStoreCommand.getAfter().getNextProp());
verifySecondaryUnit(after, neoStoreCommand.getAfter());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0Test method shouldReadRelationshipCommand.
@Test
public void shouldReadRelationshipCommand() throws Throwable {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipRecord before = new RelationshipRecord(42, -1, -1, -1);
RelationshipRecord after = new RelationshipRecord(42, true, 1, 2, 3, 4, 5, 6, 7, true, true);
new Command.RelationshipCommand(before, after).serialize(channel);
// When
PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
Command command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipCommand);
Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
// Then
assertEquals(before, relationshipCommand.getBefore());
assertEquals(after, relationshipCommand.getAfter());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0Test method shouldReadRelationshipGroupCommand.
@Test
public void shouldReadRelationshipGroupCommand() throws Throwable {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipGroupRecord before = new RelationshipGroupRecord(42, 3);
RelationshipGroupRecord after = new RelationshipGroupRecord(42, 3, 4, 5, 6, 7, 8, true);
after.setCreated();
new Command.RelationshipGroupCommand(before, after).serialize(channel);
// When
PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
Command command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipGroupCommand);
Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
// Then
assertEquals(before, relationshipGroupCommand.getBefore());
assertEquals(after, relationshipGroupCommand.getAfter());
}
use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.
the class VersionAwareLogEntryReaderTest method shouldParseOldPrepareSkipItAndReadTheOneAfter.
@Test
public void shouldParseOldPrepareSkipItAndReadTheOneAfter() 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.TX_PREPARE);
// ignored data
// identifier
channel.putInt(123);
// timewritten
channel.putLong(456);
// 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 shouldReadACommitLogEntry.
@Test
public void shouldReadACommitLogEntry() throws IOException {
// given
LogEntryVersion version = LogEntryVersion.CURRENT;
final LogEntryCommit commit = new OnePhaseCommit(version, 42, 21);
final InMemoryClosableChannel channel = new InMemoryClosableChannel();
channel.put(version.byteCode());
channel.put(LogEntryByteCodes.TX_1P_COMMIT);
channel.putLong(commit.getTxId());
channel.putLong(commit.getTimeWritten());
// when
final LogEntry logEntry = logEntryReader.readLogEntry(channel);
// then
assertEquals(commit, logEntry);
}
Aggregations