/** * @return the query handle string */ public String getQueryHandleString() { return (this.queryHandle != null) ? this.queryHandle.getHandleIdString() : null; } }
/** * @return the query handle string */ public String getQueryHandleString() { return (this.queryHandle != null) ? this.queryHandle.getHandleIdString() : null; } }
public String getQueryHandleString() { return queryHandle.getHandleIdString(); }
public String getQueryHandleString() { return queryHandle.getHandleIdString(); }
@Override public void run() { try { logSegregationContext.setLogSegragationAndQueryId(handle.getHandleIdString()); cancelQuery(handle); } catch (Exception e) { log.error("Error while cancelling query {}", handle, e); } } }
@Override public void close() throws LensException { for(QueryHandle handle : resultSetMap.keySet()) { try { closeQuery(handle); } catch (LensException e) { log.error("Error while closing query {}", handle.getHandleIdString(), e); } } }
@Override public void close() throws LensException { for(QueryHandle handle : resultSetMap.keySet()) { try { closeQuery(handle); } catch (LensException e) { log.error("Error while closing query {}", handle.getHandleIdString(), e); } } }
@Override public boolean cancelQuery(LensSessionHandle sessionHandle, QueryHandle queryHandle) throws LensException { try { logSegregationContext.setLogSegragationAndQueryId(queryHandle.getHandleIdString()); log.info("CancelQuery: session:{} query:{}", sessionHandle, queryHandle); acquire(sessionHandle); return cancelQuery(queryHandle); } finally { release(sessionHandle); } }
@Override public LensQuery getQueryInfo(LensSessionHandle sessionHandle, QueryHandle queryHandle) throws LensException { LensQuery query = getUpdatedQueryContext(sessionHandle, queryHandle).toLensQuery(); if (query == null) { try { return lensServerDao.findActiveQueryDetails(queryHandle).toLensQuery(); } catch (LensException e) { log.info("Query " + queryHandle.getHandleIdString() + " not found in active queries table in db."); } } return query; }
@Test(enabled = false) public void differentQuerySameNameSession() throws Exception { String cost5 = String.format(QueryInventory.getQueryFromInventory("HIVE.SLEEP_COST_5"), "5"); String cost3 = String.format(QueryInventory.getQueryFromInventory("HIVE.SLEEP_COST_3"), "3"); QueryHandle handle1 = (QueryHandle) qHelper.executeQuery(cost5, "queryName").getData(); QueryHandle handle2 = (QueryHandle) qHelper.executeQuery(cost3, "queryName").getData(); Assert.assertFalse(handle1.getHandleIdString().equals(handle2.getHandleIdString())); }
@Test(enabled = false) public void differentNameSameSessionQuery() throws Exception { String query = QueryInventory.getSleepQuery("3"); QueryHandle handle1 = (QueryHandle) qHelper.executeQuery(query, "name1").getData(); QueryHandle handle2 = (QueryHandle) qHelper.executeQuery(query, "name2").getData(); Assert.assertFalse(handle1.getHandleIdString().equals(handle2.getHandleIdString())); }
@Test(dataProvider = "query_names", enabled = true) public void testRunningSameNameSessionQuery(String queryName) throws Exception { String query = QueryInventory.getSleepQuery("10"); List<QueryHandle> handleList = new ArrayList<>(); List<PersistentQueryResult> resultList = new ArrayList<>(); for(int i=0; i<3; i++){ handleList.add((QueryHandle) qHelper.executeQuery(query, queryName).getData()); } Assert.assertEquals(handleList.get(1).getHandleIdString(), handleList.get(0).getHandleIdString()); Assert.assertEquals(handleList.get(2).getHandleIdString(), handleList.get(0).getHandleIdString()); for(QueryHandle handle : handleList){ LensQuery lq = qHelper.waitForCompletion(handle); Assert.assertEquals(lq.getStatus().getStatus(), QueryStatus.Status.SUCCESSFUL); resultList.add((PersistentQueryResult) qHelper.getResultSet(handle)); } Assert.assertEquals(resultList.get(1).getPersistedURI(), resultList.get(0).getPersistedURI()); Assert.assertEquals(resultList.get(2).getPersistedURI(), resultList.get(0).getPersistedURI()); }
@Test(enabled = false) public void differentConfSameNameSessionQuery() throws Exception { String query = QueryInventory.getSleepQuery("5"); LensConf lensConf = new LensConf(); lensConf.addProperty(CubeQueryConfUtil.FAIL_QUERY_ON_PARTIAL_DATA, "false"); QueryHandle qhr1 = (QueryHandle) qHelper.executeQuery(query, "query-name", null, sessionHandleString, lensConf).getData(); lensConf.addProperty(CubeQueryConfUtil.FAIL_QUERY_ON_PARTIAL_DATA, "true"); QueryHandle qhr2 = (QueryHandle) qHelper.executeQuery(query, "query-name", null, sessionHandleString, lensConf).getData(); Assert.assertFalse(qhr1.getHandleIdString().equals(qhr2.getHandleIdString())); } }
/** * Test result formatter hdfs persistent result location override from driver conf. * * @throws InterruptedException the interrupted exception * @throws IOException Signals that an I/O exception has occurred. */ @Test public void testResultDirOverrideFromDriverConf() throws InterruptedException, IOException { LensConf conf = new LensConf(); conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "true"); LensQuery lensQuery = testResultFormatter(conf, QueryStatus.Status.SUCCESSFUL, false, null, MediaType.APPLICATION_XML_TYPE); assertEquals(lensQuery.getResultSetPath(), "file:"+System.getProperty("user.dir")+"/target/hive-lens-results/" +lensQuery.getQueryHandle().getHandleIdString()+".csv"); }
@Test(enabled = false) public void differentSessionSameNameQuery() throws Exception { String query = QueryInventory.getSleepQuery("10"); String session1 = sHelper.openSession("user1", "pwd1", lens.getCurrentDB()); String session2 = sHelper.openSession("user2", "pwd2", lens.getCurrentDB()); QueryHandle handle1 = (QueryHandle) qHelper.executeQuery(query, "name", session1).getData(); QueryHandle handle2 = (QueryHandle) qHelper.executeQuery(query, "name", session2).getData(); Assert.assertFalse(handle1.getHandleIdString().equals(handle2.getHandleIdString())); }
/** * Execute query with timeout option. * If the query does not finish within the timeout time, server returns the query handle which can be used to * track further progress. * * @param sql : query/command to be executed * @param queryName : optional query name * @param timeOutMillis : timeout milliseconds for the query execution. * @param conf config to be used for the query * @return * @throws LensAPIException */ public QueryHandleWithResultSet executeQueryWithTimeout(String sql, String queryName, long timeOutMillis, LensConf conf) throws LensAPIException { log.info("Executing query {} with timeout of {} milliseconds", sql, timeOutMillis); QueryHandleWithResultSet result = statement.executeQuery(sql, queryName, timeOutMillis, conf); statementMap.put(result.getQueryHandle(), statement); if (result.getStatus().failed()) { IdBriefErrorTemplate errorResult = new IdBriefErrorTemplate(IdBriefErrorTemplateKey.QUERY_ID, result.getQueryHandle().getHandleIdString(), new BriefError(result.getStatus() .getErrorCode(), result.getStatus().getErrorMessage())); throw new LensBriefErrorException(errorResult); } return result; }
/** * Execute query with timeout option. * If the query does not finish within the timeout time, server returns the query handle which can be used to * track further progress. * * @param sql : query/command to be executed * @param queryName : optional query name * @param timeOutMillis : timeout milliseconds for the query execution. * @param conf config to be used for the query * @return * @throws LensAPIException */ public QueryHandleWithResultSet executeQueryWithTimeout(String sql, String queryName, long timeOutMillis, LensConf conf) throws LensAPIException { log.info("Executing query {} with timeout of {} milliseconds", sql, timeOutMillis); QueryHandleWithResultSet result = statement.executeQuery(sql, queryName, timeOutMillis, conf); statementMap.put(result.getQueryHandle(), statement); if (result.getStatus().failed()) { IdBriefErrorTemplate errorResult = new IdBriefErrorTemplate(IdBriefErrorTemplateKey.QUERY_ID, result.getQueryHandle().getHandleIdString(), new BriefError(result.getStatus() .getErrorCode(), result.getStatus().getErrorMessage())); throw new LensBriefErrorException(errorResult); } return result; }
if (handle == null || handle.getHandleIdString().isEmpty()) { log.info("Killing instance {} for job {} ", instanceInfo.getId(), instanceInfo.getJobId()); return updateInstanceRun(latestRun, state);
/** * Updates the status of a job instance. * * @param instanceRun * @return number of rows updated. * @throws SQLException */ public int updateJobInstanceRun(SchedulerJobInstanceRun instanceRun) throws SQLException { String updateSQL = "UPDATE " + JOB_INSTANCE_RUN_TABLE + " SET " + COLUMN_END_TIME + "=?, " + COLUMN_RESULT_PATH + "=?, " + COLUMN_QUERY_HANDLE + "=?, " + COLUMN_STATUS + "=?" + " WHERE " + COLUMN_ID + "=? AND " + COLUMN_RUN_ID + "=?"; return runner.update(updateSQL, instanceRun.getEndTime(), instanceRun.getResultPath(), instanceRun.getQueryHandle() == null ? "" : instanceRun.getQueryHandle().getHandleIdString(), instanceRun.getInstanceState().name(), instanceRun.getHandle().getHandleIdString(), instanceRun.getRunId()); }
public int insertIntoJobInstanceRunTable(SchedulerJobInstanceRun instanceRun) throws SQLException { String insetSQL = "INSERT INTO " + JOB_INSTANCE_RUN_TABLE + " VALUES(?,?,?,?,?,?,?,?)"; return runner.update(insetSQL, instanceRun.getHandle().getHandleIdString(), instanceRun.getRunId(), instanceRun.getSessionHandle() == null ? "" : instanceRun.getSessionHandle().toString(), instanceRun.getStartTime(), instanceRun.getEndTime(), instanceRun.getResultPath(), instanceRun.getQueryHandle() == null ? "" : instanceRun.getQueryHandle().getHandleIdString(), instanceRun.getInstanceState().name()); }