使用Thrift开发hive cdh5,而不是连接服务器

v9tzhpje  于 2021-06-28  发布在  Hive
关注(0)|答案(0)|浏览(217)

我想对hive cdh5的metestore使用thrift。我们平台的大数据是cdh5.5.2,安全性使用kerberos。例如:
getAllDatabases execute(sql) create_database get_database(String name) 等等。。。 hive.server2.thrift.port=10000 代码:

public class HiveClient {
    public static final String SERVER_IP = "hadoop7";
    public static final int SERVER_PORT = 10000;
    public static final int TIMEOUT = 30000;
    public static void main(String[] args) {
        TTransport transport = null;
        try {
            transport = new TSocket(SERVER_IP, SERVER_PORT, TIMEOUT);
            TProtocol protocol = new TBinaryProtocol(transport);
            ThriftHive.Client client=new ThriftHive.Client(protocol);
            transport.open();
            List<String> databases=client.get_all_databases();
            for(String database:databases){
                System.out.println(database);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            if (null != transport) {
                transport.close();
            }
        }
    }
}

错误:
org.apache.thrift.transport.ttTransportException:java.net.sockettimeoutexception:读取超时

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题