/** * From string. * * @param handle the handle * @return the query handle */ public static QueryHandle fromString(String handle) { return new QueryHandle(UUID.fromString(handle)); }
/** * From string. * * @param handle the handle * @return the query handle */ public static QueryHandle fromString(String handle) { return new QueryHandle(UUID.fromString(handle)); }
/** * @return the handle * @deprecated */ public QueryHandle getHandle() { if (handle != null) { return new QueryHandle(handle.getPrepareHandleId()); } else { return null; } }
/** * @return the handle * @deprecated */ public QueryHandle getHandle() { if (handle != null) { return new QueryHandle(handle.getPrepareHandleId()); } else { return null; } }
/** * Instantiates a new query context. * * @param userQuery the user query * @param user the user * @param qconf the qconf * @param conf the conf * @param drivers All the drivers * @param selectedDriver the selected driver * @param submissionTime the submission time */ QueryContext(String userQuery, String user, LensConf qconf, Configuration conf, Collection<LensDriver> drivers, LensDriver selectedDriver, long submissionTime, boolean mergeDriverConf) { super(userQuery, user, qconf, conf, drivers, mergeDriverConf); this.submissionTime = submissionTime; this.queryHandle = new QueryHandle(UUID.randomUUID()); this.status = new QueryStatus(0.0f, null, Status.NEW, "Query just got created", false, null, null, null); this.lensConf = qconf; this.conf = conf; this.isPersistent = conf.getBoolean(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, LensConfConstants.DEFAULT_PERSISTENT_RESULT_SET); this.isDriverPersistent = conf.getBoolean(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, LensConfConstants.DEFAULT_DRIVER_PERSISTENT_RESULT_SET); this.userQuery = userQuery; if (selectedDriver != null) { this.setSelectedDriver(selectedDriver); } this.lensConf = qconf; this.driverStatus = new DriverQueryStatus(); }
/** * Instantiates a new query context. * * @param userQuery the user query * @param user the user * @param qconf the qconf * @param conf the conf * @param drivers All the drivers * @param selectedDriver the selected driver * @param submissionTime the submission time */ QueryContext(String userQuery, String user, LensConf qconf, Configuration conf, Collection<LensDriver> drivers, LensDriver selectedDriver, long submissionTime, boolean mergeDriverConf) { super(userQuery, user, qconf, conf, drivers, mergeDriverConf); this.submissionTime = submissionTime; this.queryHandle = new QueryHandle(UUID.randomUUID()); this.status = new QueryStatus(0.0f, null, Status.NEW, "Query just got created", false, null, null, null); this.lensConf = qconf; this.conf = conf; this.isPersistent = conf.getBoolean(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, LensConfConstants.DEFAULT_PERSISTENT_RESULT_SET); this.isDriverPersistent = conf.getBoolean(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, LensConfConstants.DEFAULT_DRIVER_PERSISTENT_RESULT_SET); this.userQuery = userQuery; if (selectedDriver != null) { this.setSelectedDriver(selectedDriver); } this.driverStatus = new DriverQueryStatus(); }
/** * Kill query. * * @param qh the qh * @return the string */ @CliCommand(value = "query kill", help = "Kill query with handle <query_handle>." + DEFAULT_QUERY_HANDLE_DESCRIPTION) public String killQuery(@CliOption(key = {"", "query_handle"}, mandatory = false, help = "<query_handle>") String qh) { qh = getOrDefaultQueryHandleString(qh); boolean status = getClient().killQuery(new QueryHandle(UUID.fromString(qh))); if (status) { return "Successfully killed " + qh; } else { return "Failed in killing " + qh; } }
/** * Kill query. * * @param qh the qh * @return the string */ @CliCommand(value = "query kill", help = "Kill query with handle <query_handle>." + DEFAULT_QUERY_HANDLE_DESCRIPTION) public String killQuery(@CliOption(key = {"", "query_handle"}, mandatory = false, help = "<query_handle>") String qh) { qh = getOrDefaultQueryHandleString(qh); boolean status = getClient().killQuery(new QueryHandle(UUID.fromString(qh))); if (status) { return "Successfully killed " + qh; } else { return "Failed in killing " + qh; } }
public static void setupQueryService(SchedulerServiceImpl scheduler) throws Exception { QueryExecutionService queryExecutionService = PowerMockito.mock(QueryExecutionService.class); scheduler.setQueryService(queryExecutionService); PowerMockito .when(queryExecutionService.estimate(anyString(), any(LensSessionHandle.class), anyString(), any(LensConf.class))) .thenReturn(null); PowerMockito.when( queryExecutionService.executeAsync(any(LensSessionHandle.class), anyString(), any(LensConf.class), anyString())) .thenReturn(new QueryHandle(UUID.randomUUID())); PowerMockito.when(queryExecutionService.cancelQuery(any(LensSessionHandle.class), any(QueryHandle.class))) .thenReturn(true); scheduler.getSchedulerEventListener().setQueryService(queryExecutionService); }
help = "<async>") boolean async) { qh = getOrDefaultQueryHandleString(qh); QueryHandle queryHandle = new QueryHandle(UUID.fromString(qh)); LensClient.LensClientResultSetWithStats results; String location = path != null ? path.getPath() : null;
help = "<async>") boolean async) { qh = getOrDefaultQueryHandleString(qh); QueryHandle queryHandle = new QueryHandle(UUID.fromString(qh)); LensClient.LensClientResultSetWithStats results; String location = path != null ? path.getPath() : null;
QueryHandle query = new QueryHandle(UUID.randomUUID()); String user = "user"; long now = System.currentTimeMillis();
public static QueryEnded mockQueryEnded(SchedulerJobInstanceHandle instanceHandle, QueryStatus.Status status) { QueryContext mockContext = PowerMockito.mock(QueryContext.class); PowerMockito.when(mockContext.getResultSetPath()).thenReturn("/tmp/query1/result"); Configuration conf = new Configuration(); // set the instance handle conf.set("job_instance_key", instanceHandle.getHandleIdString()); PowerMockito.when(mockContext.getConf()).thenReturn(conf); // Get the queryHandle. PowerMockito.when(mockContext.getQueryHandle()).thenReturn(new QueryHandle(UUID.randomUUID())); QueryEnded queryEnded = PowerMockito.mock(QueryEnded.class); PowerMockito.when(queryEnded.getQueryContext()).thenReturn(mockContext); PowerMockito.when(queryEnded.getCurrentValue()).thenReturn(status); return queryEnded; } }
@Test public void testQueryStausLogger() throws Exception { System.out.println("@@@ testQueryStatusLogger"); QueryStatusLogger logger = new QueryStatusLogger(); service.addListenerForType(logger, StatusChange.class); // Catch all listener just to make sure that the query accepted and // query exec stat events get through final CountDownLatch latch = new CountDownLatch(2); LensEventListener<LensEvent> eventListener = queryEventListener(latch); service.addListenerForType(eventListener, LensEvent.class); QueryHandle queryHandle = new QueryHandle(UUID.randomUUID()); QueryAccepted queryAccepted = new QueryAccepted(System.currentTimeMillis(), "beforeAccept", "afterAccept", queryHandle); QueryExecutionStatistics queryExecStats = new QueryExecutionStatistics(System.currentTimeMillis()); service.notifyEvent(queryAccepted); service.notifyEvent(queryExecStats); latch.await(); service.removeListener(eventListener); }
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); String queryName = qCom.getClient().getLensStatement(new QueryHandle(UUID.fromString(qh))).getQuery() .getQueryName(); assertTrue("testQuery1".equalsIgnoreCase(queryName), queryName);
qctx.setQueryHandle(new QueryHandle(pctx.getPrepareHandle().getPrepareHandleId())); result = driver.execute(qctx); assertNotNull(qctx.getDriverOpHandle()); qctx.setQueryHandle(new QueryHandle(pctx.getPrepareHandle().getPrepareHandleId())); driver.executeAsync(qctx); assertHandleSize(handleSize + 1);