org.apache.druid.query.QueryInterruptedException.<init>()方法的使用及代码示例

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

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

QueryInterruptedException.<init>介绍

[英]Creates a new QueryInterruptedException wrapping an underlying exception. The errorMessage and errorClass of this exception will be based on the highest non-QueryInterruptedException in the causality chain.
[中]创建一个新的QueryInterruptedException,包装一个基础异常。此异常的errorMessage和errorClass将基于因果链中最高的非QueryInterruptedException。

代码示例

代码示例来源:origin: apache/incubator-druid

public static QueryInterruptedException wrapIfNeeded(Throwable e)
 {
  return e instanceof QueryInterruptedException ? (QueryInterruptedException) e : new QueryInterruptedException(e);
 }
}

代码示例来源:origin: apache/incubator-druid

public static void checkInterrupted()
{
 if (Thread.interrupted()) {
  throw new QueryInterruptedException(new InterruptedException());
 }
}

代码示例来源:origin: apache/incubator-druid

private static void checkCombineFutures(List<Future> combineFutures)
{
 for (Future future : combineFutures) {
  try {
   if (!future.isDone()) {
    // Cancel futures if close() for the iterator is called early due to some reason (e.g., test failure)
    future.cancel(true);
   } else {
    future.get();
   }
  }
  catch (InterruptedException | CancellationException e) {
   throw new QueryInterruptedException(e);
  }
  catch (ExecutionException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: apache/incubator-druid

throw new QueryInterruptedException(e);
throw new QueryInterruptedException(e);

代码示例来源:origin: apache/incubator-druid

public SecuritySanityCheckFilter(
  ObjectMapper jsonMapper
)
{
 try {
  QueryInterruptedException unauthorizedError = new QueryInterruptedException(
    QueryInterruptedException.UNAUTHORIZED,
    null,
    null,
    DruidNode.getDefaultHost()
  );
  unauthorizedError.setStackTrace(new StackTraceElement[0]);
  this.unauthorizedMessage = jsonMapper.writeValueAsString(unauthorizedError);
 }
 catch (Exception e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: apache/incubator-druid

private void handleUnauthenticatedRequest(
  final HttpServletResponse response
) throws IOException
{
 // Since this is the last filter in the chain, some previous authentication filter
 // should have placed an authentication result in the request.
 // If not, send an authentication challenge.
 Set<String> supportedAuthSchemes = new HashSet<>();
 for (Authenticator authenticator : authenticators) {
  String challengeHeader = authenticator.getAuthChallengeHeader();
  if (challengeHeader != null) {
   supportedAuthSchemes.add(challengeHeader);
  }
 }
 for (String authScheme : supportedAuthSchemes) {
  response.addHeader("WWW-Authenticate", authScheme);
 }
 QueryInterruptedException unauthorizedError = new QueryInterruptedException(
   QueryInterruptedException.UNAUTHORIZED,
   null,
   null,
   DruidNode.getDefaultHost()
 );
 unauthorizedError.setStackTrace(new StackTraceElement[0]);
 OutputStream out = response.getOutputStream();
 sendJsonError(response, HttpServletResponse.SC_UNAUTHORIZED, jsonMapper.writeValueAsString(unauthorizedError), out);
 out.close();
 return;
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testHost()
{
 Assert.assertEquals(
   "myhost",
   new QueryInterruptedException(new QueryInterruptedException(new CancellationException(), "myhost")).getHost()
 );
}

代码示例来源:origin: apache/incubator-druid

throw new QueryInterruptedException(e);

代码示例来源:origin: apache/incubator-druid

@Override
 public Sequence<Integer> run(QueryPlus<Integer> queryPlus, Map<String, Object> responseContext)
 {
  // do a lot of work
  synchronized (this) {
   try {
    hasStarted = true;
    start.countDown();
    neverRelease.lockInterruptibly();
   }
   catch (InterruptedException e) {
    interrupted = true;
    interruptedRunners.offer(this);
    stop.countDown();
    throw new QueryInterruptedException(e);
   }
  }
  hasCompleted = true;
  stop.countDown();
  return Sequences.simple(Collections.singletonList(123));
 }
}

代码示例来源:origin: apache/incubator-druid

throw new QueryInterruptedException(
   new ResourceLimitExceededException(
     "query[%s] url[%s] timed out or max bytes limit reached.",
if (nextToken == JsonToken.START_OBJECT) {
 QueryInterruptedException cause = jp.getCodec().readValue(jp, QueryInterruptedException.class);
 throw new QueryInterruptedException(cause, host);
} else if (nextToken != JsonToken.START_ARRAY) {
 throw new IAE("Next token wasn't a START_ARRAY, was[%s] from url [%s]", jp.getCurrentToken(), url);
throw new QueryInterruptedException(e, host);

代码示例来源:origin: apache/incubator-druid

log.warn(e, "Query interrupted, cancelling pending results, query id [%s]", query.getId());
future.cancel(true);
throw new QueryInterruptedException(e);
throw new QueryInterruptedException(e);
throw new QueryInterruptedException(e);

代码示例来源:origin: apache/incubator-druid

future.cancel(true);
closeOnFailure.close();
throw new QueryInterruptedException(e);
throw new QueryInterruptedException(e);
log.info("Query timeout, cancelling pending results for query id [%s]", query.getId());
future.cancel(true);
throw new QueryInterruptedException(e);

代码示例来源:origin: apache/incubator-druid

@Test
public void testErrorCode()
{
 Assert.assertEquals(
   "Query cancelled",
   new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getErrorCode()
 );
 Assert.assertEquals("Query cancelled", new QueryInterruptedException(new CancellationException()).getErrorCode());
 Assert.assertEquals("Query interrupted", new QueryInterruptedException(new InterruptedException()).getErrorCode());
 Assert.assertEquals("Query timeout", new QueryInterruptedException(new TimeoutException()).getErrorCode());
 Assert.assertEquals("Unknown exception", new QueryInterruptedException(null).getErrorCode());
 Assert.assertEquals("Unknown exception", new QueryInterruptedException(new ISE("Something bad!")).getErrorCode());
 Assert.assertEquals(
   "Resource limit exceeded",
   new QueryInterruptedException(new ResourceLimitExceededException("too many!")).getErrorCode()
 );
 Assert.assertEquals(
   "Unknown exception",
   new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getErrorCode()
 );
}

代码示例来源:origin: apache/incubator-druid

new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getMessage()
);
Assert.assertEquals(
  null,
  new QueryInterruptedException(new CancellationException()).getMessage()
);
Assert.assertEquals(
  null,
  new QueryInterruptedException(new InterruptedException()).getMessage()
);
Assert.assertEquals(
  null,
  new QueryInterruptedException(new TimeoutException()).getMessage()
);
Assert.assertEquals(
  null,
  new QueryInterruptedException(null).getMessage()
);
Assert.assertEquals(
  "too many!",
  new QueryInterruptedException(new ResourceLimitExceededException("too many!")).getMessage()
);
Assert.assertEquals(
  "Something bad!",
  new QueryInterruptedException(new ISE("Something bad!")).getMessage()
);
Assert.assertEquals(
  "Something bad!",
  new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getMessage()

代码示例来源:origin: apache/incubator-druid

new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getErrorClass()
);
Assert.assertEquals(
  "java.util.concurrent.CancellationException",
  new QueryInterruptedException(new CancellationException()).getErrorClass()
);
Assert.assertEquals(
  "java.lang.InterruptedException",
  new QueryInterruptedException(new InterruptedException()).getErrorClass()
);
Assert.assertEquals(
  "java.util.concurrent.TimeoutException",
  new QueryInterruptedException(new TimeoutException()).getErrorClass()
);
Assert.assertEquals(
  "org.apache.druid.query.ResourceLimitExceededException",
  new QueryInterruptedException(new ResourceLimitExceededException("too many!")).getErrorClass()
);
Assert.assertEquals(
  null,
  new QueryInterruptedException(null).getErrorClass()
);
Assert.assertEquals(
  "org.apache.druid.java.util.common.ISE",
  new QueryInterruptedException(new ISE("Something bad!")).getErrorClass()
);
Assert.assertEquals(
  "org.apache.druid.java.util.common.ISE",
  new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getErrorClass()

代码示例来源:origin: apache/incubator-druid

roundTrip(new QueryInterruptedException(new QueryInterruptedException(new CancellationException()))).getErrorCode()
);
Assert.assertEquals(
  "java.util.concurrent.CancellationException",
  roundTrip(new QueryInterruptedException(new QueryInterruptedException(new CancellationException()))).getErrorClass()
);
Assert.assertEquals(
  null,
  roundTrip(new QueryInterruptedException(new QueryInterruptedException(new CancellationException()))).getMessage()
);
Assert.assertEquals(
  "java.util.concurrent.CancellationException",
  roundTrip(new QueryInterruptedException(new CancellationException())).getErrorClass()
);
Assert.assertEquals(
  "java.lang.InterruptedException",
  roundTrip(new QueryInterruptedException(new InterruptedException())).getErrorClass()
);
Assert.assertEquals(
  "java.util.concurrent.TimeoutException",
  roundTrip(new QueryInterruptedException(new TimeoutException())).getErrorClass()
);
Assert.assertEquals(
  null,
  roundTrip(new QueryInterruptedException(null)).getErrorClass()
);
Assert.assertEquals(
  "org.apache.druid.java.util.common.ISE",
  roundTrip(new QueryInterruptedException(new ISE("Something bad!"))).getErrorClass()

代码示例来源:origin: org.apache.druid/druid-processing

public static QueryInterruptedException wrapIfNeeded(Throwable e)
 {
  return e instanceof QueryInterruptedException ? (QueryInterruptedException) e : new QueryInterruptedException(e);
 }
}

代码示例来源:origin: org.apache.druid/druid-processing

public static void checkInterrupted()
{
 if (Thread.interrupted()) {
  throw new QueryInterruptedException(new InterruptedException());
 }
}

代码示例来源:origin: org.apache.druid/druid-processing

private static void checkCombineFutures(List<Future> combineFutures)
{
 for (Future future : combineFutures) {
  try {
   if (!future.isDone()) {
    // Cancel futures if close() for the iterator is called early due to some reason (e.g., test failure)
    future.cancel(true);
   } else {
    future.get();
   }
  }
  catch (InterruptedException | CancellationException e) {
   throw new QueryInterruptedException(e);
  }
  catch (ExecutionException e) {
   throw new RuntimeException(e);
  }
 }
}

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

public SecuritySanityCheckFilter(
  ObjectMapper jsonMapper
)
{
 try {
  QueryInterruptedException unauthorizedError = new QueryInterruptedException(
    QueryInterruptedException.UNAUTHORIZED,
    null,
    null,
    DruidNode.getDefaultHost()
  );
  unauthorizedError.setStackTrace(new StackTraceElement[0]);
  this.unauthorizedMessage = jsonMapper.writeValueAsString(unauthorizedError);
 }
 catch (Exception e) {
  throw new RuntimeException(e);
 }
}

相关文章