/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package com.flaptor.indextank.rpc;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.thrift.*;
import org.apache.thrift.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
@SuppressWarnings("all") public class LogReader {
public interface Iface {
public LogPage read_page(String index_code, LogPageToken token) throws TException;
}
public interface AsyncIface {
public void read_page(String index_code, LogPageToken token, AsyncMethodCallback<AsyncClient.read_page_call> resultHandler) throws TException;
}
public static class Client implements TServiceClient, Iface {
public static class Factory implements TServiceClientFactory<Client> {
public Factory() {}
public Client getClient(TProtocol prot) {
return new Client(prot);
}
public Client getClient(TProtocol iprot, TProtocol oprot) {
return new Client(iprot, oprot);
}
}
public Client(TProtocol prot)
{
this(prot, prot);
}
public Client(TProtocol iprot, TProtocol oprot)
{
iprot_ = iprot;
oprot_ = oprot;
}
protected TProtocol iprot_;
protected TProtocol oprot_;
protected int seqid_;
public TProtocol getInputProtocol()
{
return this.iprot_;
}
public TProtocol getOutputProtocol()
{
return this.oprot_;
}
public LogPage read_page(String index_code, LogPageToken token) throws TException
{
send_read_page(index_code, token);
return recv_read_page();
}
public void send_read_page(String index_code, LogPageToken token) throws TException
{
oprot_.writeMessageBegin(new TMessage("read_page", TMessageType.CALL, ++seqid_));
read_page_args args = new read_page_args();
args.set_index_code(index_code);
args.set_token(token);
args.write(oprot_);
oprot_.writeMessageEnd();
oprot_.getTransport().flush();
}
public LogPage recv_read_page() throws TException
{
TMessage msg = iprot_.readMessageBegin();
if (msg.type == TMessageType.EXCEPTION) {
TApplicationException x = TApplicationException.read(iprot_);
iprot_.readMessageEnd();
throw x;
}
if (msg.seqid != seqid_) {
throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, "read_page failed: out of sequence response");
}
read_page_result result = new read_page_result();
result.read(iprot_);
iprot_.readMessageEnd();
if (result.is_set_success()) {
return result.success;
}
throw new TApplicationException(TApplicationException.MISSING_RESULT, "read_page failed: unknown result");
}
}
public static class AsyncClient extends TAsyncClient implements AsyncIface {
public static class Factory implements TAsyncClientFactory<AsyncClient> {
private TAsyncClientManager clientManager;
private TProtocolFactory protocolFactory;
public Factory(TAsyncClientManager clientManager, TProtocolFactory protocolFactory) {
this.clientManager = clientManager;
this.protocolFactory = protocolFactory;
}
public AsyncClient getAsyncClient(TNonblockingTransport transport) {
return new AsyncClient(protocolFactory, clientManager, transport);
}
}
public AsyncClient(TProtocolFactory protocolFactory, TAsyncClientManager clientManager, TNonblockingTransport transport) {
super(protocolFactory, clientManager, transport);
}
public void read_page(String index_code, LogPageToken token, AsyncMethodCallback<read_page_call> resultHandler) throws TException {
checkReady();
read_page_call method_call = new read_page_call(index_code, token, resultHandler, this, protocolFactory, transport);
manager.call(method_call);
}
public static class read_page_call extends TAsyncMethodCall {
private String index_code;
private LogPageToken token;
public read_page_call(String index_code, LogPageToken token, AsyncMethodCallback<read_page_call> resultHandler, TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport) throws TException {
super(client, protocolFactory, transport, resultHandler, false);
this.index_code = index_code;
this.token = token;
}
public void write_args(TProtocol prot) throws TException {
prot.writeMessageBegin(new TMessage("read_page", TMessageType.CALL, 0));
read_page_args args = new read_page_args();
args.set_index_code(index_code);
args.set_token(token);
args.write(prot);
prot.writeMessageEnd();
}
public LogPage getResult() throws TException {
if (getState() != State.RESPONSE_READ) {
throw new IllegalStateException("Method call not finished!");
}
TMemoryInputTransport memoryTransport = new TMemoryInputTransport(getFrameBuffer().array());
TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
return (new Client(prot)).recv_read_page();
}
}
}
public static class Processor implements TProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
public Processor(Iface iface)
{
iface_ = iface;
processMap_.put("read_page", new read_page());
}
protected static interface ProcessFunction {
public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;
}
private Iface iface_;
protected final HashMap<String,ProcessFunction> processMap_ = new HashMap<String,ProcessFunction>();
public boolean process(TProtocol iprot, TProtocol oprot) throws TException
{
TMessage msg = iprot.readMessageBegin();
ProcessFunction fn = processMap_.get(msg.name);
if (fn == null) {
TProtocolUtil.skip(iprot, TType.STRUCT);
iprot.readMessageEnd();
TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
x.write(oprot);
oprot.writeMessageEnd();
oprot.getTransport().flush();
return true;
}
fn.process(msg.seqid, iprot, oprot);
return true;
}
private class read_page implements ProcessFunction {
public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
{
read_page_args args = new read_page_args();
try {
args.read(iprot);
} catch (TProtocolException e) {
iprot.readMessageEnd();
TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
oprot.writeMessageBegin(new TMessage("read_page", TMessageType.EXCEPTION, seqid));
x.write(oprot);
oprot.writeMessageEnd();
oprot.getTransport().flush();
return;
}
iprot.readMessageEnd();
read_page_result result = new read_page_result();
result.success = iface_.read_page(args.index_code, args.token);
oprot.writeMessageBegin(new TMessage("read_page", TMessageType.REPLY, seqid));
result.write(oprot);
oprot.writeMessageEnd();
oprot.getTransport().flush();
}
}
}
public static class read_page_args implements TBase<read_page_args, read_page_args._Fields>, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("read_page_args");
private static final TField INDEX_CODE_FIELD_DESC = new TField("index_code", TType.STRING, (short)1);
private static final TField TOKEN_FIELD_DESC = new TField("token", TType.STRUCT, (short)2);
private String index_code;
private LogPageToken token;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
INDEX_CODE((short)1, "index_code"),
TOKEN((short)2, "token");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // INDEX_CODE
return INDEX_CODE;
case 2: // TOKEN
return TOKEN;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, FieldMetaData> metaDataMap;
static {
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.INDEX_CODE, new FieldMetaData("index_code", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.STRING)));
tmpMap.put(_Fields.TOKEN, new FieldMetaData("token", TFieldRequirementType.DEFAULT,
new StructMetaData(TType.STRUCT, LogPageToken.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(read_page_args.class, metaDataMap);
}
public read_page_args() {
}
public read_page_args(
String index_code,
LogPageToken token)
{
this();
this.index_code = index_code;
this.token = token;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public read_page_args(read_page_args other) {
if (other.is_set_index_code()) {
this.index_code = other.index_code;
}
if (other.is_set_token()) {
this.token = new LogPageToken(other.token);
}
}
public read_page_args deepCopy() {
return new read_page_args(this);
}
@Override
public void clear() {
this.index_code = null;
this.token = null;
}
public String get_index_code() {
return this.index_code;
}
public read_page_args set_index_code(String index_code) {
this.index_code = index_code;
return this;
}
public void unset_index_code() {
this.index_code = null;
}
/** Returns true if field index_code is set (has been asigned a value) and false otherwise */
public boolean is_set_index_code() {
return this.index_code != null;
}
public void set_index_code_isSet(boolean value) {
if (!value) {
this.index_code = null;
}
}
public LogPageToken get_token() {
return this.token;
}
public read_page_args set_token(LogPageToken token) {
this.token = token;
return this;
}
public void unset_token() {
this.token = null;
}
/** Returns true if field token is set (has been asigned a value) and false otherwise */
public boolean is_set_token() {
return this.token != null;
}
public void set_token_isSet(boolean value) {
if (!value) {
this.token = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case INDEX_CODE:
if (value == null) {
unset_index_code();
} else {
set_index_code((String)value);
}
break;
case TOKEN:
if (value == null) {
unset_token();
} else {
set_token((LogPageToken)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case INDEX_CODE:
return get_index_code();
case TOKEN:
return get_token();
}
throw new IllegalStateException();
}
/** 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 INDEX_CODE:
return is_set_index_code();
case TOKEN:
return is_set_token();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof read_page_args)
return this.equals((read_page_args)that);
return false;
}
public boolean equals(read_page_args that) {
if (that == null)
return false;
boolean this_present_index_code = true && this.is_set_index_code();
boolean that_present_index_code = true && that.is_set_index_code();
if (this_present_index_code || that_present_index_code) {
if (!(this_present_index_code && that_present_index_code))
return false;
if (!this.index_code.equals(that.index_code))
return false;
}
boolean this_present_token = true && this.is_set_token();
boolean that_present_token = true && that.is_set_token();
if (this_present_token || that_present_token) {
if (!(this_present_token && that_present_token))
return false;
if (!this.token.equals(that.token))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(read_page_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
read_page_args typedOther = (read_page_args)other;
lastComparison = Boolean.valueOf(is_set_index_code()).compareTo(typedOther.is_set_index_code());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_index_code()) {
lastComparison = TBaseHelper.compareTo(this.index_code, typedOther.index_code);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(is_set_token()).compareTo(typedOther.is_set_token());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_token()) {
lastComparison = TBaseHelper.compareTo(this.token, typedOther.token);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch (field.id) {
case 1: // INDEX_CODE
if (field.type == TType.STRING) {
this.index_code = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // TOKEN
if (field.type == TType.STRUCT) {
this.token = new LogPageToken();
this.token.read(iprot);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.index_code != null) {
oprot.writeFieldBegin(INDEX_CODE_FIELD_DESC);
oprot.writeString(this.index_code);
oprot.writeFieldEnd();
}
if (this.token != null) {
oprot.writeFieldBegin(TOKEN_FIELD_DESC);
this.token.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("read_page_args(");
boolean first = true;
sb.append("index_code:");
if (this.index_code == null) {
sb.append("null");
} else {
sb.append(this.index_code);
}
first = false;
if (!first) sb.append(", ");
sb.append("token:");
if (this.token == null) {
sb.append("null");
} else {
sb.append(this.token);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}
public static class read_page_result implements TBase<read_page_result, read_page_result._Fields>, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("read_page_result");
private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
private LogPage success;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
SUCCESS((short)0, "success");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 0: // SUCCESS
return SUCCESS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, FieldMetaData> metaDataMap;
static {
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
new StructMetaData(TType.STRUCT, LogPage.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(read_page_result.class, metaDataMap);
}
public read_page_result() {
}
public read_page_result(
LogPage success)
{
this();
this.success = success;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public read_page_result(read_page_result other) {
if (other.is_set_success()) {
this.success = new LogPage(other.success);
}
}
public read_page_result deepCopy() {
return new read_page_result(this);
}
@Override
public void clear() {
this.success = null;
}
public LogPage get_success() {
return this.success;
}
public read_page_result set_success(LogPage success) {
this.success = success;
return this;
}
public void unset_success() {
this.success = null;
}
/** Returns true if field success is set (has been asigned a value) and false otherwise */
public boolean is_set_success() {
return this.success != null;
}
public void set_success_isSet(boolean value) {
if (!value) {
this.success = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SUCCESS:
if (value == null) {
unset_success();
} else {
set_success((LogPage)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SUCCESS:
return get_success();
}
throw new IllegalStateException();
}
/** 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 is_set_success();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof read_page_result)
return this.equals((read_page_result)that);
return false;
}
public boolean equals(read_page_result that) {
if (that == null)
return false;
boolean this_present_success = true && this.is_set_success();
boolean that_present_success = true && that.is_set_success();
if (this_present_success || that_present_success) {
if (!(this_present_success && that_present_success))
return false;
if (!this.success.equals(that.success))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(read_page_result other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
read_page_result typedOther = (read_page_result)other;
lastComparison = Boolean.valueOf(is_set_success()).compareTo(typedOther.is_set_success());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_success()) {
lastComparison = TBaseHelper.compareTo(this.success, typedOther.success);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch (field.id) {
case 0: // SUCCESS
if (field.type == TType.STRUCT) {
this.success = new LogPage();
this.success.read(iprot);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(TProtocol oprot) throws TException {
oprot.writeStructBegin(STRUCT_DESC);
if (this.is_set_success()) {
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
this.success.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("read_page_result(");
boolean first = true;
sb.append("success:");
if (this.success == null) {
sb.append("null");
} else {
sb.append(this.success);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}
}