org.apache.hadoop.hive.ql.CommandNeedRetryException Java Examples

The following examples show how to use org.apache.hadoop.hive.ql.CommandNeedRetryException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HiveTestUtilities.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Execute the give <i>query</i> on given <i>hiveDriver</i> instance. If a {@link CommandNeedRetryException}
 * exception is thrown, it tries upto 3 times before returning failure.
 * @param hiveDriver
 * @param query
 */
public static void executeQuery(Driver hiveDriver, String query) {
  CommandProcessorResponse response = null;
  boolean failed = false;
  int retryCount = 3;

  Exception cause = null;
  try {
    response = hiveDriver.run(query);
  } catch(CommandNeedRetryException retryEx) {
    if (--retryCount == 0) {
      failed = true;
      cause = retryEx;
    }
  } catch (Exception ex) {
    failed = true;
    cause = ex;
  }

  if (failed || response.getResponseCode() != 0 ) {
    throw new RuntimeException(String.format("Failed to execute command '%s', errorMsg = '%s'",
        query, (response != null ? response.getErrorMessage() : "")), cause);
  }
}
 
Example #2
Source File: EmbeddedMetastoreService.java    From beam with Apache License 2.0 5 votes vote down vote up
/** Executes the passed query on the embedded metastore service. */
public void executeQuery(String query) {
  try {
    driver.run(query);
  } catch (CommandNeedRetryException e) {
    throw new RuntimeException(e);
  }
}
 
Example #3
Source File: HCatalogIOTest.java    From beam with Apache License 2.0 5 votes vote down vote up
private void reCreateTestTableForUnboundedReads() throws CommandNeedRetryException {
  service.executeQuery("drop table " + TEST_TABLE);
  service.executeQuery(
      "create table "
          + TEST_TABLE
          + "(mycol1 string, mycol2 int)  "
          + "partitioned by (load_date string, product_type string)");
  service.executeQuery(
      "ALTER TABLE "
          + TEST_TABLE
          + " ADD PARTITION (load_date='2019-05-14T23:28:04.425Z', product_type='1')");
}
 
Example #4
Source File: HiveClient.java    From Kylin with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param hql
 * @throws CommandNeedRetryException
 * @throws IOException
 */
public void executeHQL(String hql) throws CommandNeedRetryException, IOException {
    CommandProcessorResponse response = getDriver().run(hql);
    int retCode = response.getResponseCode();
    if (retCode != 0) {
        String err = response.getErrorMessage();
        throw new IOException("Failed to execute hql [" + hql + "], error message is: " + err);
    }
}
 
Example #5
Source File: HiveClient.java    From Kylin with Apache License 2.0 4 votes vote down vote up
public void executeHQL(String[] hqls) throws CommandNeedRetryException, IOException {
    for (String sql : hqls)
        executeHQL(sql);
}