/**
 * Autogenerated by Thrift Compiler (0.9.2)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.xiaojukeji.carrera.thrift.consumer;

import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;

import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
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 javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2018-10-31")
public class ConsumerService {

  public interface Iface {

    public PullResponse pull(PullRequest request) throws PullException, org.apache.thrift.TException;

    public boolean submit(ConsumeResult result) throws PullException, org.apache.thrift.TException;

    public List<ConsumeStats> getConsumeStats(ConsumeStatsRequest request) throws PullException, org.apache.thrift.TException;

    public FetchResponse fetch(FetchRequest request) throws org.apache.thrift.TException;

    public boolean ack(AckResult result) throws org.apache.thrift.TException;

  }

  public interface AsyncIface {

    public void pull(PullRequest request, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;

    public void submit(ConsumeResult result, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;

    public void getConsumeStats(ConsumeStatsRequest request, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;

    public void fetch(FetchRequest request, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;

    public void ack(AckResult result, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;

  }

  public static class Client extends org.apache.thrift.TServiceClient implements Iface {
    public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
      public Factory() {}
      public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
        return new Client(prot);
      }
      public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
        return new Client(iprot, oprot);
      }
    }

    public Client(org.apache.thrift.protocol.TProtocol prot)
    {
      super(prot, prot);
    }

    public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
      super(iprot, oprot);
    }

    public PullResponse pull(PullRequest request) throws PullException, org.apache.thrift.TException
    {
      send_pull(request);
      return recv_pull();
    }

    public void send_pull(PullRequest request) throws org.apache.thrift.TException
    {
      pull_args args = new pull_args();
      args.setRequest(request);
      sendBase("pull", args);
    }

    public PullResponse recv_pull() throws PullException, org.apache.thrift.TException
    {
      pull_result result = new pull_result();
      receiveBase(result, "pull");
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.error != null) {
        throw result.error;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "pull failed: unknown result");
    }

    public boolean submit(ConsumeResult result) throws PullException, org.apache.thrift.TException
    {
      send_submit(result);
      return recv_submit();
    }

    public void send_submit(ConsumeResult result) throws org.apache.thrift.TException
    {
      submit_args args = new submit_args();
      args.setResult(result);
      sendBase("submit", args);
    }

    public boolean recv_submit() throws PullException, org.apache.thrift.TException
    {
      submit_result result = new submit_result();
      receiveBase(result, "submit");
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.error != null) {
        throw result.error;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "submit failed: unknown result");
    }

    public List<ConsumeStats> getConsumeStats(ConsumeStatsRequest request) throws PullException, org.apache.thrift.TException
    {
      send_getConsumeStats(request);
      return recv_getConsumeStats();
    }

    public void send_getConsumeStats(ConsumeStatsRequest request) throws org.apache.thrift.TException
    {
      getConsumeStats_args args = new getConsumeStats_args();
      args.setRequest(request);
      sendBase("getConsumeStats", args);
    }

    public List<ConsumeStats> recv_getConsumeStats() throws PullException, org.apache.thrift.TException
    {
      getConsumeStats_result result = new getConsumeStats_result();
      receiveBase(result, "getConsumeStats");
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.error != null) {
        throw result.error;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getConsumeStats failed: unknown result");
    }

    public FetchResponse fetch(FetchRequest request) throws org.apache.thrift.TException
    {
      send_fetch(request);
      return recv_fetch();
    }

    public void send_fetch(FetchRequest request) throws org.apache.thrift.TException
    {
      fetch_args args = new fetch_args();
      args.setRequest(request);
      sendBase("fetch", args);
    }

    public FetchResponse recv_fetch() throws org.apache.thrift.TException
    {
      fetch_result result = new fetch_result();
      receiveBase(result, "fetch");
      if (result.isSetSuccess()) {
        return result.success;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "fetch failed: unknown result");
    }

    public boolean ack(AckResult result) throws org.apache.thrift.TException
    {
      send_ack(result);
      return recv_ack();
    }

    public void send_ack(AckResult result) throws org.apache.thrift.TException
    {
      ack_args args = new ack_args();
      args.setResult(result);
      sendBase("ack", args);
    }

    public boolean recv_ack() throws org.apache.thrift.TException
    {
      ack_result result = new ack_result();
      receiveBase(result, "ack");
      if (result.isSetSuccess()) {
        return result.success;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "ack failed: unknown result");
    }

  }
  public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
    public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
      private org.apache.thrift.async.TAsyncClientManager clientManager;
      private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
      public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
        this.clientManager = clientManager;
        this.protocolFactory = protocolFactory;
      }
      public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
        return new AsyncClient(protocolFactory, clientManager, transport);
      }
    }

    public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
      super(protocolFactory, clientManager, transport);
    }

    public void pull(PullRequest request, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
      checkReady();
      pull_call method_call = new pull_call(request, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class pull_call extends org.apache.thrift.async.TAsyncMethodCall {
      private PullRequest request;
      public pull_call(PullRequest request, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
        super(client, protocolFactory, transport, resultHandler, false);
        this.request = request;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("pull", org.apache.thrift.protocol.TMessageType.CALL, 0));
        pull_args args = new pull_args();
        args.setRequest(request);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public PullResponse getResult() throws PullException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new IllegalStateException("Method call not finished!");
        }
        org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
        org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
        return (new Client(prot)).recv_pull();
      }
    }

    public void submit(ConsumeResult result, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
      checkReady();
      submit_call method_call = new submit_call(result, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class submit_call extends org.apache.thrift.async.TAsyncMethodCall {
      private ConsumeResult result;
      public submit_call(ConsumeResult result, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
        super(client, protocolFactory, transport, resultHandler, false);
        this.result = result;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("submit", org.apache.thrift.protocol.TMessageType.CALL, 0));
        submit_args args = new submit_args();
        args.setResult(result);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public boolean getResult() throws PullException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new IllegalStateException("Method call not finished!");
        }
        org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
        org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
        return (new Client(prot)).recv_submit();
      }
    }

    public void getConsumeStats(ConsumeStatsRequest request, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
      checkReady();
      getConsumeStats_call method_call = new getConsumeStats_call(request, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class getConsumeStats_call extends org.apache.thrift.async.TAsyncMethodCall {
      private ConsumeStatsRequest request;
      public getConsumeStats_call(ConsumeStatsRequest request, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
        super(client, protocolFactory, transport, resultHandler, false);
        this.request = request;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getConsumeStats", org.apache.thrift.protocol.TMessageType.CALL, 0));
        getConsumeStats_args args = new getConsumeStats_args();
        args.setRequest(request);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public List<ConsumeStats> getResult() throws PullException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new IllegalStateException("Method call not finished!");
        }
        org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
        org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
        return (new Client(prot)).recv_getConsumeStats();
      }
    }

    public void fetch(FetchRequest request, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
      checkReady();
      fetch_call method_call = new fetch_call(request, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class fetch_call extends org.apache.thrift.async.TAsyncMethodCall {
      private FetchRequest request;
      public fetch_call(FetchRequest request, org.apache.thrift.async.