/** * Check current state. * * @param status the status */ protected void checkCurrentState(QueryStatus.Status status) { if (currentValue != status) { throw new IllegalStateException("Invalid query state: " + currentValue + " query:" + queryHandle.toString()); } }
/** * @return the query handle string */ public String getQueryHandleString() { return (this.queryHandle != null) ? this.queryHandle.getHandleIdString() : null; } }
/** * From string. * * @param handle the handle * @return the query handle */ public static QueryHandle fromString(String handle) { return new QueryHandle(UUID.fromString(handle)); }
public static QueryContext getMockedQueryFromQueries(Set<QueryContext> queries, String mockHandle, int index) { Iterator iterator = queries.iterator(); while (iterator.hasNext()) { QueryContext queuedQuery = (QueryContext) iterator.next(); if (queuedQuery.getQueryHandle().equals(QueryHandle.fromString(mockHandle + index))) { return queuedQuery; } } return null; }
pstmt.setString(1, queryHandle.toString()); log.error("Failed to find active query " + queryHandle.getHandleIdString() + " in database with error, " + e); throw new LensException(e);
@Override public QueryHandle handle(ResultSet rs) throws SQLException { try { return QueryHandle.fromString(rs.getString(1)); } catch (IllegalArgumentException exc) { log.warn("Warning invalid query handle found in DB " + rs.getString(1)); return null; } } }
new GenericType<LensAPIResult<QueryHandle>>() {}).getData(); LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", sessionHandle).request() .get(LensQuery.class); ctx = target.path(handle.toString()).queryParam("sessionid", sessionHandle).request().get(LensQuery.class); stat = ctx.getStatus(); try { throw new LensException("Query failed " + ctx.getQueryHandle().getHandleId() + " reason:" + stat.getErrorMessage());
/** * Gets the query context. * * @param handle the handle * @return the query context * @throws LensException the lens exception */ protected JdbcQueryContext getQueryContext(QueryHandle handle) throws LensException { JdbcQueryContext ctx = queryContextMap.get(handle); if (ctx == null) { throw new LensException("Query not found:" + handle.getHandleId()); } return ctx; }
long submitTime = System.currentTimeMillis(); String qh = qCom.executeQuery(sql, true, "testQuery1"); String user = qCom.getClient().getLensStatement(new QueryHandle(UUID.fromString(qh))) .getQuery().getSubmittedUser(); String result = qCom.getAllQueries("", "testQuery1", user, "", null, null); for (String handle : handles) { if (!handle.contains("Total number of queries")) { QueryHandle.fromString(handle.trim()); String queryName = qCom.getClient().getLensStatement(new QueryHandle(UUID.fromString(qh))).getQuery() .getQueryName(); assertTrue("testQuery1".equalsIgnoreCase(queryName), queryName);
assertTrue(allQueries.size() >= 1); String queryXML = target.path(theHandle.toString()).queryParam("sessionid", lensSessionId) .request(MediaType.APPLICATION_XML).get(String.class); log.debug("query XML:{}", queryXML); target.path(theHandle.toString() + "001").queryParam("sessionid", lensSessionId).request(mt).get(); assertEquals(response.getStatus(), 404); LensQuery query = target.path(theHandle.toString()).queryParam("sessionid", lensSessionId).request(mt) .get(LensQuery.class); while (!stat.finished()) { Thread.sleep(1000); query = target.path(theHandle.toString()).queryParam("sessionid", lensSessionId).request(mt).get(LensQuery.class); stat = query.getStatus(); isPurged = true; for (QueryHandle aHandle : queryService.allQueries.keySet()) { if (aHandle.equals(theHandle)) { isPurged = false; //current query is still not purged Thread.sleep(1000); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); APIResult updateConf = target.path(theHandle.toString()).request(mt) .put(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); assertEquals(updateConf.getStatus(), APIResult.Status.FAILED);
/** * Since the collection is a linkedHashSet, the order of queries is always maintained. * @param query * @return */ @Override public Integer getQueryIndex(QueryContext query) { Iterator iterator = queries.iterator(); int index = 1; while (iterator.hasNext()) { QueryContext queuedQuery = (QueryContext) iterator.next(); if (queuedQuery.getQueryHandle().equals(query.getQueryHandle())) { return index; } index += 1; } return null; }
LensQuery lensQuery = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(mt) .get(LensQuery.class); assertTrue(lensQuery.getStatus().getStatus().equals(Status.QUEUED) lensQuery = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(mt).get(LensQuery .class); stat = lensQuery.getStatus(); APIResult result = target.path(handle2.toString()).queryParam("sessionid", lensSessionId).request(mt) .delete(APIResult.class); LensQuery ctx2 = target.path(handle2.toString()).queryParam("sessionid", lensSessionId).request(mt) .get(LensQuery.class); if (result.getStatus().equals(APIResult.Status.FAILED)) { ctx3.getSelectedDriverConf().get(LensConfConstants.RESULT_SET_PARENT_DIR) + "/" + handle3.getHandleIdString() + ctx3.getConf().get(LensConfConstants.QUERY_OUTPUT_FILE_EXTN); assertTrue(((PersistentResultSet) rs).getOutputPath().endsWith(expectedPath)
public QueryStatus getQueryStatus(String q) { return getQueryStatus(QueryHandle.fromString(q)); }
for (QueryHandle handle : persistedHandles) { LensQuery query = service.getQuery(session, handle); if (!handle.getHandleId().toString().equals(finishedHandle)) { Assert.assertTrue(query.getStatus().finished(), query.getQueryHandle() + " STATUS=" + query.getStatus().getStatus()); queryContext.getSelectedDriver().getFullyQualifiedName(), "daotestquery1", -1L, Long.MAX_VALUE); Assert.assertEquals(daoTestQueryHandles.size(), 1); Assert.assertEquals(daoTestQueryHandles.get(0).getHandleId().toString(), finishedHandle); Assert.assertEquals(actualQueryContext.getQueryHandle().toString(), queryContext.getQueryHandle().toString());
/** * Gets the query context. * * @param handle the handle * @return the query context * @throws LensException the lens exception */ protected JdbcQueryContext getQueryContext(QueryHandle handle) throws LensException { JdbcQueryContext ctx = queryContextMap.get(handle); if (ctx == null) { throw new LensException("Query not found:" + handle.getHandleId()); } return ctx; }
/** * Check current state. * * @param status the status */ protected void checkCurrentState(QueryStatus.Status status) { if (currentValue != status) { throw new IllegalStateException("Invalid query state: " + currentValue + " query:" + queryHandle.toString()); } }
/** * @return the query handle string */ public String getQueryHandleString() { return (this.queryHandle != null) ? this.queryHandle.getHandleIdString() : null; } }
public LensQuery getQueryDetails(String handle) { return getQueryDetails(QueryHandle.fromString(handle)); }
/** * From string. * * @param handle the handle * @return the query handle */ public static QueryHandle fromString(String handle) { return new QueryHandle(UUID.fromString(handle)); }
/** * Close the query specified by the handle, releases all the resources held by the query. * * @param handle The query handle * @throws LensException the lens exception */ @Override public void closeQuery(QueryHandle handle) throws LensException { checkConfigured(); try { JdbcQueryContext ctx = getQueryContext(handle); if (ctx != null) { ctx.getResultFuture().cancel(true); ctx.closeResult(); } } catch (LensException exc) { log.error("{} Failed to close query {}", getFullyQualifiedName(), handle.getHandleId()); } finally { queryContextMap.remove(handle); } log.info("{} Closed query {}", getFullyQualifiedName(), handle.getHandleId()); }