diff --git a/.idea/modules/plugin-transport-thrift.iml b/.idea/modules/plugin-transport-thrift.iml index 48fe5d6ac6a..f81a0e28836 100644 --- a/.idea/modules/plugin-transport-thrift.iml +++ b/.idea/modules/plugin-transport-thrift.iml @@ -16,7 +16,7 @@ - + diff --git a/plugins/transport/thrift/build.gradle b/plugins/transport/thrift/build.gradle index bee9fac21ee..ff1cae0a689 100644 --- a/plugins/transport/thrift/build.gradle +++ b/plugins/transport/thrift/build.gradle @@ -33,11 +33,11 @@ configurations { dependencies { compile project(':elasticsearch') - compile 'org.elasticsearch:es-libthrift:0.4.0' + compile 'org.elasticsearch:es-libthrift:0.5.0' compile 'org.slf4j:slf4j-api:1.5.11' compile('org.slf4j:slf4j-log4j12:1.5.11') { transitive = false } - distLib("org.elasticsearch:es-libthrift:0.4.0") { transitive = false } + distLib("org.elasticsearch:es-libthrift:0.5.0") { transitive = false } distLib 'org.slf4j:slf4j-api:1.5.11' distLib('org.slf4j:slf4j-log4j12:1.5.11') { transitive = false } diff --git a/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/Rest.java b/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/Rest.java index cb496011d66..f0b4040b7c3 100644 --- a/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/Rest.java +++ b/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/Rest.java @@ -315,11 +315,6 @@ public class Rest { return new execute_args(this); } - @Deprecated - public execute_args clone() { - return new execute_args(this); - } - @Override public void clear() { this.request = null; @@ -364,10 +359,6 @@ public class Rest { } } - public void setFieldValue(int fieldID, Object value) { - setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); - } - public Object getFieldValue(_Fields field) { switch (field) { case REQUEST: @@ -377,14 +368,14 @@ public class Rest { throw new IllegalStateException(); } - public Object getFieldValue(int fieldId) { - return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); - } - /** * Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + switch (field) { case REQUEST: return isSetRequest(); @@ -392,10 +383,6 @@ public class Rest { throw new IllegalStateException(); } - public boolean isSet(int fieldID) { - return isSet(_Fields.findByThriftIdOrThrow(fieldID)); - } - @Override public boolean equals(Object that) { if (that == null) @@ -447,6 +434,10 @@ public class Rest { return 0; } + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + public void read(TProtocol iprot) throws TException { TField field; iprot.readStructBegin(); @@ -614,11 +605,6 @@ public class Rest { return new execute_result(this); } - @Deprecated - public execute_result clone() { - return new execute_result(this); - } - @Override public void clear() { this.success = null; @@ -663,10 +649,6 @@ public class Rest { } } - public void setFieldValue(int fieldID, Object value) { - setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); - } - public Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: @@ -676,14 +658,14 @@ public class Rest { throw new IllegalStateException(); } - public Object getFieldValue(int fieldId) { - return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); - } - /** * Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + switch (field) { case SUCCESS: return isSetSuccess(); @@ -691,10 +673,6 @@ public class Rest { throw new IllegalStateException(); } - public boolean isSet(int fieldID) { - return isSet(_Fields.findByThriftIdOrThrow(fieldID)); - } - @Override public boolean equals(Object that) { if (that == null) @@ -746,6 +724,10 @@ public class Rest { return 0; } + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + public void read(TProtocol iprot) throws TException { TField field; iprot.readStructBegin(); diff --git a/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/RestRequest.java b/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/RestRequest.java index 26b11e3d927..ca9a81bebe9 100644 --- a/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/RestRequest.java +++ b/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/RestRequest.java @@ -1,3 +1,22 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /** * Autogenerated by Thrift * @@ -184,8 +203,8 @@ public class RestRequest implements TBase, jav this.headers = __this__headers; } if (other.isSetBody()) { - this.body = ByteBuffer.wrap(new byte[other.body.limit() - other.body.arrayOffset()]); - System.arraycopy(other.body.array(), other.body.arrayOffset(), body.array(), 0, other.body.limit() - other.body.arrayOffset()); + this.body = TBaseHelper.copyBinary(other.body); + ; } } @@ -193,11 +212,6 @@ public class RestRequest implements TBase, jav return new RestRequest(this); } - @Deprecated - public RestRequest clone() { - return new RestRequest(this); - } - @Override public void clear() { this.method = null; @@ -339,8 +353,18 @@ public class RestRequest implements TBase, jav } } - public ByteBuffer getBody() { - return this.body; + public byte[] getBody() { + setBody(TBaseHelper.rightSize(body)); + return body.array(); + } + + public ByteBuffer BufferForBody() { + return body; + } + + public RestRequest setBody(byte[] body) { + setBody(ByteBuffer.wrap(body)); + return this; } public RestRequest setBody(ByteBuffer body) { @@ -410,10 +434,6 @@ public class RestRequest implements TBase, jav } } - public void setFieldValue(int fieldID, Object value) { - setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); - } - public Object getFieldValue(_Fields field) { switch (field) { case METHOD: @@ -435,14 +455,14 @@ public class RestRequest implements TBase, jav throw new IllegalStateException(); } - public Object getFieldValue(int fieldId) { - return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); - } - /** * Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + switch (field) { case METHOD: return isSetMethod(); @@ -458,10 +478,6 @@ public class RestRequest implements TBase, jav throw new IllegalStateException(); } - public boolean isSet(int fieldID) { - return isSet(_Fields.findByThriftIdOrThrow(fieldID)); - } - @Override public boolean equals(Object that) { if (that == null) @@ -589,6 +605,10 @@ public class RestRequest implements TBase, jav return 0; } + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + public void read(TProtocol iprot) throws TException { TField field; iprot.readStructBegin(); diff --git a/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/RestResponse.java b/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/RestResponse.java index 605132fde6d..f33e3d1cfc1 100644 --- a/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/RestResponse.java +++ b/plugins/transport/thrift/src/main/gen-java/org/elasticsearch/thrift/RestResponse.java @@ -1,3 +1,22 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /** * Autogenerated by Thrift * @@ -148,8 +167,8 @@ public class RestResponse implements TBase, this.headers = __this__headers; } if (other.isSetBody()) { - this.body = ByteBuffer.wrap(new byte[other.body.limit() - other.body.arrayOffset()]); - System.arraycopy(other.body.array(), other.body.arrayOffset(), body.array(), 0, other.body.limit() - other.body.arrayOffset()); + this.body = TBaseHelper.copyBinary(other.body); + ; } } @@ -157,11 +176,6 @@ public class RestResponse implements TBase, return new RestResponse(this); } - @Deprecated - public RestResponse clone() { - return new RestResponse(this); - } - @Override public void clear() { this.status = null; @@ -238,8 +252,18 @@ public class RestResponse implements TBase, } } - public ByteBuffer getBody() { - return this.body; + public byte[] getBody() { + setBody(TBaseHelper.rightSize(body)); + return body.array(); + } + + public ByteBuffer BufferForBody() { + return body; + } + + public RestResponse setBody(byte[] body) { + setBody(ByteBuffer.wrap(body)); + return this; } public RestResponse setBody(ByteBuffer body) { @@ -293,10 +317,6 @@ public class RestResponse implements TBase, } } - public void setFieldValue(int fieldID, Object value) { - setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); - } - public Object getFieldValue(_Fields field) { switch (field) { case STATUS: @@ -312,14 +332,14 @@ public class RestResponse implements TBase, throw new IllegalStateException(); } - public Object getFieldValue(int fieldId) { - return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); - } - /** * Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + switch (field) { case STATUS: return isSetStatus(); @@ -331,10 +351,6 @@ public class RestResponse implements TBase, throw new IllegalStateException(); } - public boolean isSet(int fieldID) { - return isSet(_Fields.findByThriftIdOrThrow(fieldID)); - } - @Override public boolean equals(Object that) { if (that == null) @@ -424,6 +440,10 @@ public class RestResponse implements TBase, return 0; } + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + public void read(TProtocol iprot) throws TException { TField field; iprot.readStructBegin(); diff --git a/plugins/transport/thrift/src/main/java/org/elasticsearch/thrift/ThriftRestRequest.java b/plugins/transport/thrift/src/main/java/org/elasticsearch/thrift/ThriftRestRequest.java index c02f4da250a..f71bdfc5f33 100644 --- a/plugins/transport/thrift/src/main/java/org/elasticsearch/thrift/ThriftRestRequest.java +++ b/plugins/transport/thrift/src/main/java/org/elasticsearch/thrift/ThriftRestRequest.java @@ -80,7 +80,7 @@ public class ThriftRestRequest extends AbstractRestRequest implements org.elasti } @Override public boolean hasContent() { - return request.getBody() != null && request.getBody().remaining() > 0; + return request.isSetBody() && request.BufferForBody().remaining() > 0; } @Override public boolean contentUnsafe() { @@ -91,21 +91,21 @@ public class ThriftRestRequest extends AbstractRestRequest implements org.elasti if (!request.isSetBody()) { return Bytes.EMPTY_ARRAY; } - return request.getBody().array(); + return request.BufferForBody().array(); } @Override public int contentByteArrayOffset() { if (!request.isSetBody()) { return 0; } - return request.getBody().arrayOffset(); + return request.BufferForBody().arrayOffset(); } @Override public int contentLength() { if (!request.isSetBody()) { return 0; } - return request.getBody().remaining(); + return request.BufferForBody().remaining(); } @Override public String contentAsString() { diff --git a/plugins/transport/thrift/src/test/java/org/elasticsearch/thrift/test/SimpleThriftTests.java b/plugins/transport/thrift/src/test/java/org/elasticsearch/thrift/test/SimpleThriftTests.java index 29f34e8c280..51adb4acfd3 100644 --- a/plugins/transport/thrift/src/test/java/org/elasticsearch/thrift/test/SimpleThriftTests.java +++ b/plugins/transport/thrift/src/test/java/org/elasticsearch/thrift/test/SimpleThriftTests.java @@ -83,6 +83,6 @@ public class SimpleThriftTests { } private Map parseBody(RestResponse response) throws IOException { - return XContentFactory.xContent(XContentType.JSON).createParser(response.getBody().array(), response.getBody().arrayOffset(), response.getBody().remaining()).map(); + return XContentFactory.xContent(XContentType.JSON).createParser(response.BufferForBody().array(), response.BufferForBody().arrayOffset(), response.BufferForBody().remaining()).map(); } }