My Hive client stopped working with Cosmos instance

自闭症网瘾萝莉.ら 提交于 2019-12-02 07:46:38

问题


I have a Hive client (written in Java) that worked just fine with the Global Instance of Cosmos at FIWARE Lab. However, it is not working anymore, it seems the client cannot connect (it times out).

Has anything changed on the server-side?


回答1:


This is because the Global Instance of Cosmos at FIWARE Lab has been upgraded and now HiveServer2 is being run on the server side of Hive. Thus, everything in your code is still valid except for the following:

  • Load org.apache.hive.jdbc.HiveDriver instead of org.apache.hadoop.hive.jdbc.HiveDriver.
  • Change the JDBC connection schema from jdbc:hive to jdbc:hive2
  • Change your Hive dependencies to 0.13.0 version.

I mean, the code should finally have the following aspect:

try {
    // dynamically load the Hive JDBC driver
    Class.forName("org.apache.hive.jdbc.HiveDriver");
} catch (ClassNotFoundException e) {
    System.out.println(e.getMessage());
    return null;
} // try catch

try {
    // return a connection based on the Hive JDBC driver
    return DriverManager.getConnection("jdbc:hive2://" + hiveServer + ":" + hivePort,
            hadoopUser, hadoopPassword);
} catch (SQLException e) {
    System.out.println(e.getMessage());
    return null;
} // try catch

Regarding the dependencies, if using for instance Maven, your pom.xml should contain something like:

...
<dependencies>
  ...
  <dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-exec</artifactId>
    <version>0.13.0</version>
  </dependency>
  <dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-jdbc</artifactId>
    <version>0.13.0</version>
  </dependency>
  ...
</dependencies>
...

Finally, if using a JSON-like format, you will need to add the JSON serde. From the Hive CLI this is pretty simple:

hive> add JAR /usr/local/apache-hive-0.13.0-bin/lib/json-serde-1.3.1-SNAPSHOT-jar-with-dependencies.jar;

From you Hive client, just execute an update sentence with the above command.



来源:https://stackoverflow.com/questions/32134341/my-hive-client-stopped-working-with-cosmos-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!