diff --git a/core/src/main/java/org/elasticsearch/index/Index.java b/core/src/main/java/org/elasticsearch/index/Index.java index 3ffe13e38b1..0dbf522dc9a 100644 --- a/core/src/main/java/org/elasticsearch/index/Index.java +++ b/core/src/main/java/org/elasticsearch/index/Index.java @@ -41,11 +41,19 @@ public class Index implements Writeable { this.uuid = uuid.intern(); } + /** + * Read from a stream. + */ public Index(StreamInput in) throws IOException { this.name = in.readString(); this.uuid = in.readString(); } + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeString(name); + out.writeString(uuid); + } public String getName() { return this.name; @@ -85,15 +93,4 @@ public class Index implements Writeable { result = 31 * result + uuid.hashCode(); return result; } - - @Override - public Index readFrom(StreamInput in) throws IOException { - return new Index(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeString(name); - out.writeString(uuid); - } } diff --git a/core/src/main/java/org/elasticsearch/index/engine/Engine.java b/core/src/main/java/org/elasticsearch/index/engine/Engine.java index 5d702f44918..69aee4ac680 100644 --- a/core/src/main/java/org/elasticsearch/index/engine/Engine.java +++ b/core/src/main/java/org/elasticsearch/index/engine/Engine.java @@ -1077,26 +1077,24 @@ public abstract class Engine implements Closeable { this.id = Arrays.copyOf(id, id.length); } + /** + * Read from a stream. + */ public CommitId(StreamInput in) throws IOException { assert in != null; this.id = in.readByteArray(); } - @Override - public String toString() { - return Base64.encodeBytes(id); - } - - @Override - public CommitId readFrom(StreamInput in) throws IOException { - return new CommitId(in); - } - @Override public void writeTo(StreamOutput out) throws IOException { out.writeByteArray(id); } + @Override + public String toString() { + return Base64.encodeBytes(id); + } + public boolean idsEqual(byte[] id) { return Arrays.equals(id, this.id); } diff --git a/core/src/main/java/org/elasticsearch/index/store/StoreFileMetaData.java b/core/src/main/java/org/elasticsearch/index/store/StoreFileMetaData.java index 9f712c77e70..e163b15f60e 100644 --- a/core/src/main/java/org/elasticsearch/index/store/StoreFileMetaData.java +++ b/core/src/main/java/org/elasticsearch/index/store/StoreFileMetaData.java @@ -49,16 +49,6 @@ public class StoreFileMetaData implements Writeable { private final BytesRef hash; - public StoreFileMetaData(StreamInput in) throws IOException { - name = in.readString(); - length = in.readVLong(); - checksum = in.readString(); - String versionString = in.readString(); - assert versionString != null; - writtenBy = Lucene.parseVersionLenient(versionString, FIRST_LUCENE_CHECKSUM_VERSION); - hash = in.readBytesRef(); - } - public StoreFileMetaData(String name, long length, String checksum) { this(name, length, checksum, FIRST_LUCENE_CHECKSUM_VERSION); } @@ -79,6 +69,26 @@ public class StoreFileMetaData implements Writeable { this.hash = hash == null ? new BytesRef() : hash; } + /** + * Read from a stream. + */ + public StoreFileMetaData(StreamInput in) throws IOException { + name = in.readString(); + length = in.readVLong(); + checksum = in.readString(); + // TODO Why not Version.parse? + writtenBy = Lucene.parseVersionLenient(in.readString(), FIRST_LUCENE_CHECKSUM_VERSION); + hash = in.readBytesRef(); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeString(name); + out.writeVLong(length); + out.writeString(checksum); + out.writeString(writtenBy.toString()); + out.writeBytesRef(hash); + } /** * Returns the name of this file @@ -118,20 +128,6 @@ public class StoreFileMetaData implements Writeable { return "name [" + name + "], length [" + length + "], checksum [" + checksum + "], writtenBy [" + writtenBy + "]" ; } - @Override - public StoreFileMetaData readFrom(StreamInput in) throws IOException { - return new StoreFileMetaData(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeString(name); - out.writeVLong(length); - out.writeString(checksum); - out.writeString(writtenBy.toString()); - out.writeBytesRef(hash); - } - /** * Returns the Lucene version this file has been written by or null if unknown */