-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hotfix] Introduce SlotPoolResource and TestingRpcServiceResource
- Loading branch information
1 parent
d5919d9
commit 217c312
Showing
6 changed files
with
221 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...k-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.runtime.jobmaster.slotpool; | ||
|
||
import org.apache.flink.api.common.JobID; | ||
import org.apache.flink.runtime.jobmaster.JobMasterId; | ||
import org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway; | ||
import org.apache.flink.runtime.rpc.RpcService; | ||
|
||
import org.junit.rules.ExternalResource; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* {@link ExternalResource} which provides a {@link SlotPool}. | ||
*/ | ||
public class SlotPoolResource extends ExternalResource { | ||
|
||
@Nonnull | ||
private final RpcService rpcService; | ||
|
||
@Nonnull | ||
private final SchedulingStrategy schedulingStrategy; | ||
|
||
private SlotPool slotPool; | ||
|
||
private SlotPoolGateway slotPoolGateway; | ||
|
||
private TestingResourceManagerGateway testingResourceManagerGateway; | ||
|
||
public SlotPoolResource(@Nonnull RpcService rpcService, @Nonnull SchedulingStrategy schedulingStrategy) { | ||
this.rpcService = rpcService; | ||
this.schedulingStrategy = schedulingStrategy; | ||
slotPool = null; | ||
slotPoolGateway = null; | ||
testingResourceManagerGateway = null; | ||
} | ||
|
||
public SlotProvider getSlotProvider() { | ||
checkInitialized(); | ||
return slotPool.getSlotProvider(); | ||
} | ||
|
||
public TestingResourceManagerGateway getTestingResourceManagerGateway() { | ||
checkInitialized(); | ||
return testingResourceManagerGateway; | ||
} | ||
|
||
public SlotPoolGateway getSlotPoolGateway() { | ||
checkInitialized(); | ||
return slotPoolGateway; | ||
} | ||
|
||
private void checkInitialized() { | ||
assert(slotPool != null); | ||
} | ||
|
||
@Override | ||
protected void before() throws Throwable { | ||
if (slotPool != null) { | ||
terminateSlotPool(); | ||
} | ||
|
||
testingResourceManagerGateway = new TestingResourceManagerGateway(); | ||
|
||
slotPool = new SlotPool( | ||
rpcService, | ||
new JobID(), | ||
schedulingStrategy); | ||
|
||
slotPool.start(JobMasterId.generate(), "foobar"); | ||
|
||
slotPoolGateway = slotPool.getSelfGateway(SlotPoolGateway.class); | ||
|
||
slotPool.connectToResourceManager(testingResourceManagerGateway); | ||
} | ||
|
||
@Override | ||
protected void after() { | ||
if (slotPool != null) { | ||
terminateSlotPool(); | ||
slotPool = null; | ||
} | ||
} | ||
|
||
private void terminateSlotPool() { | ||
slotPool.shutDown(); | ||
CompletableFuture<Void> terminationFuture = slotPool.getTerminationFuture(); | ||
terminationFuture.join(); | ||
} | ||
} |
96 changes: 0 additions & 96 deletions
96
...src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolSchedulingTestBase.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.