本文整理了Java中org.apache.druid.query.QueryInterruptedException
类的一些代码示例,展示了QueryInterruptedException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryInterruptedException
类的具体详情如下:
包路径:org.apache.druid.query.QueryInterruptedException
类名称:QueryInterruptedException
[英]Exception representing a failed query. The name "QueryInterruptedException" is a misnomer; this is actually used on the client side for all kinds of failed queries. Fields: - "errorCode" is a well-defined errorCode code taken from a specific list (see the static constants). "Unknown exception" represents all wrapped exceptions other than interrupt/timeout/cancellation. - "errorMessage" is the toString of the wrapped exception - "errorClass" is the class of the wrapped exception - "host" is the host that the errorCode occurred on The QueryResource is expected to emit the JSON form of this object when errors happen, and the DirectDruidClient deserializes and wraps them.
[中]表示失败查询的异常。“QueryInterruptedException”这个名字用词不当;这实际上在客户端用于所有失败的查询。字段:-“errorCode”是从特定列表中提取的定义良好的errorCode代码(参见静态常量)。“未知异常”表示除中断/超时/取消之外的所有包装异常。-“errorMessage”是包装异常的toString——“errorClass”是包装异常的类——“host”是发生错误时QueryResource上发生的错误代码预计将发出此对象的JSON形式的主机,DirectDruidClient将对其进行反序列化和包装。
代码示例来源:origin: apache/incubator-druid
private static String getErrorCodeFromThrowable(Throwable e)
{
if (e instanceof QueryInterruptedException) {
return ((QueryInterruptedException) e).getErrorCode();
} else if (e instanceof InterruptedException) {
return QUERY_INTERRUPTED;
} else if (e instanceof CancellationException) {
return QUERY_CANCELLED;
} else if (e instanceof TimeoutException) {
return QUERY_TIMEOUT;
} else if (e instanceof ResourceLimitExceededException) {
return RESOURCE_LIMIT_EXCEEDED;
} else {
return UNKNOWN_EXCEPTION;
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public String toString()
{
return StringUtils.format(
"QueryInterruptedException{msg=%s, code=%s, class=%s, host=%s}",
getMessage(),
errorCode,
errorClass,
host
);
}
代码示例来源:origin: apache/incubator-druid
public static QueryInterruptedException wrapIfNeeded(Throwable e)
{
return e instanceof QueryInterruptedException ? (QueryInterruptedException) e : new QueryInterruptedException(e);
}
}
代码示例来源:origin: apache/incubator-druid
public QueryInterruptedException(Throwable cause, String host)
{
super(cause == null ? null : cause.getMessage(), cause);
this.errorCode = getErrorCodeFromThrowable(cause);
this.errorClass = getErrorClassFromThrowable(cause);
this.host = host;
}
代码示例来源: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
@Test
public void testHost()
{
Assert.assertEquals(
"myhost",
new QueryInterruptedException(new QueryInterruptedException(new CancellationException(), "myhost")).getHost()
);
}
代码示例来源: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: apache/incubator-druid
@Test
public void testCannotConvert() throws Exception
{
// SELECT + ORDER unsupported
final QueryInterruptedException exception = doPost(
new SqlQuery("SELECT dim1 FROM druid.foo ORDER BY dim1", ResultFormat.OBJECT, false, null)
).lhs;
Assert.assertNotNull(exception);
Assert.assertEquals(QueryInterruptedException.UNKNOWN_EXCEPTION, exception.getErrorCode());
Assert.assertEquals(ISE.class.getName(), exception.getErrorClass());
Assert.assertTrue(
exception.getMessage()
.contains("Cannot build plan for query: SELECT dim1 FROM druid.foo ORDER BY dim1")
);
checkSqlRequestLog(false);
}
代码示例来源:origin: apache/incubator-druid
Assert.assertEquals("testing1", actualException.getErrorCode());
Assert.assertEquals("testing2", actualException.getMessage());
Assert.assertEquals(hostName, actualException.getHost());
EasyMock.verify(httpClient);
代码示例来源: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
@Test
public void testResourceLimitExceeded() throws Exception
{
final QueryInterruptedException exception = doPost(
new SqlQuery(
"SELECT DISTINCT dim1 FROM foo",
ResultFormat.OBJECT,
false,
ImmutableMap.of("maxMergingDictionarySize", 1)
)
).lhs;
Assert.assertNotNull(exception);
Assert.assertEquals(exception.getErrorCode(), QueryInterruptedException.RESOURCE_LIMIT_EXCEEDED);
Assert.assertEquals(exception.getErrorClass(), ResourceLimitExceededException.class.getName());
checkSqlRequestLog(false);
}
代码示例来源: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
private static String getHostFromThrowable(Throwable e)
{
if (e instanceof QueryInterruptedException) {
return ((QueryInterruptedException) e).getHost();
} else {
return null;
}
}
代码示例来源:origin: apache/incubator-druid
private static String getErrorClassFromThrowable(Throwable e)
{
if (e instanceof QueryInterruptedException) {
return ((QueryInterruptedException) e).getErrorClass();
} else if (e != null) {
return e.getClass().getName();
} else {
return null;
}
}
代码示例来源:origin: apache/incubator-druid
Response gotError(Exception e) throws IOException
{
return Response.serverError()
.type(contentType)
.entity(newOutputWriter(false).writeValueAsBytes(QueryInterruptedException.wrapIfNeeded(e)))
.build();
}
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testCannotValidate() throws Exception
{
final QueryInterruptedException exception = doPost(
new SqlQuery(
"SELECT dim4 FROM druid.foo",
ResultFormat.OBJECT,
false,
null
)
).lhs;
Assert.assertNotNull(exception);
Assert.assertEquals(QueryInterruptedException.UNKNOWN_EXCEPTION, exception.getErrorCode());
Assert.assertEquals(ValidationException.class.getName(), exception.getErrorClass());
Assert.assertTrue(exception.getMessage().contains("Column 'dim4' not found in any table"));
checkSqlRequestLog(false);
}
代码示例来源: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: org.apache.druid/druid-processing
private static String getHostFromThrowable(Throwable e)
{
if (e instanceof QueryInterruptedException) {
return ((QueryInterruptedException) e).getHost();
} else {
return null;
}
}
代码示例来源:origin: org.apache.druid/druid-processing
private static String getErrorClassFromThrowable(Throwable e)
{
if (e instanceof QueryInterruptedException) {
return ((QueryInterruptedException) e).getErrorClass();
} else if (e != null) {
return e.getClass().getName();
} else {
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!