@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; } } }
public LensQuery getQueryDetails(String handle) { return getQueryDetails(QueryHandle.fromString(handle)); }
public QueryStatus getQueryStatus(String q) { return getQueryStatus(QueryHandle.fromString(q)); }
public QueryStatus getQueryStatus(String q) { return getQueryStatus(QueryHandle.fromString(q)); }
public LensQuery getQueryDetails(String handle) { return getQueryDetails(QueryHandle.fromString(handle)); }
/** * Gets the query handle. * * @param queryHandle the query handle * @return the query handle */ private QueryHandle getQueryHandle(String queryHandle) throws LensException { try { return QueryHandle.fromString(queryHandle); } catch (Exception e) { throw new LensException(INVALID_HANDLE.getLensErrorInfo(), e, queryHandle); } }
private List<SchedulerJobInstanceRun> processInstanceRun(List<Object[]> instanceRuns) throws SQLException { List<SchedulerJobInstanceRun> runList = new ArrayList<>(); for (Object[] run : instanceRuns) { // run[0] will contain the instanceID SchedulerJobInstanceHandle id = SchedulerJobInstanceHandle.fromString((String) run[0]); int runId = (Integer) run[1]; LensSessionHandle sessionHandle = LensSessionHandle.valueOf((String) run[2]); long starttime = (Long) run[3]; long endtime = (Long) run[4]; String resultPath = (String) run[5]; String queryHandleString = (String) run[6]; QueryHandle queryHandle = null; if (!queryHandleString.isEmpty()) { queryHandle = QueryHandle.fromString((String) run[6]); } SchedulerJobInstanceState instanceStatus = SchedulerJobInstanceState.valueOf((String) run[7]); SchedulerJobInstanceRun instanceRun = new SchedulerJobInstanceRun(id, runId, sessionHandle, starttime, endtime, resultPath, queryHandle, instanceStatus); runList.add(instanceRun); } return runList; }
public static QueryContext createQueryInstanceWithQueryHandleAndPriorityStubbing(String handlePrefix, int index, Priority priority) { QueryContext mockQuery = mock(QueryContext.class); when(mockQuery.getQueryHandle()).thenReturn(QueryHandle.fromString(handlePrefix + index)); when(mockQuery.getPriority()).thenReturn(priority); return mockQuery; }
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; }
public static QueryContext createQueryInstanceWithQueryHandleAndCostStubbing(String handlePrefix, int index, double queryCost) { QueryContext mockQuery = mock(QueryContext.class); when(mockQuery.getQueryHandle()).thenReturn(QueryHandle.fromString(handlePrefix + index)); when(mockQuery.getSelectedDriverQueryCost()).thenReturn(new FactPartitionBasedQueryCost(queryCost)); return mockQuery; }
LensPersistentResult(FinishedLensQuery query, Configuration conf, LensConf qconf) throws ClassNotFoundException, IOException { this(QueryHandle.fromString(query.getHandle()), LensResultSetMetadata.fromJson(query.getMetadata()), query.getResult(), query.getRows(), query.getFileSize(), conf, qconf); }
/** * Test multiple closeSession invocations for a session */ @Test(dataProvider = "mediaTypeData") public void testCloseSessionMultipleTimes(MediaType mt) throws Exception { HiveSessionService sessionService = LensServices.get().getService(SessionService.NAME); LensSessionHandle sessionHandle = sessionService.openSession("foo@localhost", "bar", new HashMap<String, String>()); Assert.assertNotNull(sessionHandle, "Expected session to be opened"); sessionService.getSession(sessionHandle).addToActiveQueries(QueryHandle.fromString(UUID.randomUUID().toString())); // Closing multiple times should not cause any issues sessionService.closeSession(sessionHandle); sessionService.closeSession(sessionHandle); }
/** * Gets the status. * * @param qh the qh * @return the status */ @CliCommand(value = "query status", help = "Fetch status of executed query having query handle <query_handle>. " + DEFAULT_QUERY_HANDLE_DESCRIPTION) public String getStatus( @CliOption(key = {"", "query_handle"}, mandatory = false, help = "<query_handle>") String qh) { qh = getOrDefaultQueryHandleString(qh); QueryHandle handle = QueryHandle.fromString(qh); QueryStatus status = getClient().getQueryStatus(handle); if (status == null) { return "Unable to find status for " + handle; } return "Query Handle: " + qh + "\n" + status.toString(); }
/** * Gets the status. * * @param qh the qh * @return the status */ @CliCommand(value = "query status", help = "Fetch status of executed query having query handle <query_handle>. " + DEFAULT_QUERY_HANDLE_DESCRIPTION) public String getStatus( @CliOption(key = {"", "query_handle"}, mandatory = false, help = "<query_handle>") String qh) { qh = getOrDefaultQueryHandleString(qh); QueryHandle handle = QueryHandle.fromString(qh); QueryStatus status = getClient().getQueryStatus(handle); if (status == null) { return "Unable to find status for " + handle; } return "Query Handle: " + qh + "\n" + status.toString(); }
SchedulerJobInstanceRun run1 = new SchedulerJobInstanceRun(instanceHandle, 1, new LensSessionHandle(UUID.randomUUID(), UUID.randomUUID()), currentTime, currentTime, "/tmp/", QueryHandle.fromString(UUID.randomUUID().toString()), SchedulerJobInstanceState.WAITING); instances.put(firstInstance.getId(), firstInstance); schedulerDAO.storeJobInstance(firstInstance); SchedulerJobInstanceRun run2 = new SchedulerJobInstanceRun(instanceHandle, 1, new LensSessionHandle(UUID.randomUUID(), UUID.randomUUID()), currentTime, currentTime, "/tmp/", QueryHandle.fromString(UUID.randomUUID().toString()), SchedulerJobInstanceState.WAITING); instances.put(secondInstance.getId(), secondInstance); schedulerDAO.storeJobInstance(secondInstance);
for (String handle : handles) { if (!handle.contains("Total number of queries")) { QueryHandle.fromString(handle.trim());
public QueryContext toQueryContext(Configuration conf, Collection<LensDriver> drivers) { if (null == selectedDriver && null != driverName) { selectedDriver = getDriverFromName(drivers); } QueryContext qctx = new QueryContext(userQuery, submitter, this.conf, conf, drivers, selectedDriver, submissionTime, false); qctx.setQueryHandle(QueryHandle.fromString(handle)); qctx.setLaunchTime(this.startTime); qctx.setEndTime(getEndTime()); qctx.setStatusSkippingTransitionTest(new QueryStatus(0.0, null, QueryStatus.Status.valueOf(getStatus()), null, getResult() != null, null, getErrorMessage() == null ? "" : getErrorMessage(), null)); qctx.getDriverStatus().setDriverStartTime(getDriverStartTime()); qctx.getDriverStatus().setDriverFinishTime(getDriverEndTime()); qctx.setResultSetPath(getResult()); qctx.setQueryName(getQueryName()); if (null != driverQuery){ qctx.setSelectedDriverQuery(driverQuery); } if (getPriority() != null) { qctx.setPriority(Priority.valueOf(getPriority())); } qctx.setFailedAttempts(getFailedAttempts()); return qctx; }
public QueryContext toQueryContext(Configuration conf, Collection<LensDriver> drivers) { if (null == selectedDriver && null != driverName) { selectedDriver = getDriverFromName(drivers); } QueryContext qctx = new QueryContext(userQuery, submitter, this.conf, conf, drivers, selectedDriver, submissionTime, false); qctx.setQueryHandle(QueryHandle.fromString(handle)); qctx.setLaunchTime(this.startTime); qctx.setEndTime(getEndTime()); qctx.setStatusSkippingTransitionTest(new QueryStatus(0.0, null, QueryStatus.Status.valueOf(getStatus()), null, getResult() != null, null, getErrorMessage() == null ? "" : getErrorMessage(), null)); qctx.getDriverStatus().setDriverStartTime(getDriverStartTime()); qctx.getDriverStatus().setDriverFinishTime(getDriverEndTime()); qctx.setResultSetPath(getResult()); qctx.setQueryName(getQueryName()); if (null != driverQuery){ qctx.setSelectedDriverQuery(driverQuery); } if (getPriority() != null) { qctx.setPriority(Priority.valueOf(getPriority())); } qctx.setFailedAttempts(getFailedAttempts()); return qctx; }