use of org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory in project neo4j by neo4j.
the class IndexDefineCommandTest method shouldWriteIndexDefineCommandIfMapWithinShortRange.
@Test
public void shouldWriteIndexDefineCommandIfMapWithinShortRange() throws IOException {
// GIVEN
InMemoryClosableChannel channel = new InMemoryClosableChannel(10_000);
IndexDefineCommand command = initIndexDefineCommand(300);
// WHEN
command.serialize(channel);
// THEN
CommandReader commandReader = new RecordStorageCommandReaderFactory().byVersion(LogEntryVersion.CURRENT.byteCode());
IndexDefineCommand read = (IndexDefineCommand) commandReader.read(channel);
assertEquals(command.getIndexNameIdRange(), read.getIndexNameIdRange());
assertEquals(command.getKeyIdRange(), read.getKeyIdRange());
}
use of org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory in project neo4j by neo4j.
the class TxPullResponseDecoder method decode.
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
NetworkReadableClosableChannelNetty4 logChannel = new NetworkReadableClosableChannelNetty4(msg);
StoreId storeId = StoreIdMarshal.INSTANCE.unmarshal(logChannel);
LogEntryReader<NetworkReadableClosableChannelNetty4> reader = new VersionAwareLogEntryReader<>(new RecordStorageCommandReaderFactory());
PhysicalTransactionCursor<NetworkReadableClosableChannelNetty4> transactionCursor = new PhysicalTransactionCursor<>(logChannel, reader);
transactionCursor.next();
CommittedTransactionRepresentation tx = transactionCursor.get();
if (tx != null) {
out.add(new TxPullResponse(storeId, tx));
}
}
use of org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory in project neo4j by neo4j.
the class ReplicatedTransactionFactory method read.
public static TransactionRepresentation read(NetworkReadableClosableChannelNetty4 channel, byte[] extraHeader) throws IOException {
LogEntryReader<ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader<>(new RecordStorageCommandReaderFactory());
int authorId = channel.getInt();
int masterId = channel.getInt();
long latestCommittedTxWhenStarted = channel.getLong();
long timeStarted = channel.getLong();
long timeCommitted = channel.getLong();
int lockSessionId = channel.getInt();
int headerLength = channel.getInt();
byte[] header;
if (headerLength == 0) {
header = extraHeader;
} else {
header = new byte[headerLength];
}
channel.get(header, headerLength);
LogEntryCommand entryRead;
List<StorageCommand> commands = new LinkedList<>();
while ((entryRead = (LogEntryCommand) reader.readLogEntry(channel)) != null) {
commands.add(entryRead.getXaCommand());
}
PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(commands);
tx.setHeader(header, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted, lockSessionId);
return tx;
}
use of org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory in project neo4j by neo4j.
the class ReplicatedTokenRequestSerializer method extractCommands.
static Collection<StorageCommand> extractCommands(byte[] commandBytes) {
ByteBuf txBuffer = Unpooled.wrappedBuffer(commandBytes);
NetworkReadableClosableChannelNetty4 channel = new NetworkReadableClosableChannelNetty4(txBuffer);
LogEntryReader<ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader<>(new RecordStorageCommandReaderFactory());
LogEntryCommand entryRead;
List<StorageCommand> commands = new LinkedList<>();
try {
while ((entryRead = (LogEntryCommand) reader.readLogEntry(channel)) != null) {
commands.add(entryRead.getXaCommand());
}
} catch (IOException e) {
// TODO: Handle or throw.
e.printStackTrace();
}
return commands;
}
use of org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory in project neo4j by neo4j.
the class TransactionLogCatchUpWriterTest method verifyCheckpointInLog.
private void verifyCheckpointInLog() throws IOException {
LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>(new RecordStorageCommandReaderFactory());
PhysicalLogFiles logFiles = new PhysicalLogFiles(storeDir, fs);
final LatestCheckPointFinder checkPointFinder = new LatestCheckPointFinder(logFiles, fs, logEntryReader);
LatestCheckPointFinder.LatestCheckPoint checkPoint = checkPointFinder.find(0);
assertNotNull(checkPoint.checkPoint);
assertTrue(checkPoint.commitsAfterCheckPoint);
}
Aggregations