try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
boolean snapshotTaken = txManager.takeSnapshot(out);
if (!snapshotTaken) {
throw new TTransactionCouldNotTakeSnapshotException("Transaction manager could not get a snapshot.");
}
} finally {
out.close();
}
// todo find a way to encode directly to the stream, without having the snapshot in memory twice
return ByteBuffer.wrap(out.toByteArray());
} catch (IOException e) {
throw new TTransactionCouldNotTakeSnapshotException(e.getMessage());
}
}