use of org.apache.thrift.protocol.TProtocolException in project storm by apache.
the class Grouping method tupleSchemeReadValue.
@Override
protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
_Fields setField = _Fields.findByThriftId(fieldID);
if (setField != null) {
switch(setField) {
case FIELDS:
List<String> fields;
{
org.apache.thrift.protocol.TList _list12 = iprot.readListBegin();
fields = new ArrayList<String>(_list12.size);
String _elem13;
for (int _i14 = 0; _i14 < _list12.size; ++_i14) {
_elem13 = iprot.readString();
fields.add(_elem13);
}
iprot.readListEnd();
}
return fields;
case SHUFFLE:
NullStruct shuffle;
shuffle = new NullStruct();
shuffle.read(iprot);
return shuffle;
case ALL:
NullStruct all;
all = new NullStruct();
all.read(iprot);
return all;
case NONE:
NullStruct none;
none = new NullStruct();
none.read(iprot);
return none;
case DIRECT:
NullStruct direct;
direct = new NullStruct();
direct.read(iprot);
return direct;
case CUSTOM_OBJECT:
JavaObject custom_object;
custom_object = new JavaObject();
custom_object.read(iprot);
return custom_object;
case CUSTOM_SERIALIZED:
ByteBuffer custom_serialized;
custom_serialized = iprot.readBinary();
return custom_serialized;
case LOCAL_OR_SHUFFLE:
NullStruct local_or_shuffle;
local_or_shuffle = new NullStruct();
local_or_shuffle.read(iprot);
return local_or_shuffle;
default:
throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
}
} else {
throw new TProtocolException("Couldn't find a field with field id " + fieldID);
}
}
use of org.apache.thrift.protocol.TProtocolException in project storm by apache.
the class JavaObjectArg method tupleSchemeReadValue.
@Override
protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
_Fields setField = _Fields.findByThriftId(fieldID);
if (setField != null) {
switch(setField) {
case INT_ARG:
Integer int_arg;
int_arg = iprot.readI32();
return int_arg;
case LONG_ARG:
Long long_arg;
long_arg = iprot.readI64();
return long_arg;
case STRING_ARG:
String string_arg;
string_arg = iprot.readString();
return string_arg;
case BOOL_ARG:
Boolean bool_arg;
bool_arg = iprot.readBool();
return bool_arg;
case BINARY_ARG:
ByteBuffer binary_arg;
binary_arg = iprot.readBinary();
return binary_arg;
case DOUBLE_ARG:
Double double_arg;
double_arg = iprot.readDouble();
return double_arg;
default:
throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
}
} else {
throw new TProtocolException("Couldn't find a field with field id " + fieldID);
}
}
use of org.apache.thrift.protocol.TProtocolException in project hive by apache.
the class RetryingMetaStoreClient method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object ret = null;
int retriesMade = 0;
TException caughtException = null;
boolean allowReconnect = !method.isAnnotationPresent(NoReconnect.class);
boolean allowRetry = true;
Annotation[] directives = method.getDeclaredAnnotations();
if (directives != null) {
for (Annotation a : directives) {
if (a instanceof RetrySemantics.CannotRetry) {
allowRetry = false;
}
}
}
while (true) {
try {
reloginExpiringKeytabUser();
if (allowReconnect) {
if (retriesMade > 0 || hasConnectionLifeTimeReached(method)) {
base.reconnect();
lastConnectionTime = System.currentTimeMillis();
}
}
if (metaCallTimeMap == null) {
ret = method.invoke(base, args);
} else {
// need to capture the timing
long startTime = System.currentTimeMillis();
ret = method.invoke(base, args);
long timeTaken = System.currentTimeMillis() - startTime;
addMethodTime(method, timeTaken);
}
break;
} catch (UndeclaredThrowableException e) {
throw e.getCause();
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof TApplicationException) {
TApplicationException tae = (TApplicationException) t;
switch(tae.getType()) {
case TApplicationException.UNSUPPORTED_CLIENT_TYPE:
case TApplicationException.UNKNOWN_METHOD:
case TApplicationException.WRONG_METHOD_NAME:
case TApplicationException.INVALID_PROTOCOL:
throw t;
default:
// TODO: most other options are probably unrecoverable... throw?
caughtException = tae;
}
} else if ((t instanceof TProtocolException) || (t instanceof TTransportException)) {
// TODO: most protocol exceptions are probably unrecoverable... throw?
caughtException = (TException) t;
} else if ((t instanceof MetaException) && t.getMessage().matches("(?s).*(JDO[a-zA-Z]*|TProtocol|TTransport)Exception.*") && !t.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException")) {
caughtException = (MetaException) t;
} else {
throw t;
}
} catch (MetaException e) {
if (e.getMessage().matches("(?s).*(IO|TTransport)Exception.*") && !e.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException")) {
caughtException = e;
} else {
throw e;
}
}
if (retriesMade >= retryLimit || base.isLocalMetaStore() || !allowRetry) {
throw caughtException;
}
retriesMade++;
LOG.warn("MetaStoreClient lost connection. Attempting to reconnect (" + retriesMade + " of " + retryLimit + ") after " + retryDelaySeconds + "s. " + method.getName(), caughtException);
Thread.sleep(retryDelaySeconds * 1000);
}
return ret;
}
use of org.apache.thrift.protocol.TProtocolException in project hive by apache.
the class TUGIBasedProcessor method handleSetUGI.
private void handleSetUGI(TUGIContainingTransport ugiTrans, set_ugi<Iface> fn, TMessage msg, TProtocol iprot, TProtocol oprot) throws TException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
UserGroupInformation clientUgi = ugiTrans.getClientUGI();
if (null != clientUgi) {
throw new TException(new IllegalStateException("UGI is already set. Resetting is not " + "allowed. Current ugi is: " + clientUgi.getUserName()));
}
set_ugi_args args = fn.getEmptyArgsInstance();
try {
args.read(iprot);
} catch (TProtocolException e) {
iprot.readMessageEnd();
TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
x.write(oprot);
oprot.writeMessageEnd();
oprot.getTransport().flush();
return;
}
iprot.readMessageEnd();
set_ugi_result result = fn.getResult(iface, args);
List<String> principals = result.getSuccess();
// Store the ugi in transport and then continue as usual.
ugiTrans.setClientUGI(UserGroupInformation.createRemoteUser(principals.remove(principals.size() - 1)));
oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.REPLY, msg.seqid));
result.write(oprot);
oprot.writeMessageEnd();
oprot.getTransport().flush();
}
use of org.apache.thrift.protocol.TProtocolException in project pinpoint by naver.
the class ThriftRequestProperty method writeTraceHeader.
public void writeTraceHeader(ThriftHeader headerKey, TProtocol oprot) throws TException {
Object headerValue = this.thriftHeaders.get(headerKey);
if (headerValue == null) {
return;
}
byte headerType = headerKey.getType();
TField traceField = new TField(headerKey.name(), headerKey.getType(), headerKey.getId());
oprot.writeFieldBegin(traceField);
try {
if (headerType == TType.STRING) {
// these will be read as byte buffer although it's probably safe to just use writeString here.
// see org.apache.thrift.protocol.TProtocolUtil.skip(TProtocol, byte, int)
oprot.writeBinary(stringToByteBuffer((String) headerValue));
} else if (headerType == TType.I64) {
oprot.writeI64((Long) headerValue);
} else if (headerType == TType.I16) {
oprot.writeI16((Short) headerValue);
} else if (headerType == TType.BOOL) {
oprot.writeBool((Boolean) headerValue);
} else {
throw new TProtocolException("Invalid pinpoint header type - " + headerType);
}
} finally {
oprot.writeFieldEnd();
}
}
Aggregations