Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Forever310
druid
提交
0e1a8f6f
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,发现更多精彩内容 >>
提交
0e1a8f6f
编写于
8月 09, 2014
作者:
F
fjy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
concurrency my old foe, we meet again
上级
d58ae945
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
25 deletion
+26
-25
server/src/main/java/io/druid/server/coordinator/LoadQueuePeon.java
.../main/java/io/druid/server/coordinator/LoadQueuePeon.java
+26
-25
未找到文件。
server/src/main/java/io/druid/server/coordinator/LoadQueuePeon.java
浏览文件 @
0e1a8f6f
...
@@ -57,7 +57,16 @@ public class LoadQueuePeon
...
@@ -57,7 +57,16 @@ public class LoadQueuePeon
private
static
final
int
DROP
=
0
;
private
static
final
int
DROP
=
0
;
private
static
final
int
LOAD
=
1
;
private
static
final
int
LOAD
=
1
;
private
static
Comparator
<
DataSegment
>
segmentHolderComparator
=
Comparators
.
inverse
(
DataSegment
.
bucketMonthComparator
());
private
static
Comparator
<
DataSegment
>
segmentComparator
=
Comparators
.
inverse
(
DataSegment
.
bucketMonthComparator
());
private
static
void
executeCallbacks
(
List
<
LoadPeonCallback
>
callbacks
)
{
for
(
LoadPeonCallback
callback
:
callbacks
)
{
if
(
callback
!=
null
)
{
callback
.
execute
();
}
}
}
private
final
CuratorFramework
curator
;
private
final
CuratorFramework
curator
;
private
final
String
basePath
;
private
final
String
basePath
;
...
@@ -70,10 +79,10 @@ public class LoadQueuePeon
...
@@ -70,10 +79,10 @@ public class LoadQueuePeon
private
final
AtomicInteger
failedAssignCount
=
new
AtomicInteger
(
0
);
private
final
AtomicInteger
failedAssignCount
=
new
AtomicInteger
(
0
);
private
final
ConcurrentSkipListMap
<
DataSegment
,
SegmentHolder
>
segmentsToLoad
=
new
ConcurrentSkipListMap
<>(
private
final
ConcurrentSkipListMap
<
DataSegment
,
SegmentHolder
>
segmentsToLoad
=
new
ConcurrentSkipListMap
<>(
segment
Holder
Comparator
segmentComparator
);
);
private
final
ConcurrentSkipListMap
<
DataSegment
,
SegmentHolder
>
segmentsToDrop
=
new
ConcurrentSkipListMap
<>(
private
final
ConcurrentSkipListMap
<
DataSegment
,
SegmentHolder
>
segmentsToDrop
=
new
ConcurrentSkipListMap
<>(
segment
Holder
Comparator
segmentComparator
);
);
private
final
Object
lock
=
new
Object
();
private
final
Object
lock
=
new
Object
();
...
@@ -120,8 +129,8 @@ public class LoadQueuePeon
...
@@ -120,8 +129,8 @@ public class LoadQueuePeon
}
}
public
void
loadSegment
(
public
void
loadSegment
(
DataSegment
segment
,
final
DataSegment
segment
,
LoadPeonCallback
callback
final
LoadPeonCallback
callback
)
)
{
{
synchronized
(
lock
)
{
synchronized
(
lock
)
{
...
@@ -134,8 +143,6 @@ public class LoadQueuePeon
...
@@ -134,8 +143,6 @@ public class LoadQueuePeon
}
}
}
}
final
SegmentHolder
holder
=
new
SegmentHolder
(
segment
,
LOAD
,
Arrays
.
asList
(
callback
));
synchronized
(
lock
)
{
synchronized
(
lock
)
{
final
SegmentHolder
existingHolder
=
segmentsToLoad
.
get
(
segment
);
final
SegmentHolder
existingHolder
=
segmentsToLoad
.
get
(
segment
);
if
(
existingHolder
!=
null
)
{
if
(
existingHolder
!=
null
)
{
...
@@ -148,13 +155,13 @@ public class LoadQueuePeon
...
@@ -148,13 +155,13 @@ public class LoadQueuePeon
log
.
info
(
"Asking server peon[%s] to load segment[%s]"
,
basePath
,
segment
.
getIdentifier
());
log
.
info
(
"Asking server peon[%s] to load segment[%s]"
,
basePath
,
segment
.
getIdentifier
());
queuedSize
.
addAndGet
(
segment
.
getSize
());
queuedSize
.
addAndGet
(
segment
.
getSize
());
segmentsToLoad
.
put
(
segment
,
holder
);
segmentsToLoad
.
put
(
segment
,
new
SegmentHolder
(
segment
,
LOAD
,
Arrays
.
asList
(
callback
))
);
doNext
();
doNext
();
}
}
public
void
dropSegment
(
public
void
dropSegment
(
DataSegment
segment
,
final
DataSegment
segment
,
LoadPeonCallback
callback
final
LoadPeonCallback
callback
)
)
{
{
synchronized
(
lock
)
{
synchronized
(
lock
)
{
...
@@ -167,8 +174,6 @@ public class LoadQueuePeon
...
@@ -167,8 +174,6 @@ public class LoadQueuePeon
}
}
}
}
SegmentHolder
holder
=
new
SegmentHolder
(
segment
,
DROP
,
Arrays
.
asList
(
callback
));
synchronized
(
lock
)
{
synchronized
(
lock
)
{
final
SegmentHolder
existingHolder
=
segmentsToDrop
.
get
(
segment
);
final
SegmentHolder
existingHolder
=
segmentsToDrop
.
get
(
segment
);
if
(
existingHolder
!=
null
)
{
if
(
existingHolder
!=
null
)
{
...
@@ -180,7 +185,7 @@ public class LoadQueuePeon
...
@@ -180,7 +185,7 @@ public class LoadQueuePeon
}
}
log
.
info
(
"Asking server peon[%s] to drop segment[%s]"
,
basePath
,
segment
.
getIdentifier
());
log
.
info
(
"Asking server peon[%s] to drop segment[%s]"
,
basePath
,
segment
.
getIdentifier
());
segmentsToDrop
.
put
(
segment
,
holder
);
segmentsToDrop
.
put
(
segment
,
new
SegmentHolder
(
segment
,
DROP
,
Arrays
.
asList
(
callback
))
);
doNext
();
doNext
();
}
}
...
@@ -305,14 +310,15 @@ public class LoadQueuePeon
...
@@ -305,14 +310,15 @@ public class LoadQueuePeon
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
final
List
<
LoadPeonCallback
>
callbacks
=
currentlyProcessing
.
getCallbacks
();
currentlyProcessing
=
null
;
callBackExecutor
.
execute
(
callBackExecutor
.
execute
(
new
Runnable
()
new
Runnable
()
{
{
@Override
@Override
public
void
run
()
public
void
run
()
{
{
currentlyProcessing
.
executeCallbacks
();
executeCallbacks
(
callbacks
);
currentlyProcessing
=
null
;
}
}
}
}
);
);
...
@@ -323,20 +329,20 @@ public class LoadQueuePeon
...
@@ -323,20 +329,20 @@ public class LoadQueuePeon
{
{
synchronized
(
lock
)
{
synchronized
(
lock
)
{
if
(
currentlyProcessing
!=
null
)
{
if
(
currentlyProcessing
!=
null
)
{
currentlyProcessing
.
executeCallbacks
(
);
executeCallbacks
(
currentlyProcessing
.
getCallbacks
()
);
currentlyProcessing
=
null
;
currentlyProcessing
=
null
;
}
}
if
(!
segmentsToDrop
.
isEmpty
())
{
if
(!
segmentsToDrop
.
isEmpty
())
{
for
(
SegmentHolder
holder
:
segmentsToDrop
.
values
())
{
for
(
SegmentHolder
holder
:
segmentsToDrop
.
values
())
{
holder
.
executeCallbacks
(
);
executeCallbacks
(
holder
.
getCallbacks
()
);
}
}
}
}
segmentsToDrop
.
clear
();
segmentsToDrop
.
clear
();
if
(!
segmentsToLoad
.
isEmpty
())
{
if
(!
segmentsToLoad
.
isEmpty
())
{
for
(
SegmentHolder
holder
:
segmentsToLoad
.
values
())
{
for
(
SegmentHolder
holder
:
segmentsToLoad
.
values
())
{
holder
.
executeCallbacks
(
);
executeCallbacks
(
holder
.
getCallbacks
()
);
}
}
}
}
segmentsToLoad
.
clear
();
segmentsToLoad
.
clear
();
...
@@ -433,15 +439,10 @@ public class LoadQueuePeon
...
@@ -433,15 +439,10 @@ public class LoadQueuePeon
}
}
}
}
public
void
execute
Callbacks
()
public
List
<
LoadPeonCallback
>
get
Callbacks
()
{
{
synchronized
(
callbacks
)
{
synchronized
(
callbacks
)
{
for
(
LoadPeonCallback
callback
:
callbacks
)
{
return
callbacks
;
if
(
callback
!=
null
)
{
callback
.
execute
();
}
}
callbacks
.
clear
();
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录