使用Thrift开发Hive CDH5,而不是连接服务器

时间:2017-01-22 07:22:32

标签: hive kerberos thrift

我想使用thrift作为hive cdh5的metestore。平台的大数据是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.TTransportException:java.net.SocketTimeoutException:read timed out

0 个答案:

没有答案