Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
c54d9a64
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c54d9a64
编写于
2月 17, 2019
作者:
T
tison
提交者:
Chesnay Schepler
2月 22, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-10569][runtime] Remove Instance usage in ExecutionVertexCancelTest
上级
991a5595
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
51 deletion
+24
-51
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphTestUtils.java
...flink/runtime/executiongraph/ExecutionGraphTestUtils.java
+2
-1
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java
...ink/runtime/executiongraph/ExecutionVertexCancelTest.java
+22
-50
未找到文件。
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphTestUtils.java
浏览文件 @
c54d9a64
...
...
@@ -47,6 +47,7 @@ import org.apache.flink.runtime.jobgraph.JobVertex;
import
org.apache.flink.runtime.jobgraph.JobVertexID
;
import
org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable
;
import
org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway
;
import
org.apache.flink.runtime.jobmaster.LogicalSlot
;
import
org.apache.flink.runtime.jobmaster.SlotOwner
;
import
org.apache.flink.runtime.jobmaster.slotpool.SlotProvider
;
import
org.apache.flink.runtime.messages.Acknowledge
;
...
...
@@ -337,7 +338,7 @@ public class ExecutionGraphTestUtils {
}
}
public
static
void
setVertexResource
(
ExecutionVertex
vertex
,
Simple
Slot
slot
)
{
public
static
void
setVertexResource
(
ExecutionVertex
vertex
,
Logical
Slot
slot
)
{
Execution
exec
=
vertex
.
getCurrentExecutionAttempt
();
if
(!
exec
.
tryAssignResource
(
slot
))
{
...
...
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java
浏览文件 @
c54d9a64
...
...
@@ -18,10 +18,11 @@
package
org.apache.flink.runtime.executiongraph
;
import
org.apache.flink.api.common.time.Time
;
import
org.apache.flink.runtime.akka.AkkaUtils
;
import
org.apache.flink.runtime.concurrent.FutureUtils
;
import
org.apache.flink.runtime.execution.ExecutionState
;
import
org.apache.flink.runtime.instance.ActorGateway
;
import
org.apache.flink.runtime.instance.BaseTestingActorGateway
;
import
org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway
;
import
org.apache.flink.runtime.instance.DummyActorGateway
;
import
org.apache.flink.runtime.instance.Instance
;
import
org.apache.flink.runtime.instance.SimpleSlot
;
...
...
@@ -29,10 +30,9 @@ import org.apache.flink.runtime.jobgraph.JobStatus;
import
org.apache.flink.runtime.jobgraph.JobVertexID
;
import
org.apache.flink.runtime.jobmanager.scheduler.LocationPreferenceConstraint
;
import
org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway
;
import
org.apache.flink.runtime.jobmaster.LogicalSlot
;
import
org.apache.flink.runtime.jobmaster.TestingLogicalSlot
;
import
org.apache.flink.runtime.messages.Acknowledge
;
import
org.apache.flink.runtime.messages.TaskMessages.CancelTask
;
import
org.apache.flink.runtime.messages.TaskMessages.SubmitTask
;
import
org.apache.flink.runtime.testingUtils.TestingUtils
;
import
org.apache.flink.runtime.testutils.DirectScheduledExecutorService
;
import
org.apache.flink.util.TestLogger
;
...
...
@@ -40,8 +40,7 @@ import org.junit.Test;
import
java.io.IOException
;
import
java.util.Collections
;
import
scala.concurrent.ExecutionContext
;
import
java.util.concurrent.CompletableFuture
;
import
static
org
.
apache
.
flink
.
runtime
.
executiongraph
.
ExecutionGraphTestUtils
.
getExecutionVertex
;
import
static
org
.
apache
.
flink
.
runtime
.
executiongraph
.
ExecutionGraphTestUtils
.
getInstance
;
...
...
@@ -124,12 +123,7 @@ public class ExecutionVertexCancelTest extends TestLogger {
final
ExecutionVertex
vertex
=
new
ExecutionVertex
(
ejv
,
0
,
new
IntermediateResult
[
0
],
AkkaUtils
.
getDefaultTimeout
());
ActorGateway
actorGateway
=
new
CancelSequenceActorGateway
(
TestingUtils
.
directExecutionContext
(),
1
);
Instance
instance
=
getInstance
(
new
ActorTaskManagerGateway
(
actorGateway
));
SimpleSlot
slot
=
instance
.
allocateSimpleSlot
();
LogicalSlot
slot
=
new
TestingLogicalSlot
(
new
CancelSequenceSimpleAckingTaskManagerGateway
(
1
));
setVertexResource
(
vertex
,
slot
);
setVertexState
(
vertex
,
ExecutionState
.
RUNNING
);
...
...
@@ -141,7 +135,7 @@ public class ExecutionVertexCancelTest extends TestLogger {
assertEquals
(
ExecutionState
.
CANCELED
,
vertex
.
getExecutionState
());
assert
True
(
slot
.
isReleased
());
assert
False
(
slot
.
isAlive
());
assertNull
(
vertex
.
getFailureCause
());
...
...
@@ -164,12 +158,7 @@ public class ExecutionVertexCancelTest extends TestLogger {
final
ExecutionVertex
vertex
=
new
ExecutionVertex
(
ejv
,
0
,
new
IntermediateResult
[
0
],
AkkaUtils
.
getDefaultTimeout
());
final
ActorGateway
actorGateway
=
new
CancelSequenceActorGateway
(
TestingUtils
.
directExecutionContext
(),
1
);
Instance
instance
=
getInstance
(
new
ActorTaskManagerGateway
(
actorGateway
));
SimpleSlot
slot
=
instance
.
allocateSimpleSlot
();
LogicalSlot
slot
=
new
TestingLogicalSlot
(
new
CancelSequenceSimpleAckingTaskManagerGateway
(
1
));
setVertexResource
(
vertex
,
slot
);
setVertexState
(
vertex
,
ExecutionState
.
RUNNING
);
...
...
@@ -189,7 +178,7 @@ public class ExecutionVertexCancelTest extends TestLogger {
assertEquals
(
ExecutionState
.
CANCELED
,
vertex
.
getExecutionState
());
assert
True
(
slot
.
isReleased
());
assert
False
(
slot
.
isAlive
());
assertNull
(
vertex
.
getFailureCause
());
...
...
@@ -212,12 +201,7 @@ public class ExecutionVertexCancelTest extends TestLogger {
final
ExecutionVertex
vertex
=
new
ExecutionVertex
(
ejv
,
0
,
new
IntermediateResult
[
0
],
AkkaUtils
.
getDefaultTimeout
());
final
ActorGateway
actorGateway
=
new
CancelSequenceActorGateway
(
TestingUtils
.
directExecutionContext
(),
1
);
Instance
instance
=
getInstance
(
new
ActorTaskManagerGateway
(
actorGateway
));
SimpleSlot
slot
=
instance
.
allocateSimpleSlot
();
LogicalSlot
slot
=
new
TestingLogicalSlot
(
new
CancelSequenceSimpleAckingTaskManagerGateway
(
1
));
setVertexResource
(
vertex
,
slot
);
setVertexState
(
vertex
,
ExecutionState
.
RUNNING
);
...
...
@@ -247,10 +231,7 @@ public class ExecutionVertexCancelTest extends TestLogger {
final
ExecutionVertex
vertex
=
new
ExecutionVertex
(
ejv
,
0
,
new
IntermediateResult
[
0
],
AkkaUtils
.
getDefaultTimeout
());
final
ActorGateway
gateway
=
new
CancelSequenceActorGateway
(
TestingUtils
.
directExecutionContext
(),
0
);
Instance
instance
=
getInstance
(
new
ActorTaskManagerGateway
(
gateway
));
SimpleSlot
slot
=
instance
.
allocateSimpleSlot
();
LogicalSlot
slot
=
new
TestingLogicalSlot
(
new
CancelSequenceSimpleAckingTaskManagerGateway
(
0
));
setVertexResource
(
vertex
,
slot
);
setVertexState
(
vertex
,
ExecutionState
.
RUNNING
);
...
...
@@ -262,7 +243,7 @@ public class ExecutionVertexCancelTest extends TestLogger {
// Callback fails, leading to CANCELED
assertEquals
(
ExecutionState
.
CANCELED
,
vertex
.
getExecutionState
());
assert
True
(
slot
.
isReleased
());
assert
False
(
slot
.
isAlive
());
assertTrue
(
vertex
.
getStateTimestamp
(
ExecutionState
.
CREATED
)
>
0
);
assertTrue
(
vertex
.
getStateTimestamp
(
ExecutionState
.
CANCELING
)
>
0
);
...
...
@@ -399,33 +380,24 @@ public class ExecutionVertexCancelTest extends TestLogger {
}
}
public
static
class
CancelSequence
ActorGateway
extends
BaseTestingActo
rGateway
{
public
static
class
CancelSequence
SimpleAckingTaskManagerGateway
extends
SimpleAckingTaskManage
rGateway
{
private
final
int
successfulOperations
;
private
int
index
=
-
1
;
public
CancelSequence
ActorGateway
(
ExecutionContext
executionContext
,
int
successfulOperations
)
{
super
(
executionContext
);
public
CancelSequence
SimpleAckingTaskManagerGateway
(
int
successfulOperations
)
{
super
();
this
.
successfulOperations
=
successfulOperations
;
}
@Override
public
Object
handleMessage
(
Object
message
)
throws
Exception
{
Object
result
;
if
(
message
instanceof
SubmitTask
)
{
result
=
Acknowledge
.
get
();
}
else
if
(
message
instanceof
CancelTask
)
{
index
++;
if
(
index
>=
successfulOperations
){
throw
new
IOException
(
"RPC call failed."
);
}
else
{
result
=
Acknowledge
.
get
();
}
public
CompletableFuture
<
Acknowledge
>
cancelTask
(
ExecutionAttemptID
executionAttemptID
,
Time
timeout
)
{
index
++;
if
(
index
>=
successfulOperations
)
{
return
FutureUtils
.
completedExceptionally
(
new
IOException
(
"Rpc call fails"
));
}
else
{
re
sult
=
null
;
re
turn
CompletableFuture
.
completedFuture
(
Acknowledge
.
get
())
;
}
return
result
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录