hive 0.14 获取执行情况日志
String myBC_DB_URL = "mybc:hive2://my-test-001:10000/default;" + "principal=" + loginUserPrinc + ";kerberosAuthType=kerberos;hive.server2.proxy.user=" + proxtUser; Connection con = DriverManager.getConnection(myBC_DB_URL); final HiveStatement stmt = (HiveStatement) con.createStatement(); String tableName = "test_count"; final String sql = "select count(*) from " + tableName; LOGGER.info("Running: " + sql); final CountDownLatch latch = new CountDownLatch(1); Thread t = new Thread(new Runnable() { @Override public void run() { try { long start = System.currentTimeMillis(); ResultSet res = stmt.executeQuery(sql); while (res.next()) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < res.getMetaData().getColumnCount(); i++) { sb.append(res.getString(i + 1)).append("\t"); } LOGGER.info(sb); } if (res.next()) { LOGGER.info(res.getString(1)); } long end = System.currentTimeMillis(); LOGGER.info("query-" + Thread.currentThread().getId() + ":" + (end - start)); } catch (Exception e) { e.printStackTrace(); } finally { latch.countDown(); } } }); t.start(); while (latch.getCount() != 0) { List<String> logs = stmt.getQueryLog(); for (String log : logs) { /* if(log.contains("The url to track the job")||log.contains("Tracking URL =")||log.contains("Kill Command =")){ //not print }else{ LOGGER.info(log); }*/ if(log.contains(" Stage-")){ LOGGER.info(log); }else{ } } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } }
相关推荐
archive 2020-07-30
成长之路 2020-07-28
eternityzzy 2020-07-19
taisenki 2020-07-05
tugangkai 2020-07-05
SignalDu 2020-07-05
zlsdmx 2020-07-05
tomson 2020-07-05
tugangkai 2020-07-04
tomson 2020-07-05
Zhangdragonfly 2020-06-28
genshengxiao 2020-06-26
成长之路 2020-06-26
tomson 2020-06-26
蜗牛之窝 2020-06-26
成长之路 2020-06-25