Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,9 @@ private void write(final StreamOutput out) throws IOException {
out.writeString(type);
out.writeBytesReference(source);
out.writeOptionalString(routing);
if (format < FORMAT_NO_PARENT) {
out.writeOptionalString(null); // _parent
}
out.writeLong(version);
if (format < FORMAT_NO_VERSION_TYPE) {
out.writeByte(VersionType.EXTERNAL.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.Assertions;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Randomness;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -72,6 +73,7 @@
import org.elasticsearch.index.translog.Translog.Location;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.VersionUtils;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -2814,9 +2816,12 @@ public void testTranslogOpSerialization() throws Exception {
Engine.IndexResult eIndexResult = new Engine.IndexResult(1, randomPrimaryTerm, randomSeqNum, true);
Translog.Index index = new Translog.Index(eIndex, eIndexResult);

Version wireVersion = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT);
BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(wireVersion);
Translog.Operation.writeOperation(out, index);
StreamInput in = out.bytes().streamInput();
in.setVersion(wireVersion);
Translog.Index serializedIndex = (Translog.Index) Translog.Operation.readOperation(in);
assertEquals(index, serializedIndex);

Expand All @@ -2826,8 +2831,10 @@ public void testTranslogOpSerialization() throws Exception {
Translog.Delete delete = new Translog.Delete(eDelete, eDeleteResult);

out = new BytesStreamOutput();
out.setVersion(wireVersion);
Translog.Operation.writeOperation(out, delete);
in = out.bytes().streamInput();
in.setVersion(wireVersion);
Translog.Delete serializedDelete = (Translog.Delete) Translog.Operation.readOperation(in);
assertEquals(delete, serializedDelete);
}
Expand Down