Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Forever310
druid
提交
a541029b
D
druid
项目概览
Forever310
/
druid
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
druid
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a541029b
编写于
6月 10, 2014
作者:
X
Xavier Léauté
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
segmentMetadata query cancellation
上级
6550cb17
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
11 deletion
+42
-11
processing/src/main/java/io/druid/query/metadata/SegmentMetadataQueryRunnerFactory.java
...uid/query/metadata/SegmentMetadataQueryRunnerFactory.java
+39
-9
processing/src/test/java/io/druid/query/metadata/SegmentAnalyzerTest.java
...est/java/io/druid/query/metadata/SegmentAnalyzerTest.java
+2
-1
processing/src/test/java/io/druid/query/metadata/SegmentMetadataQueryTest.java
...ava/io/druid/query/metadata/SegmentMetadataQueryTest.java
+1
-1
未找到文件。
processing/src/main/java/io/druid/query/metadata/SegmentMetadataQueryRunnerFactory.java
浏览文件 @
a541029b
...
...
@@ -22,15 +22,21 @@ package io.druid.query.metadata;
import
com.google.common.base.Function
;
import
com.google.common.base.Throwables
;
import
com.google.common.collect.Maps
;
import
com.metamx.common.guava.ExecutorExecutingSequence
;
import
com.google.common.util.concurrent.ListenableFuture
;
import
com.google.common.util.concurrent.ListeningExecutorService
;
import
com.google.common.util.concurrent.MoreExecutors
;
import
com.google.inject.Inject
;
import
com.metamx.common.guava.Sequence
;
import
com.metamx.common.guava.Sequences
;
import
com.metamx.common.logger.Logger
;
import
io.druid.query.AbstractPrioritizedCallable
;
import
io.druid.query.ConcatQueryRunner
;
import
io.druid.query.Query
;
import
io.druid.query.QueryInterruptedException
;
import
io.druid.query.QueryRunner
;
import
io.druid.query.QueryRunnerFactory
;
import
io.druid.query.QueryToolChest
;
import
io.druid.query.QueryWatcher
;
import
io.druid.query.metadata.metadata.ColumnAnalysis
;
import
io.druid.query.metadata.metadata.ColumnIncluderator
;
import
io.druid.query.metadata.metadata.SegmentAnalysis
;
...
...
@@ -40,16 +46,27 @@ import io.druid.segment.Segment;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.concurrent.Ca
llable
;
import
java.util.concurrent.Ca
ncellationException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeoutException
;
public
class
SegmentMetadataQueryRunnerFactory
implements
QueryRunnerFactory
<
SegmentAnalysis
,
SegmentMetadataQuery
>
{
private
static
final
SegmentAnalyzer
analyzer
=
new
SegmentAnalyzer
();
private
static
final
SegmentMetadataQueryQueryToolChest
toolChest
=
new
SegmentMetadataQueryQueryToolChest
();
private
static
final
Logger
log
=
new
Logger
(
SegmentMetadataQueryRunnerFactory
.
class
);
private
final
QueryWatcher
queryWatcher
;
@Inject
public
SegmentMetadataQueryRunnerFactory
(
QueryWatcher
queryWatcher
)
{
this
.
queryWatcher
=
queryWatcher
;
}
@Override
public
QueryRunner
<
SegmentAnalysis
>
createRunner
(
final
Segment
segment
)
...
...
@@ -101,9 +118,10 @@ public class SegmentMetadataQueryRunnerFactory implements QueryRunnerFactory<Seg
@Override
public
QueryRunner
<
SegmentAnalysis
>
mergeRunners
(
final
ExecutorService
queryExecutor
,
Iterable
<
QueryRunner
<
SegmentAnalysis
>>
queryRunners
ExecutorService
exec
,
Iterable
<
QueryRunner
<
SegmentAnalysis
>>
queryRunners
)
{
final
ListeningExecutorService
queryExecutor
=
MoreExecutors
.
listeningDecorator
(
exec
);
return
new
ConcatQueryRunner
<
SegmentAnalysis
>(
Sequences
.
map
(
Sequences
.
simple
(
queryRunners
),
...
...
@@ -118,7 +136,7 @@ public class SegmentMetadataQueryRunnerFactory implements QueryRunnerFactory<Seg
public
Sequence
<
SegmentAnalysis
>
run
(
final
Query
<
SegmentAnalysis
>
query
)
{
final
int
priority
=
query
.
getContextPriority
(
0
);
Future
<
Sequence
<
SegmentAnalysis
>>
future
=
queryExecutor
.
submit
(
Listenable
Future
<
Sequence
<
SegmentAnalysis
>>
future
=
queryExecutor
.
submit
(
new
AbstractPrioritizedCallable
<
Sequence
<
SegmentAnalysis
>>(
priority
)
{
@Override
...
...
@@ -129,13 +147,25 @@ public class SegmentMetadataQueryRunnerFactory implements QueryRunnerFactory<Seg
}
);
try
{
return
future
.
get
();
queryWatcher
.
registerQuery
(
query
,
future
);
final
Number
timeout
=
query
.
getContextValue
(
"timeout"
,
(
Number
)
null
);
return
timeout
==
null
?
future
.
get
()
:
future
.
get
(
timeout
.
longValue
(),
TimeUnit
.
MILLISECONDS
);
}
catch
(
InterruptedException
e
)
{
throw
Throwables
.
propagate
(
e
);
log
.
warn
(
e
,
"Query interrupted, cancelling pending results, query id [%s]"
,
query
.
getId
());
future
.
cancel
(
true
);
throw
new
QueryInterruptedException
(
"Query interrupted"
);
}
catch
(
CancellationException
e
)
{
throw
new
QueryInterruptedException
(
"Query cancelled"
);
}
catch
(
TimeoutException
e
)
{
log
.
info
(
"Query timeout, cancelling pending results for query id [%s]"
,
query
.
getId
());
future
.
cancel
(
true
);
throw
new
QueryInterruptedException
(
"Query timeout"
);
}
catch
(
ExecutionException
e
)
{
throw
Throwables
.
propagate
(
e
);
throw
Throwables
.
propagate
(
e
.
getCause
()
);
}
}
};
...
...
processing/src/test/java/io/druid/query/metadata/SegmentAnalyzerTest.java
浏览文件 @
a541029b
...
...
@@ -25,6 +25,7 @@ import io.druid.query.LegacyDataSource;
import
io.druid.query.QueryRunner
;
import
io.druid.query.QueryRunnerFactory
;
import
io.druid.query.QueryRunnerTestHelper
;
import
io.druid.query.QueryWatcher
;
import
io.druid.query.metadata.metadata.ColumnAnalysis
;
import
io.druid.query.metadata.metadata.SegmentAnalysis
;
import
io.druid.query.metadata.metadata.SegmentMetadataQuery
;
...
...
@@ -95,7 +96,7 @@ public class SegmentAnalyzerTest
private
List
<
SegmentAnalysis
>
getSegmentAnalysises
(
Segment
index
)
{
final
QueryRunner
runner
=
QueryRunnerTestHelper
.
makeQueryRunner
(
(
QueryRunnerFactory
)
new
SegmentMetadataQueryRunnerFactory
(),
index
(
QueryRunnerFactory
)
new
SegmentMetadataQueryRunnerFactory
(
QueryRunnerTestHelper
.
NOOP_QUERYWATCHER
),
index
);
final
SegmentMetadataQuery
query
=
new
SegmentMetadataQuery
(
...
...
processing/src/test/java/io/druid/query/metadata/SegmentMetadataQueryTest.java
浏览文件 @
a541029b
...
...
@@ -45,7 +45,7 @@ public class SegmentMetadataQueryTest
{
@SuppressWarnings
(
"unchecked"
)
private
final
QueryRunner
runner
=
makeQueryRunner
(
new
SegmentMetadataQueryRunnerFactory
()
new
SegmentMetadataQueryRunnerFactory
(
QueryRunnerTestHelper
.
NOOP_QUERYWATCHER
)
);
private
ObjectMapper
mapper
=
new
DefaultObjectMapper
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录