我正在尝试使用spring hadoop Hive Thrift Client远程连接到hive服务器。我在Cloudera QuickStart VM 5.0.0下使用默认的hive安装。 我可以在使用Hive JDBC Client时连接到Hive Server,并使用JdbcTemplate来执行查询。 但是,如果我尝试通过HiveTemplate连接到远程配置单元服务器,代码似乎等待某些东西并且不响应。 此外,日志不会显示任何错误。 我正在参考以下文档来配置我的应用程序: http://docs.spring.io/spring-hadoop/docs/current/reference/html/hive.html
我在hive-context.xml文件中使用以下配置
<hive-client-factory id="hiveClientFactory" host="${hive.host}" port="${hive.port}" xmlns="http://www.springframework.org/schema/hadoop"/>
<hive-template id="hiveTemplate"/>
我正在使用HiveTemplate,如下所示:
@Autowired
private HiveTemplate hiveTemplate;
public List<String> getDbs() {
System.out.println("Hive Template ="+ hiveTemplate);
return hiveTemplate.execute(new HiveClientCallback<List<String>>() {
public List<String> doInHive(HiveClient hiveClient) throws Exception {
System.out.println(" ----> In execute getDbs "+ hiveClient);
return hiveClient.get_all_databases();
}
});
}
我的JUnit代码如下:
public class TestHiveDAO {
ApplicationContext ctx = new ClassPathXmlApplicationContext("hive-context.xml");
HiveDaoImpl hiveDao = ctx.getBean(HiveDaoImpl.class);
@Test
public void testScript(){
System.out.println("Before");
List<String> dbs = hiveDao.getDbs();
for(String s : dbs){
System.out.println(" ----> Databases "+s);
}
System.out.println("After");
}
输出只是等待某事并且永远不会完成:
[main] INFO org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@9e5e323: startup date [Tue Aug 19 16:50:33 BST 2014]; root of context hierarchy
[main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [hive-context.xml]
[main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [jdbc-context.xml]
[main] INFO org.springframework.context.support.PropertySourcesPlaceholderConfigurer - Loading properties file from class path resource [hive.properties]
[main] INFO org.springframework.context.support.PropertySourcesPlaceholderConfigurer - Loading properties file from class path resource [hadoop.properties]
[main] INFO org.springframework.context.support.PropertySourcesPlaceholderConfigurer - Loading properties file from class path resource [hive-server.properties]
Before
Hive Template =org.springframework.data.hadoop.hive.HiveTemplate@48b997d0
----> In execute getDbs org.apache.hadoop.hive.service.HiveClient@282c0dbe
任何帮助都将非常感激。