Thrift-RPC client in Flume
Get RpcClient from RpcClientFactory with Reflection programming
Message or Event definition in Flum
public interface Event { /**
* Returns a map of name-value pairs describing the data stored in the body.
*/
public Map<String, String> getHeaders(); /**
* Set the event headers
* @param headers Map of headers to replace the current headers.
*/
public void setHeaders(Map<String, String> headers); /**
* Returns the raw byte array of the data contained in this event.
*/
public byte[] getBody(); /**
* Sets the raw byte array of the data contained in this event.
* @param body The data.
*/
public void setBody(byte[] body); }
/**
* Factory class to construct Flume {@link RPCClient} implementations.
*/
public class RpcClientFactory { @SuppressWarnings("unchecked")
public static RpcClient getInstance(Properties properties)
throws FlumeException {
String type = null;
type = properties.getProperty(
RpcClientConfigurationConstants.CONFIG_CLIENT_TYPE);
if (type == null || type.isEmpty()) {
type = ClientType.DEFAULT.getClientClassName();
}
Class<? extends AbstractRpcClient> clazz;
AbstractRpcClient client;
try {
String clientClassType = type;
ClientType clientType = null;
try {
clientType = ClientType.valueOf(type.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
clientType = ClientType.OTHER;
}
if (!clientType.equals(ClientType.OTHER)) {
clientClassType = clientType.getClientClassName();
}
clazz =
(Class<? extends AbstractRpcClient>) Class.forName(clientClassType);
} catch (ClassNotFoundException e) {
throw new FlumeException("No such client!", e);
} try {
client = clazz.newInstance();
} catch (InstantiationException e) {
throw new FlumeException("Cannot instantiate client. " +
"Exception follows:", e);
} catch (IllegalAccessException e) {
throw new FlumeException("Cannot instantiate client. " +
"Exception follows:", e);
}
client.configure(properties);
return client; } public static RpcClient getThriftInstance(String hostname, Integer port, Integer batchSize) {
if (hostname == null) {
throw new NullPointerException("hostname must not be null");
}
if (port == null) {
throw new NullPointerException("port must not be null");
}
if (batchSize == null) {
throw new NullPointerException("batchSize must not be null");
} Properties props = new Properties();
props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1",
hostname + ":" + port.intValue());
props.setProperty(RpcClientConfigurationConstants.CONFIG_BATCH_SIZE, batchSize.toString());
ThriftRpcClient client = new ThriftRpcClient();
client.configure(props);
return client;
} public static RpcClient getThriftInstance(String hostname, Integer port) {
return getThriftInstance(hostname, port, RpcClientConfigurationConstants
.DEFAULT_BATCH_SIZE);
} public static RpcClient getThriftInstance(Properties props) {
props.setProperty(RpcClientConfigurationConstants.CONFIG_CLIENT_TYPE,
ClientType.THRIFT.clientClassName);
return getInstance(props);
} public static enum ClientType {
OTHER(null),
DEFAULT(NettyAvroRpcClient.class.getCanonicalName()),
DEFAULT_FAILOVER(FailoverRpcClient.class.getCanonicalName()),
DEFAULT_LOADBALANCE(LoadBalancingRpcClient.class.getCanonicalName()),
THRIFT(ThriftRpcClient.class.getCanonicalName()); private final String clientClassName; private ClientType(String className) {
this.clientClassName = className;
} protected String getClientClassName() {
return this.clientClassName;
} }
}
Define ThriftRpcClient implementing RpcClient
public class ThriftRpcClient extends AbstractRpcClient {
private ConnectionPoolManager connectionManager;
private final ExecutorService callTimeoutPool;
private final AtomicLong threadCounter;
private final Random random = new Random();
private String protocol; private boolean enableSsl;
private String truststore;
private String truststorePassword;
private String truststoreType;
private final List<String> excludeProtocols = new LinkedList<String>(); public ThriftRpcClient() {
stateLock = new ReentrantLock(true);
connState = State.INIT;
threadCounter = new AtomicLong(0);
callTimeoutPool = Executors.newCachedThreadPool(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("Flume Thrift RPC thread - " + String.valueOf(threadCounter.incrementAndGet()));
return t;
}
});
} @Override
public void append(Event event) throws EventDeliveryException {
ClientWrapper client = null;
boolean destroyedClient = false;
try {
if (!isActive()) {
throw new EventDeliveryException("Client was closed due to error. " +
"Please create a new client");
}
client = connectionManager.checkout();
final ThriftFlumeEvent thriftEvent = new ThriftFlumeEvent(event.getHeaders(), ByteBuffer.wrap(event.getBody()));
doAppend(client, thriftEvent).get(requestTimeout, TimeUnit.MILLISECONDS);
} catch (Throwable e) {
if (e instanceof ExecutionException) {
Throwable cause = e.getCause();
if (cause instanceof EventDeliveryException) {
throw (EventDeliveryException) cause;
} else if (cause instanceof TimeoutException) {
throw new EventDeliveryException("Append call timeout", cause);
}
}
destroyedClient = true;
// If destroy throws, we still don't want to reuse the client, so mark it
// as destroyed before we actually do.
if (client != null) {
connectionManager.destroy(client);
}
if (e instanceof Error) {
throw (Error) e;
} else if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new EventDeliveryException("Failed to send event. ", e);
} finally {
if (client != null && !destroyedClient) {
connectionManager.checkIn(client);
}
}
} private Future<Void> doAppend(final ClientWrapper client,
final ThriftFlumeEvent e) throws Exception { return callTimeoutPool.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
Status status = client.client.append(e);
if (status != Status.OK) {
throw new EventDeliveryException("Failed to deliver events. Server " +
"returned status : " + status.name());
}
return null;
}
});
} private Future<Void> doAppendBatch(final ClientWrapper client,
final List<ThriftFlumeEvent> e) throws Exception {
return callTimeoutPool.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
Status status = client.client.appendBatch(e);
if (status != Status.OK) {
throw new EventDeliveryException("Failed to deliver events. Server " +
"returned status : " + status.name());
}
return null;
}
});
} @Override
public boolean isActive() {
stateLock.lock();
try {
return (connState == State.READY);
} finally {
stateLock.unlock();
}
}
/**
* Wrapper around a client and transport, so we can clean up when this
* client gets closed.
*/
private class ClientWrapper {
public final ThriftSourceProtocol.Client client;
public final TTransport transport;
private final int hashCode; public ClientWrapper() throws Exception {
TSocket tsocket;
if (enableSsl) {
// JDK6's factory doesn't appear to pass the protocol onto the Socket
// properly so we have to do some magic to make sure that happens.
// Not an issue in JDK7 Lifted from thrift-0.9.1 to make the SSLContext
SSLContext sslContext = createSSLContext(truststore, truststorePassword,
truststoreType); // Create the factory from it
SSLSocketFactory sslSockFactory = sslContext.getSocketFactory(); // Create the TSocket from that
tsocket = createSSLSocket(
sslSockFactory, hostname, port, 120000, excludeProtocols);
} else {
tsocket = new TSocket(hostname, port);
} transport = getTransport(tsocket); // The transport is already open for SSL as part of TSSLTransportFactory.getClientSocket
if (!transport.isOpen()) {
transport.open();
}
if (protocol.equals(BINARY_PROTOCOL)) {
LOGGER.info("Using TBinaryProtocol");
client = new ThriftSourceProtocol.Client(new TBinaryProtocol(transport));
} else {
LOGGER.info("Using TCompactProtocol");
client = new ThriftSourceProtocol.Client(new TCompactProtocol(transport));
}
// Not a great hash code, but since this class is immutable and there
// is at most one instance of the components of this class,
// this works fine [If the objects are equal, hash code is the same]
hashCode = random.nextInt();
} public boolean equals(Object o) {
if (o == null) {
return false;
}
// Since there is only one wrapper with any given client,
// direct comparison is good enough.
if (this == o) {
return true;
}
return false;
} public int hashCode() {
return hashCode;
}
} private class ConnectionPoolManager {
private final Queue<ClientWrapper> availableClients;
private final Set<ClientWrapper> checkedOutClients;
private final int maxPoolSize;
private int currentPoolSize;
private final Lock poolLock;
private final Condition availableClientsCondition; public ConnectionPoolManager(int poolSize) {
this.maxPoolSize = poolSize;
availableClients = new LinkedList<ClientWrapper>();
checkedOutClients = new HashSet<ClientWrapper>();
poolLock = new ReentrantLock();
availableClientsCondition = poolLock.newCondition();
currentPoolSize = 0;
} public ClientWrapper checkout() throws Exception { ClientWrapper ret = null;
poolLock.lock();
try {
if (availableClients.isEmpty() && currentPoolSize < maxPoolSize) {
ret = new ClientWrapper();
currentPoolSize++;
checkedOutClients.add(ret);
return ret;
}
while (availableClients.isEmpty()) {
availableClientsCondition.await();
}
ret = availableClients.poll();
checkedOutClients.add(ret);
} finally {
poolLock.unlock();
}
return ret;
} public void checkIn(ClientWrapper client) {
poolLock.lock();
try {
availableClients.add(client);
checkedOutClients.remove(client);
availableClientsCondition.signal();
} finally {
poolLock.unlock();
}
} public void destroy(ClientWrapper client) {
poolLock.lock();
try {
checkedOutClients.remove(client);
currentPoolSize--;
} finally {
poolLock.unlock();
}
client.transport.close();
} public void closeAll() {
poolLock.lock();
try {
for (ClientWrapper c : availableClients) {
c.transport.close();
currentPoolSize--;
}
for (ClientWrapper c : checkedOutClients) {
c.transport.close();
currentPoolSize--;
}
} finally {
poolLock.unlock();
}
}
}
private static SSLContext createSSLContext(String truststore,
String truststorePassword,
String truststoreType) throws FlumeException {
SSLContext ctx;
try {
ctx = SSLContext.getInstance("TLS");
TrustManagerFactory tmf;
tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore ts = null;
if (truststore != null && truststoreType != null) {
ts = KeyStore.getInstance(truststoreType);
ts.load(new FileInputStream(truststore), truststorePassword.toCharArray());
tmf.init(ts);
} tmf.init(ts);
ctx.init(null, tmf.getTrustManagers(), null); } catch (Exception e) {
throw new FlumeException("Error creating the transport", e);
}
return ctx;
}
private static TSocket createSSLSocket(SSLSocketFactory factory, String host,
int port, int timeout, List<String> excludeProtocols)
throws FlumeException {
try {
SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
socket.setSoTimeout(timeout); List<String> enabledProtocols = new ArrayList<String>();
for (String protocol : socket.getEnabledProtocols()) {
if (!excludeProtocols.contains(protocol)) {
enabledProtocols.add(protocol);
}
}
socket.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
return new TSocket(socket);
} catch (Exception e) {
throw new FlumeException("Could not connect to " + host + " on port " + port, e);
}
}
}
Now we look at ThriftSourceProtocol
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 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);
}
}
..................................
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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 Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.flume.thrift; import org.apache.commons.lang.builder.HashCodeBuilder;
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; public class ThriftSourceProtocol { public interface Iface { public Status append(ThriftFlumeEvent event) throws org.apache.thrift.TException; public Status appendBatch(List<ThriftFlumeEvent> events) throws org.apache.thrift.TException; } public interface AsyncIface { public void append(ThriftFlumeEvent event, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.append_call> resultHandler) throws org.apache.thrift.TException; public void appendBatch(List<ThriftFlumeEvent> events, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.appendBatch_call> 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 Status append(ThriftFlumeEvent event) throws org.apache.thrift.TException
{
send_append(event);
return recv_append();
} public void send_append(ThriftFlumeEvent event) throws org.apache.thrift.TException
{
append_args args = new append_args();
args.setEvent(event);
sendBase("append", args);
} public Status recv_append() throws org.apache.thrift.TException
{
append_result result = new append_result();
receiveBase(result, "append");
if (result.isSetSuccess()) {
return result.success;
}
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "append failed: unknown result");
} public Status appendBatch(List<ThriftFlumeEvent> events) throws org.apache.thrift.TException
{
send_appendBatch(events);
return recv_appendBatch();
} public void send_appendBatch(List<ThriftFlumeEvent> events) throws org.apache.thrift.TException
{
appendBatch_args args = new appendBatch_args();
args.setEvents(events);
sendBase("appendBatch", args);
} public Status recv_appendBatch() throws org.apache.thrift.TException
{
appendBatch_result result = new appendBatch_result();
receiveBase(result, "appendBatch");
if (result.isSetSuccess()) {
return result.success;
}
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "appendBatch 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 append(ThriftFlumeEvent event, org.apache.thrift.async.AsyncMethodCallback<append_call> resultHandler) throws org.apache.thrift.TException {
checkReady();
append_call method_call = new append_call(event, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
___manager.call(method_call);
} public static class append_call extends org.apache.thrift.async.TAsyncMethodCall {
private ThriftFlumeEvent event;
public append_call(ThriftFlumeEvent event, org.apache.thrift.async.AsyncMethodCallback<append_call> 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.event = event;
} public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("append", org.apache.thrift.protocol.TMessageType.CALL, 0));
append_args args = new append_args();
args.setEvent(event);
args.write(prot);
prot.writeMessageEnd();
} public Status getResult() throws 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_append();
}
} public void appendBatch(List<ThriftFlumeEvent> events, org.apache.thrift.async.AsyncMethodCallback<appendBatch_call> resultHandler) throws org.apache.thrift.TException {
checkReady();
appendBatch_call method_call = new appendBatch_call(events, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
___manager.call(method_call);
} public static class appendBatch_call extends org.apache.thrift.async.TAsyncMethodCall {
private List<ThriftFlumeEvent> events;
public appendBatch_call(List<ThriftFlumeEvent> events, org.apache.thrift.async.AsyncMethodCallback<appendBatch_call> 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.events = events;
} public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("appendBatch", org.apache.thrift.protocol.TMessageType.CALL, 0));
appendBatch_args args = new appendBatch_args();
args.setEvents(events);
args.write(prot);
prot.writeMessageEnd();
} public Status getResult() throws 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_appendBatch();
}
} } public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
public Processor(I iface) {
super(iface, getProcessMap(new HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
} protected Processor(I iface, Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
super(iface, getProcessMap(processMap));
} private static <I extends Iface> Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
processMap.put("append", new append());
processMap.put("appendBatch", new appendBatch());
return processMap;
} private static class append<I extends Iface> extends org.apache.thrift.ProcessFunction<I, append_args> {
public append() {
super("append");
} public append_args getEmptyArgsInstance() {
return new append_args();
} public append_result getResult(I iface, append_args args) throws org
.apache.thrift.TException {
append_result result = new append_result();
result.success = iface.append(args.event);
return result;
} protected boolean isOneway() {
return false;
}
} private static class appendBatch<I extends Iface> extends org.apache.thrift.ProcessFunction<I, appendBatch_args> {
public appendBatch() {
super("appendBatch");
} public appendBatch_args getEmptyArgsInstance() {
return new appendBatch_args();
} public appendBatch_result getResult(I iface, appendBatch_args args)
throws org.apache.thrift.TException {
appendBatch_result result = new appendBatch_result();
result.success = iface.appendBatch(args.events);
return result;
} protected boolean isOneway() {
return false;
}
} } public static class append_args implements org.apache.thrift.TBase<append_args, append_args._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("append_args"); private static final org.apache.thrift.protocol.TField EVENT_FIELD_DESC = new org.apache.thrift.protocol.TField("event", org.apache.thrift.protocol.TType.STRUCT, (short)1); public ThriftFlumeEvent event; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
EVENT((short)1, "event"); 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: // EVENT
return EVENT;
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, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.EVENT, new org.apache.thrift.meta_data.FieldMetaData("event", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ThriftFlumeEvent.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(append_args.class, metaDataMap);
} public append_args() {
} public append_args(
ThriftFlumeEvent event)
{
this();
this.event = event;
} /**
* Performs a deep copy on <i>other</i>.
*/
public append_args(append_args other) {
if (other.isSetEvent()) {
this.event = new ThriftFlumeEvent(other.event);
}
} public append_args deepCopy() {
return new append_args(this);
} @Override
public void clear() {
this.event = null;
} public ThriftFlumeEvent getEvent() {
return this.event;
} public append_args setEvent(ThriftFlumeEvent event) {
this.event = event;
return this;
} public void unsetEvent() {
this.event = null;
} /** Returns true if field event is set (has been assigned a value) and false otherwise */
public boolean isSetEvent() {
return this.event != null;
} public void setEventIsSet(boolean value) {
if (!value) {
this.event = null;
}
} public void setFieldValue(_Fields field, Object value) {
switch (field) {
case EVENT:
if (value == null) {
unsetEvent();
} else {
setEvent((ThriftFlumeEvent)value);
}
break; }
} public Object getFieldValue(_Fields field) {
switch (field) {
case EVENT:
return getEvent(); }
throw new IllegalStateException();
} /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
} switch (field) {
case EVENT:
return isSetEvent();
}
throw new IllegalStateException();
} @Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof append_args)
return this.equals((append_args)that);
return false;
} public boolean equals(append_args that) {
if (that == null)
return false; boolean this_present_event = true && this.isSetEvent();
boolean that_present_event = true && that.isSetEvent();
if (this_present_event || that_present_event) {
if (!(this_present_event && that_present_event))
return false;
if (!this.event.equals(that.event))
return false;
} return true;
} @Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder(); boolean present_event = true && (isSetEvent());
builder.append(present_event);
if (present_event)
builder.append(event); return builder.toHashCode();
} public int compareTo(append_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
} int lastComparison = 0;
append_args typedOther = (append_args)other; lastComparison = Boolean.valueOf(isSetEvent()).compareTo(typedOther.isSetEvent());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetEvent()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.event, typedOther.event);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
} public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
} public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // EVENT
if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
this.event = new ThriftFlumeEvent();
this.event.read(iprot);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.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(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate(); oprot.writeStructBegin(STRUCT_DESC);
if (this.event != null) {
oprot.writeFieldBegin(EVENT_FIELD_DESC);
this.event.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
} @Override
public String toString() {
StringBuilder sb = new StringBuilder("append_args(");
boolean first = true; sb.append("event:");
if (this.event == null) {
sb.append("null");
} else {
sb.append(this.event);
}
first = false;
sb.append(")");
return sb.toString();
} public void validate() throws org.apache.thrift.TException {
// check for required fields
} private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} } public static class append_result implements org.apache.thrift.TBase<append_result, append_result._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("append_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.I32, (short)0); /**
*
* @see Status
*/
public Status success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
/**
*
* @see Status
*/
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, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Status.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(append_result.class, metaDataMap);
} public append_result() {
} public append_result(
Status success)
{
this();
this.success = success;
} /**
* Performs a deep copy on <i>other</i>.
*/
public append_result(append_result other) {
if (other.isSetSuccess()) {
this.success = other.success;
}
} public append_result deepCopy() {
return new append_result(this);
} @Override
public void clear() {
this.success = null;
} /**
*
* @see Status
*/
public Status getSuccess() {
return this.success;
} /**
*
* @see Status
*/
public append_result setSuccess(Status success) {
this.success = success;
return this;
} public void unsetSuccess() {
this.success = null;
} /** Returns true if field success is set (has been assigned a value) and false otherwise */
public boolean isSetSuccess() {
return this.success != null;
} public void setSuccessIsSet(boolean value) {
if (!value) {
this.success = null;
}
} public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SUCCESS:
if (value == null) {
unsetSuccess();
} else {
setSuccess((Status)value);
}
break; }
} public Object getFieldValue(_Fields field) {
switch (field) {
case SUCCESS:
return getSuccess(); }
throw new IllegalStateException();
} /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
} switch (field) {
case SUCCESS:
return isSetSuccess();
}
throw new IllegalStateException();
} @Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof append_result)
return this.equals((append_result)that);
return false;
} public boolean equals(append_result that) {
if (that == null)
return false; boolean this_present_success = true && this.isSetSuccess();
boolean that_present_success = true && that.isSetSuccess();
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() {
HashCodeBuilder builder = new HashCodeBuilder(); boolean present_success = true && (isSetSuccess());
builder.append(present_success);
if (present_success)
builder.append(success.getValue()); return builder.toHashCode();
} public int compareTo(append_result other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
} int lastComparison = 0;
append_result typedOther = (append_result)other; lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSuccess()) {
lastComparison = org.apache.thrift.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(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 0: // SUCCESS
if (field.type == org.apache.thrift.protocol.TType.I32) {
this.success = Status.findByValue(iprot.readI32());
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.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(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
oprot.writeStructBegin(STRUCT_DESC); if (this.isSetSuccess()) {
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
oprot.writeI32(this.success.getValue());
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
} @Override
public String toString() {
StringBuilder sb = new StringBuilder("append_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 org.apache.thrift.TException {
// check for required fields
} private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} } public static class appendBatch_args implements org.apache.thrift.TBase<appendBatch_args, appendBatch_args._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("appendBatch_args"); private static final org.apache.thrift.protocol.TField EVENTS_FIELD_DESC = new org.apache.thrift.protocol.TField("events", org.apache.thrift.protocol.TType.LIST, (short)1); public List<ThriftFlumeEvent> events; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
EVENTS((short)1, "events"); 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: // EVENTS
return EVENTS;
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, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.EVENTS, new org.apache.thrift.meta_data.FieldMetaData("events", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ThriftFlumeEvent.class))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(appendBatch_args.class, metaDataMap);
} public appendBatch_args() {
} public appendBatch_args(
List<ThriftFlumeEvent> events)
{
this();
this.events = events;
} /**
* Performs a deep copy on <i>other</i>.
*/
public appendBatch_args(appendBatch_args other) {
if (other.isSetEvents()) {
List<ThriftFlumeEvent> __this__events = new ArrayList<ThriftFlumeEvent>();
for (ThriftFlumeEvent other_element : other.events) {
__this__events.add(new ThriftFlumeEvent(other_element));
}
this.events = __this__events;
}
} public appendBatch_args deepCopy() {
return new appendBatch_args(this);
} @Override
public void clear() {
this.events = null;
} public int getEventsSize() {
return (this.events == null) ? 0 : this.events.size();
} public java.util.Iterator<ThriftFlumeEvent> getEventsIterator() {
return (this.events == null) ? null : this.events.iterator();
} public void addToEvents(ThriftFlumeEvent elem) {
if (this.events == null) {
this.events = new ArrayList<ThriftFlumeEvent>();
}
this.events.add(elem);
} public List<ThriftFlumeEvent> getEvents() {
return this.events;
} public appendBatch_args setEvents(List<ThriftFlumeEvent> events) {
this.events = events;
return this;
} public void unsetEvents() {
this.events = null;
} /** Returns true if field events is set (has been assigned a value) and false otherwise */
public boolean isSetEvents() {
return this.events != null;
} public void setEventsIsSet(boolean value) {
if (!value) {
this.events = null;
}
} public void setFieldValue(_Fields field, Object value) {
switch (field) {
case EVENTS:
if (value == null) {
unsetEvents();
} else {
setEvents((List<ThriftFlumeEvent>)value);
}
break; }
} public Object getFieldValue(_Fields field) {
switch (field) {
case EVENTS:
return getEvents(); }
throw new IllegalStateException();
} /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
} switch (field) {
case EVENTS:
return isSetEvents();
}
throw new IllegalStateException();
} @Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof appendBatch_args)
return this.equals((appendBatch_args)that);
return false;
} public boolean equals(appendBatch_args that) {
if (that == null)
return false; boolean this_present_events = true && this.isSetEvents();
boolean that_present_events = true && that.isSetEvents();
if (this_present_events || that_present_events) {
if (!(this_present_events && that_present_events))
return false;
if (!this.events.equals(that.events))
return false;
} return true;
} @Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder(); boolean present_events = true && (isSetEvents());
builder.append(present_events);
if (present_events)
builder.append(events); return builder.toHashCode();
} public int compareTo(appendBatch_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
} int lastComparison = 0;
appendBatch_args typedOther = (appendBatch_args)other; lastComparison = Boolean.valueOf(isSetEvents()).compareTo(typedOther.isSetEvents());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetEvents()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.events, typedOther.events);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
} public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
} public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // EVENTS
if (field.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list5 = iprot.readListBegin();
this.events = new ArrayList<ThriftFlumeEvent>(_list5.size);
for (int _i6 = 0; _i6 < _list5.size; ++_i6)
{
ThriftFlumeEvent _elem7; // required
_elem7 = new ThriftFlumeEvent();
_elem7.read(iprot);
this.events.add(_elem7);
}
iprot.readListEnd();
}
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.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(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate(); oprot.writeStructBegin(STRUCT_DESC);
if (this.events != null) {
oprot.writeFieldBegin(EVENTS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.events.size()));
for (ThriftFlumeEvent _iter8 : this.events)
{
_iter8.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
} @Override
public String toString() {
StringBuilder sb = new StringBuilder("appendBatch_args(");
boolean first = true; sb.append("events:");
if (this.events == null) {
sb.append("null");
} else {
sb.append(this.events);
}
first = false;
sb.append(")");
return sb.toString();
} public void validate() throws org.apache.thrift.TException {
// check for required fields
} private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} } public static class appendBatch_result implements org.apache.thrift.TBase<appendBatch_result, appendBatch_result._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("appendBatch_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.I32, (short)0); /**
*
* @see Status
*/
public Status success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
/**
*
* @see Status
*/
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, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Status.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(appendBatch_result.class, metaDataMap);
} public appendBatch_result() {
} public appendBatch_result(
Status success)
{
this();
this.success = success;
} /**
* Performs a deep copy on <i>other</i>.
*/
public appendBatch_result(appendBatch_result other) {
if (other.isSetSuccess()) {
this.success = other.success;
}
} public appendBatch_result deepCopy() {
return new appendBatch_result(this);
} @Override
public void clear() {
this.success = null;
} /**
*
* @see Status
*/
public Status getSuccess() {
return this.success;
} /**
*
* @see Status
*/
public appendBatch_result setSuccess(Status success) {
this.success = success;
return this;
} public void unsetSuccess() {
this.success = null;
} /** Returns true if field success is set (has been assigned a value) and false otherwise */
public boolean isSetSuccess() {
return this.success != null;
} public void setSuccessIsSet(boolean value) {
if (!value) {
this.success = null;
}
} public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SUCCESS:
if (value == null) {
unsetSuccess();
} else {
setSuccess((Status)value);
}
break; }
} public Object getFieldValue(_Fields field) {
switch (field) {
case SUCCESS:
return getSuccess(); }
throw new IllegalStateException();
} /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
} switch (field) {
case SUCCESS:
return isSetSuccess();
}
throw new IllegalStateException();
} @Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof appendBatch_result)
return this.equals((appendBatch_result)that);
return false;
} public boolean equals(appendBatch_result that) {
if (that == null)
return false; boolean this_present_success = true && this.isSetSuccess();
boolean that_present_success = true && that.isSetSuccess();
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() {
HashCodeBuilder builder = new HashCodeBuilder(); boolean present_success = true && (isSetSuccess());
builder.append(present_success);
if (present_success)
builder.append(success.getValue()); return builder.toHashCode();
} public int compareTo(appendBatch_result other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
} int lastComparison = 0;
appendBatch_result typedOther = (appendBatch_result)other; lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSuccess()) {
lastComparison = org.apache.thrift.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(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 0: // SUCCESS
if (field.type == org.apache.thrift.protocol.TType.I32) {
this.success = Status.findByValue(iprot.readI32());
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.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(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
oprot.writeStructBegin(STRUCT_DESC); if (this.isSetSuccess()) {
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
oprot.writeI32(this.success.getValue());
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
} @Override
public String toString() {
StringBuilder sb = new StringBuilder("appendBatch_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 org.apache.thrift.TException {
// check for required fields
} private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} } }
Thrift-RPC client in Flume的更多相关文章
- Thrift 个人实战--Thrift 服务化 Client的改造
前言: Thrift作为Facebook开源的RPC框架, 通过IDL中间语言, 并借助代码生成引擎生成各种主流语言的rpc框架服务端/客户端代码. 不过Thrift的实现, 简单使用离实际生产环境还 ...
- 利用thrift rpc进行C++与Go的通信
一:什么是rpc rpc通俗来理解就是远程调用函数,相对于本地调用来说,只需要在主调函数中调用被掉函数即可,代码如下: void fun(int i) { cout << "fu ...
- Avro-RPC client in Flume
Avro used in Flume Define the interface of RpcClient public interface RpcClient { public int getBatc ...
- thrift RPC 框架的自我搭建
安装thrift rpc 安装的系统是Centos 7 未成功的方法 :(原因没找到,但是还是要记录下) 安装依赖库 yum install automake libtool flex bison ...
- Thrift RPC Golang、C++ Example
Thrift RPC Example 运行 请直接使用即可,无需拉取任何依赖包. cd $GOPATH/src git clone https://github.com/hunterhug/thrif ...
- 又一个半成品库 weblog rpc client
我基本上属于半成品专业户,去看我的github就知道. 下午又撸了一个weblog rpc client库,而这又一次证明了一个有技术但没有产品能力的程序员是没有卵用的. 因为当做好了库的雏形,但与具 ...
- 用NFS挂载root出现:NFS: failed to create MNT RPC client, status=-101(-110)
2014-02-18 08:06:17 By Ly #Linux 阅读(78) 评论(0) 错误信息如下: Root-NFS: nfsroot=/home/zenki/nfs/rootfs NFS ...
- 使用Zeppelin时出现at org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService$Client.recv_getFormType(RemoteInterpreterService.java:288)错误的解决办法(图文详解)
不多说,直接上干货! 问题详解 org.apache.thrift.TApplicationException: Internal error processing getFormType at or ...
- thrift rpc通信
thrift rpc通信 框架 别人的简历: 负责抓取程序的开发和维护,对抓取内容进行数据提取.整理.1.定向数据抓取程序的维护和开发,了解了Sqlite数据库.Thrift服务和多线程的开发调试.2 ...
随机推荐
- python全栈开发_day3_数据类型,输入输出及运算符
一:常见数据类型 1)int整型 例:age=1 整型常用于年龄,账号等 2)float浮点型 例:salary=5.1 浮点型常用于薪水,身高,体重等 3)str字符串类型 例:name=“chen ...
- golang (2) package
综述 golang package是基本的管理单元,package是golang最基本的分发单位和工程管理中依赖关系的体现. 每个golang源代码文件开头都拥有一个package声明,表示该gola ...
- 第十次 Scrum Meeting
第十次 Scrum Meeting 写在前面 会议时间 会议时长 会议地点 2019/4/16 14:30 30min 新主楼F座2F 附Github仓库:WEDO 例会照片 工作情况总结 人员 上阶 ...
- TR-069_Amendment-4:附录G.穿越NAT网关的连接请求方式
注意:这种机制只适用于RFC 3489[21]中定义的经典STUN,RFC 5389引入后,这个机制已经过时.这个机制不是设计用于RFC 5389中定义的STUN.IPv6部署要么不使用NAT,要么以 ...
- [JAVA]Apache FTPClient操作“卡死”问题的分析和解决
最近在和一个第三方的合作中不得已需要使用FTP文件接口.由于FTP Server由对方提供,而且双方背后各自的网络环境都很不单纯等等原因,造成测试环境无法模拟实际情况.测试环境中程序一切正常,但是在部 ...
- Spark standalone简介与运行wordcount(master、slave1和slave2)
前期博客 Spark standalone模式的安装(spark-1.6.1-bin-hadoop2.6.tgz)(master.slave1和slave2) Spark运行模式概述 1. Stan ...
- Django开发步骤
Django开发步骤 Django框架每次开发的初始化的套路都基本一样,这里记录一下. 安装Django 首先安装Python软件,上python官网下载对应的安装包.接下来就是安装Django: p ...
- Python机器学习库sklearn的安装
Python机器学习库sklearn的安装 scikit-learn是Python的一个开源机器学习模块,它建立在NumPy,SciPy和matplotlib模块之上能够为用户提供各种机器学习算法接口 ...
- PHP常用文件操作
<?php $path = "/home/work/srccode/hello.go"; $dirName = dirname($path); $name = basenam ...
- [转]微信小程序联盟 跳坑《一百八十一》设置API:wx.openSetting使用说明
本文转自:http://www.wxapp-union.com/forum.php?mod=viewthread&tid=4066 这个API解决了过去一个长久以来无法解决的问题,如何让用户重 ...