use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class CheckTxLogsTest method writeTxContent.
private void writeTxContent(File log, long txId, Command... commands) throws IOException {
PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(Arrays.asList(commands));
tx.setHeader(new byte[0], 0, 0, 0, 0, 0, 0);
writeContent(log, (txWriter) -> txWriter.append(tx, txId));
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation 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.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class SlaveTransactionCommitProcessTest method setUp.
@Before
public void setUp() {
lastSeenEventIdentifier = new AtomicInteger(-1);
master = mock(Master.class);
requestContext = new RequestContext(10, 11, 12, 13, 14);
reqFactory = new ConstantRequestContextFactory(requestContext) {
@Override
public RequestContext newRequestContext(int eventIdentifier) {
lastSeenEventIdentifier.set(eventIdentifier);
return super.newRequestContext(eventIdentifier);
}
};
response = new LongResponse(42L);
tx = new PhysicalTransactionRepresentation(Collections.<StorageCommand>emptyList());
tx.setHeader(new byte[] {}, 1, 1, 1, 1, 1, 1337);
commitProcess = new SlaveTransactionCommitProcess(master, reqFactory);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class RaftContentByteBufferMarshalTest method shouldSerializeTransactionRepresentation.
@Test
public void shouldSerializeTransactionRepresentation() throws Exception {
// given
CoreReplicatedContentMarshal serializer = new CoreReplicatedContentMarshal();
Collection<StorageCommand> commands = new ArrayList<>();
IndexCommand.AddNodeCommand addNodeCommand = new IndexCommand.AddNodeCommand();
addNodeCommand.init(0, 0, 0, 0);
commands.add(addNodeCommand);
byte[] extraHeader = new byte[0];
PhysicalTransactionRepresentation txIn = new PhysicalTransactionRepresentation(commands);
txIn.setHeader(extraHeader, -1, -1, 0, 0, 0, 0);
ReplicatedTransaction in = ReplicatedTransactionFactory.createImmutableReplicatedTransaction(txIn);
// when
ByteBuf buf = Unpooled.buffer();
serializer.marshal(in, new NetworkFlushableByteBuf(buf));
ReplicatedTransaction out = (ReplicatedTransaction) serializer.unmarshal(new NetworkReadableClosableChannelNetty4(buf));
TransactionRepresentation txOut = ReplicatedTransactionFactory.extractTransactionRepresentation(out, extraHeader);
// then
assertEquals(in, out);
assertEquals(txIn, txOut);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation in project neo4j by neo4j.
the class TransactionWriter method representation.
public TransactionRepresentation representation(byte[] additionalHeader, int masterId, int authorId, long startTime, long lastCommittedTx, long committedTime) {
prepareForCommit();
PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(allCommands());
representation.setHeader(additionalHeader, masterId, authorId, startTime, lastCommittedTx, committedTime, -1);
return representation;
}
Aggregations