org.apache.lens.server.api.query.QueryContext.isLaunching()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.apache.lens.server.api.query.QueryContext.isLaunching方法的一些代码示例,展示了QueryContext.isLaunching的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryContext.isLaunching方法的具体详情如下:
包路径:org.apache.lens.server.api.query.QueryContext
类名称:QueryContext
方法名:isLaunching

QueryContext.isLaunching介绍

暂无

代码示例

代码示例来源:origin: apache/lens

private int getIsLaunchingCount(final Set<QueryContext> launchedQueries) {
  int launcherCount = 0;
  for (QueryContext ctx : launchedQueries) {
   if (ctx.isLaunching()) {
    launcherCount++;
   }
  }
  return  launcherCount;
 }
}

代码示例来源:origin: org.apache.lens/lens-server-api

private int getIsLaunchingCount(final Set<QueryContext> launchedQueries) {
  int launcherCount = 0;
  for (QueryContext ctx : launchedQueries) {
   if (ctx.isLaunching()) {
    launcherCount++;
   }
  }
  return  launcherCount;
 }
}

代码示例来源:origin: apache/lens

@Override
public long getLaunchingQueriesCount() {
 long count = 0;
 for (QueryContext ctx : launchedQueries.getQueries()) {
  if (ctx.isLaunching()) {
   count++;
  }
 }
 return count;
}

代码示例来源:origin: apache/lens

return;
if (ctx.isLaunching()) {
 continue;

代码示例来源:origin: apache/lens

private boolean cancelQuery(@NonNull QueryHandle queryHandle) throws LensException {
 QueryContext ctx =  allQueries.get(queryHandle);
 if (ctx == null) {
  log.info("Could not cancel query {} as it has been purged already", queryHandle);
  return false;
 }
 synchronized (ctx) {
  updateStatus(queryHandle);
  if (ctx.finished()) {
   log.info("Could not cancel query {} as it has finished execution already", queryHandle);
   return false;
  }
  if (ctx.isLaunching()) {
   boolean launchCancelled = ctx.getQueryLauncher().cancel(true);
   log.info("query launch cancellation success : {}", launchCancelled);
  }
  if (ctx.launched() || ctx.running()) {
   if (!ctx.getSelectedDriver().cancelQuery(queryHandle)) {
    log.info("Could not cancel query {}", queryHandle);
    return false;
   }
  }
  log.info("Query {} cancelled successfully", queryHandle);
  setCancelledStatus(ctx, "Query is cancelled");
  return true;
 }
}

代码示例来源:origin: apache/lens

@Test(dataProvider = "dpTestConcurrentLaunches")
public void testConcurrentLaunches(final int currentDriverLaunchedQueries, final boolean expectedCanLaunch) {
 QueryContext mockCandidateQuery = mock(QueryContext.class);
 EstimatedImmutableQueryCollection mockLaunchedQueries = mock(EstimatedImmutableQueryCollection.class);
 LensDriver mockDriver = mock(LensDriver.class);
 Set<QueryContext> queries = new HashSet<>(currentDriverLaunchedQueries);
 for (int i = 0; i < currentDriverLaunchedQueries; i++) {
  QueryContext mQuery = mock(QueryContext.class);
  when(mQuery.isLaunching()).thenReturn(true);
  queries.add(mQuery);
 }
 when(mockCandidateQuery.getSelectedDriver()).thenReturn(mockDriver);
 when(mockLaunchedQueries.getQueriesCount(mockDriver)).thenReturn(currentDriverLaunchedQueries);
 when(mockLaunchedQueries.getQueries(mockDriver)).thenReturn(queries);
 String actualCanLaunch = constraint.allowsLaunchOf(mockCandidateQuery, mockLaunchedQueries);
 if (expectedCanLaunch) {
  assertNull(actualCanLaunch);
 } else {
  assertNotNull(actualCanLaunch);
 }
}

代码示例来源:origin: apache/lens

/**
 * Test multiple launches and failure in execute operation.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test(dataProvider = "mediaTypeData")
public void testMultipleLaunches(MediaType mt) throws Exception {
 QueryHandle handle = executeAndGetHandle(target(), Optional.of(lensSessionId),
  Optional.of("select wait,fail from non_exist"),
  Optional.<LensConf>absent(), mt);
 // launch one more.
 QueryHandle handle2 = executeAndGetHandle(target(), Optional.of(lensSessionId),
  Optional.of("select wait,fail2 from non_exist"),
  Optional.<LensConf>absent(), mt);
 assertNotEquals(handle, handle2);
 // put a small sleep sothat querysubmitter picks handle2
 Thread.sleep(50);
 assertTrue(queryService.getQueryContext(handle).isLaunching());
 assertTrue(queryService.getQueryContext(handle2).isLaunching());
 assertTrue(queryService.getLaunchingQueriesCount() > 1);
 waitForQueryToFinish(target(), lensSessionId, handle, mt);
 waitForQueryToFinish(target(), lensSessionId, handle2, mt);
}

相关文章

微信公众号

最新文章

更多