Skip to content

Commit

Permalink
[hotfix][tests] Extend MockEnvironmentBuilder to support TaskManagerR…
Browse files Browse the repository at this point in the history
…untimeInfo
  • Loading branch information
zentol committed Sep 7, 2018
1 parent 2dbd413 commit b50a19b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.apache.flink.runtime.query.TaskKvStateRegistry;
import org.apache.flink.runtime.state.TaskStateManager;
import org.apache.flink.runtime.taskmanager.TaskManagerRuntimeInfo;
import org.apache.flink.runtime.util.TestingTaskManagerRuntimeInfo;
import org.apache.flink.types.Record;
import org.apache.flink.util.MutableObjectIterator;
import org.apache.flink.util.Preconditions;
Expand Down Expand Up @@ -91,6 +90,8 @@ public class MockEnvironment implements Environment, AutoCloseable {

private final JobVertexID jobVertexID;

private final TaskManagerRuntimeInfo taskManagerRuntimeInfo;

private final BroadcastVariableManager bcVarManager = new BroadcastVariableManager();

private final AccumulatorRegistry accumulatorRegistry;
Expand Down Expand Up @@ -127,7 +128,8 @@ protected MockEnvironment(
int parallelism,
int subtaskIndex,
ClassLoader userCodeClassLoader,
TaskMetricGroup taskMetricGroup) {
TaskMetricGroup taskMetricGroup,
TaskManagerRuntimeInfo taskManagerRuntimeInfo) {

this.jobID = jobID;
this.jobVertexID = jobVertexID;
Expand All @@ -140,6 +142,7 @@ protected MockEnvironment(

this.memManager = new MemoryManager(memorySize, 1);
this.ioManager = new IOManagerAsync();
this.taskManagerRuntimeInfo = taskManagerRuntimeInfo;

this.executionConfig = executionConfig;
this.inputSplitProvider = inputSplitProvider;
Expand Down Expand Up @@ -212,7 +215,7 @@ public Configuration getJobConfiguration() {

@Override
public TaskManagerRuntimeInfo getTaskManagerInfo() {
return new TestingTaskManagerRuntimeInfo();
return this.taskManagerRuntimeInfo;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups;
import org.apache.flink.runtime.state.TaskStateManager;
import org.apache.flink.runtime.state.TestTaskStateManager;
import org.apache.flink.runtime.taskmanager.TaskManagerRuntimeInfo;
import org.apache.flink.runtime.util.TestingTaskManagerRuntimeInfo;

public class MockEnvironmentBuilder {
private String taskName = "mock-task";
Expand All @@ -43,6 +45,7 @@ public class MockEnvironmentBuilder {
private JobID jobID = new JobID();
private JobVertexID jobVertexID = new JobVertexID();
private TaskMetricGroup taskMetricGroup = UnregisteredMetricGroups.createUnregisteredTaskMetricGroup();
private TaskManagerRuntimeInfo taskManagerRuntimeInfo = new TestingTaskManagerRuntimeInfo();

public MockEnvironmentBuilder setTaskName(String taskName) {
this.taskName = taskName;
Expand Down Expand Up @@ -79,6 +82,11 @@ public MockEnvironmentBuilder setExecutionConfig(ExecutionConfig executionConfig
return this;
}

public MockEnvironmentBuilder setTaskManagerRuntimeInfo(TaskManagerRuntimeInfo taskManagerRuntimeInfo){
this.taskManagerRuntimeInfo = taskManagerRuntimeInfo;
return this;
}

public MockEnvironmentBuilder setMaxParallelism(int maxParallelism) {
this.maxParallelism = maxParallelism;
return this;
Expand Down Expand Up @@ -129,6 +137,7 @@ public MockEnvironment build() {
parallelism,
subtaskIndex,
userCodeClassLoader,
taskMetricGroup);
taskMetricGroup,
taskManagerRuntimeInfo);
}
}

0 comments on commit b50a19b

Please sign in to comment.