use of org.apache.thrift.TException in project hive by apache.
the class UgiMetaStoreClientFactory method createProxy.
private IMetaStoreClient createProxy(final IMetaStoreClient delegate, final String user, final UserGroupInformation authenticatedUser) {
InvocationHandler handler = new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(Object proxy, final Method method, final Object[] args) throws Throwable {
try {
if (!I_META_STORE_CLIENT_METHODS.contains(method) || authenticatedUser == null) {
return method.invoke(delegate, args);
}
try {
return authenticatedUser.doAs(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
return method.invoke(delegate, args);
}
});
} catch (IOException | InterruptedException e) {
throw new TException("PrivilegedExceptionAction failed as user '" + user + "'.", e);
}
} catch (UndeclaredThrowableException | InvocationTargetException e) {
throw e.getCause();
}
}
};
ClassLoader classLoader = IMetaStoreClient.class.getClassLoader();
Class<?>[] interfaces = new Class<?>[] { IMetaStoreClient.class };
Object proxy = Proxy.newProxyInstance(classLoader, interfaces, handler);
return IMetaStoreClient.class.cast(proxy);
}
use of org.apache.thrift.TException in project hive by apache.
the class MetadataJSONSerializer method deserializeTable.
@Override
public HCatTable deserializeTable(String hcatTableStringRep) throws HCatException {
try {
Table table = new Table();
new TDeserializer(new TJSONProtocol.Factory()).deserialize(table, hcatTableStringRep, "UTF-8");
return new HCatTable(table);
} catch (TException exception) {
if (LOG.isDebugEnabled())
LOG.debug("Could not de-serialize from: " + hcatTableStringRep);
throw new HCatException("Could not de-serialize HCatTable.", exception);
}
}
use of org.apache.thrift.TException in project hive by apache.
the class MetadataJSONSerializer method serializePartitionSpec.
@Override
@InterfaceAudience.LimitedPrivate({ "Hive" })
@InterfaceStability.Evolving
public List<String> serializePartitionSpec(HCatPartitionSpec hcatPartitionSpec) throws HCatException {
try {
List<String> stringReps = new ArrayList<String>();
TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
for (PartitionSpec partitionSpec : hcatPartitionSpec.partitionSpecProxy.toPartitionSpec()) {
stringReps.add(serializer.toString(partitionSpec, "UTF-8"));
}
return stringReps;
} catch (TException serializationException) {
throw new HCatException("Failed to serialize!", serializationException);
}
}
use of org.apache.thrift.TException in project hive by apache.
the class MetadataJSONSerializer method deserializePartition.
@Override
public HCatPartition deserializePartition(String hcatPartitionStringRep) throws HCatException {
try {
Partition partition = new Partition();
new TDeserializer(new TJSONProtocol.Factory()).deserialize(partition, hcatPartitionStringRep, "UTF-8");
return new HCatPartition(null, partition);
} catch (TException exception) {
if (LOG.isDebugEnabled())
LOG.debug("Could not de-serialize partition from: " + hcatPartitionStringRep);
throw new HCatException("Could not de-serialize HCatPartition.", exception);
}
}
use of org.apache.thrift.TException in project hive by apache.
the class TestHeartbeatTimerTask method testRunHeartbeatFailsTException.
@Test
public void testRunHeartbeatFailsTException() throws Exception {
TException exception = new TException();
doThrow(exception).when(mockMetaStoreClient).heartbeat(TRANSACTION_ID, LOCK_ID);
task.run();
}
Aggregations