Search in sources :

Example 86 with TException

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);
}
Also used : TException(org.apache.thrift.TException) Method(java.lang.reflect.Method) IOException(java.io.IOException) IMetaStoreClient(org.apache.hadoop.hive.metastore.IMetaStoreClient) AbstractInvocationHandler(com.google.common.reflect.AbstractInvocationHandler) InvocationHandler(java.lang.reflect.InvocationHandler) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) AbstractInvocationHandler(com.google.common.reflect.AbstractInvocationHandler)

Example 87 with TException

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);
    }
}
Also used : TException(org.apache.thrift.TException) Table(org.apache.hadoop.hive.metastore.api.Table) TDeserializer(org.apache.thrift.TDeserializer) HCatException(org.apache.hive.hcatalog.common.HCatException) LoggerFactory(org.slf4j.LoggerFactory)

Example 88 with TException

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);
    }
}
Also used : TException(org.apache.thrift.TException) TSerializer(org.apache.thrift.TSerializer) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) ArrayList(java.util.ArrayList) HCatException(org.apache.hive.hcatalog.common.HCatException) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec)

Example 89 with TException

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);
    }
}
Also used : TException(org.apache.thrift.TException) Partition(org.apache.hadoop.hive.metastore.api.Partition) TDeserializer(org.apache.thrift.TDeserializer) HCatException(org.apache.hive.hcatalog.common.HCatException) LoggerFactory(org.slf4j.LoggerFactory)

Example 90 with TException

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();
}
Also used : TException(org.apache.thrift.TException) Test(org.junit.Test)

Aggregations

TException (org.apache.thrift.TException)381 IOException (java.io.IOException)164 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)57 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)48 ArrayList (java.util.ArrayList)42 HashMap (java.util.HashMap)40 Table (org.apache.hadoop.hive.metastore.api.Table)38 Map (java.util.Map)30 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)29 AuthorizationException (org.apache.storm.generated.AuthorizationException)27 Test (org.junit.Test)26 List (java.util.List)25 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)24 UnknownHostException (java.net.UnknownHostException)23 TProtocol (org.apache.thrift.protocol.TProtocol)23 FileNotFoundException (java.io.FileNotFoundException)22 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)22 InvalidMetaException (com.netflix.metacat.common.server.connectors.exception.InvalidMetaException)21 LoginException (javax.security.auth.login.LoginException)21 ConnectorException (com.netflix.metacat.common.server.connectors.exception.ConnectorException)20