use of org.neo4j.causalclustering.messaging.MessageTooBigException in project neo4j by neo4j.
the class ReplicatedTransactionFactory method createImmutableReplicatedTransaction.
public static ReplicatedTransaction createImmutableReplicatedTransaction(TransactionRepresentation tx) {
ByteBuf transactionBuffer = Unpooled.buffer();
NetworkFlushableChannelNetty4 channel = new NetworkFlushableChannelNetty4(transactionBuffer, MAX_SERIALIZED_TX_SIZE);
try {
TransactionSerializer.write(tx, channel);
} catch (MessageTooBigException e) {
throw new IllegalStateException("Transaction size was too large to replicate across the cluster.", e);
} catch (IOException e) {
// Easier said than done though, we use the LogEntry handling routines which throw IOException
throw new RuntimeException(e);
}
/*
* This trims down the array to send up to the actual index it was written. While sending additional zeroes
* is safe, since LogEntryReader stops reading once it sees a zero entry, it is wasteful.
*/
byte[] txBytes = Arrays.copyOf(transactionBuffer.array(), transactionBuffer.writerIndex());
transactionBuffer.release();
return new ReplicatedTransaction(txBytes);
}
Aggregations