Search in sources :

Example 11 with TProtocolException

use of org.apache.thrift.protocol.TProtocolException in project pinpoint by naver.

the class TAnnotationValue 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 STRING_VALUE:
                String stringValue;
                stringValue = iprot.readString();
                return stringValue;
            case BOOL_VALUE:
                Boolean boolValue;
                boolValue = iprot.readBool();
                return boolValue;
            case INT_VALUE:
                Integer intValue;
                intValue = iprot.readI32();
                return intValue;
            case LONG_VALUE:
                Long longValue;
                longValue = iprot.readI64();
                return longValue;
            case SHORT_VALUE:
                Short shortValue;
                shortValue = iprot.readI16();
                return shortValue;
            case DOUBLE_VALUE:
                Double doubleValue;
                doubleValue = iprot.readDouble();
                return doubleValue;
            case BINARY_VALUE:
                ByteBuffer binaryValue;
                binaryValue = iprot.readBinary();
                return binaryValue;
            case BYTE_VALUE:
                Byte byteValue;
                byteValue = iprot.readByte();
                return byteValue;
            case INT_STRING_VALUE:
                TIntStringValue intStringValue;
                intStringValue = new TIntStringValue();
                intStringValue.read(iprot);
                return intStringValue;
            case INT_STRING_STRING_VALUE:
                TIntStringStringValue intStringStringValue;
                intStringStringValue = new TIntStringStringValue();
                intStringStringValue.read(iprot);
                return intStringStringValue;
            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);
    }
}
Also used : ByteBuffer(java.nio.ByteBuffer) TProtocolException(org.apache.thrift.protocol.TProtocolException)

Example 12 with TProtocolException

use of org.apache.thrift.protocol.TProtocolException in project hive by apache.

the class TUGIBasedProcessor method handleSetUGI.

private void handleSetUGI(TUGIContainingTransport ugiTrans, ThriftHiveMetastore.Processor.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();
}
Also used : TException(org.apache.thrift.TException) ThriftHiveMetastore.set_ugi_result(org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.set_ugi_result) TMessage(org.apache.thrift.protocol.TMessage) ThriftHiveMetastore.set_ugi_args(org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.set_ugi_args) TProtocolException(org.apache.thrift.protocol.TProtocolException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) TApplicationException(org.apache.thrift.TApplicationException)

Example 13 with TProtocolException

use of org.apache.thrift.protocol.TProtocolException in project hive by apache.

the class TestListPartitions method testListPartitionValuesNullSchema.

@Test
public void testListPartitionValuesNullSchema() throws Exception {
    try {
        createTable4PartColsParts(client);
        PartitionValuesRequest request = new PartitionValuesRequest(DB_NAME, TABLE_NAME, null);
        client.listPartitionValues(request);
        fail("Should have thrown exception");
    } catch (NullPointerException | TProtocolException e) {
    // TODO: should not throw different exceptions for different HMS deployment types
    }
}
Also used : PartitionValuesRequest(org.apache.hadoop.hive.metastore.api.PartitionValuesRequest) TProtocolException(org.apache.thrift.protocol.TProtocolException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 14 with TProtocolException

use of org.apache.thrift.protocol.TProtocolException in project hive by apache.

the class TestListPartitions method testListPartitionValuesNullTblName.

@Test
public void testListPartitionValuesNullTblName() throws Exception {
    try {
        createTable4PartColsParts(client);
        List<FieldSchema> partitionSchema = Lists.newArrayList(new FieldSchema("yyyy", "string", ""), new FieldSchema("mm", "string", ""));
        PartitionValuesRequest request = new PartitionValuesRequest(DB_NAME, null, partitionSchema);
        client.listPartitionValues(request);
        fail("Should have thrown exception");
    } catch (NullPointerException | TProtocolException e) {
    // TODO: should not throw different exceptions for different HMS deployment types
    }
}
Also used : PartitionValuesRequest(org.apache.hadoop.hive.metastore.api.PartitionValuesRequest) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) TProtocolException(org.apache.thrift.protocol.TProtocolException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 15 with TProtocolException

use of org.apache.thrift.protocol.TProtocolException in project hive by apache.

the class TestListPartitions method testListPartitionValuesNullDbName.

@Test
public void testListPartitionValuesNullDbName() throws Exception {
    try {
        createTable4PartColsParts(client);
        List<FieldSchema> partitionSchema = Lists.newArrayList(new FieldSchema("yyyy", "string", ""), new FieldSchema("mm", "string", ""));
        PartitionValuesRequest request = new PartitionValuesRequest(null, TABLE_NAME, partitionSchema);
        client.listPartitionValues(request);
        fail("Should have thrown exception");
    } catch (NullPointerException | TProtocolException e) {
    // TODO: should not throw different exceptions for different HMS deployment types
    }
}
Also used : PartitionValuesRequest(org.apache.hadoop.hive.metastore.api.PartitionValuesRequest) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) TProtocolException(org.apache.thrift.protocol.TProtocolException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Aggregations

TProtocolException (org.apache.thrift.protocol.TProtocolException)15 ByteBuffer (java.nio.ByteBuffer)8 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)3 PartitionValuesRequest (org.apache.hadoop.hive.metastore.api.PartitionValuesRequest)3 TApplicationException (org.apache.thrift.TApplicationException)3 TException (org.apache.thrift.TException)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)2 ThriftHiveMetastore.set_ugi_args (org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.set_ugi_args)2 ThriftHiveMetastore.set_ugi_result (org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.set_ugi_result)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2 TMessage (org.apache.thrift.protocol.TMessage)2 Annotation (java.lang.annotation.Annotation)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 NoReconnect (org.apache.hadoop.hive.metastore.annotation.NoReconnect)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 TField (org.apache.thrift.protocol.TField)1