Backported synced-flush PR to v5.6.8 and v6.2.2

Relates #28464
This commit is contained in:
Nhat Nguyen 2018-02-14 13:19:39 -05:00
parent b59b1cf59d
commit 452bfc0d83
1 changed files with 10 additions and 2 deletions

View File

@ -529,11 +529,19 @@ public class SyncedFlushService extends AbstractComponent implements IndexEventL
return numDocs;
}
boolean includeNumDocs(Version version) {
if (version.major == Version.V_5_6_8.major) {
return version.onOrAfter(Version.V_5_6_8);
} else {
return version.onOrAfter(Version.V_6_2_2);
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
commitId = new Engine.CommitId(in);
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
if (includeNumDocs(in.getVersion())) {
numDocs = in.readInt();
} else {
numDocs = UNKNOWN_NUM_DOCS;
@ -544,7 +552,7 @@ public class SyncedFlushService extends AbstractComponent implements IndexEventL
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
commitId.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
if (includeNumDocs(out.getVersion())) {
out.writeInt(numDocs);
}
}