You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2019/01/24 19:47:19 UTC
[flink] 04/06: [hotfix][tests] Remove BlobServer from
JobManagerRunnerTest
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 9d9863e9119e6394ecee68c80f7ae22ce4c7aa59
Author: Till Rohrmann <tr...@apache.org>
AuthorDate: Fri Jan 18 13:43:37 2019 +0100
[hotfix][tests] Remove BlobServer from JobManagerRunnerTest
---
.../runtime/blob/VoidPermanentBlobService.java | 41 +++++++++++++
.../ContextClassLoaderLibraryCacheManager.java | 70 ++++++++++++++++++++++
.../runtime/jobmaster/JobManagerRunnerTest.java | 34 +++++------
.../TestingJobManagerSharedServicesBuilder.java | 3 +-
4 files changed, 130 insertions(+), 18 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/VoidPermanentBlobService.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/VoidPermanentBlobService.java
new file mode 100644
index 0000000..d431a90
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/VoidPermanentBlobService.java
@@ -0,0 +1,41 @@
+/*
+ * 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.blob;
+
+import org.apache.flink.api.common.JobID;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * {@link PermanentBlobService} implementation for testing purposes.
+ */
+public enum VoidPermanentBlobService implements PermanentBlobService {
+ INSTANCE;
+
+ @Override
+ public File getFile(JobID jobId, PermanentBlobKey key) throws IOException {
+ throw new IOException(String.format("Could not find file for job id %s and key %s.", jobId, key));
+ }
+
+ @Override
+ public void close() throws IOException {
+
+ }
+}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/ContextClassLoaderLibraryCacheManager.java b/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/ContextClassLoaderLibraryCacheManager.java
new file mode 100644
index 0000000..9b866b3
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/ContextClassLoaderLibraryCacheManager.java
@@ -0,0 +1,70 @@
+/*
+ * 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.execution.librarycache;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.blob.PermanentBlobKey;
+import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
+
+import javax.annotation.Nonnull;
+
+import java.net.URL;
+import java.util.Collection;
+
+/**
+ * {@link LibraryCacheManager} implementation which returns the context class loader.
+ */
+public enum ContextClassLoaderLibraryCacheManager implements LibraryCacheManager {
+ INSTANCE;
+
+ @Override
+ public ClassLoader getClassLoader(JobID id) {
+ return getClass().getClassLoader();
+ }
+
+ @Override
+ public void registerJob(JobID id, Collection<PermanentBlobKey> requiredJarFiles, Collection<URL> requiredClasspaths) {
+
+ }
+
+ @Override
+ public void registerTask(JobID id, ExecutionAttemptID execution, Collection<PermanentBlobKey> requiredJarFiles, Collection<URL> requiredClasspaths) {
+
+ }
+
+ @Override
+ public void unregisterTask(JobID id, ExecutionAttemptID execution) {
+
+ }
+
+ @Override
+ public void unregisterJob(JobID id) {
+
+ }
+
+ @Override
+ public void shutdown() {
+
+ }
+
+ @Override
+ public boolean hasClassLoader(@Nonnull JobID jobId) {
+ return true;
+ }
+}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerTest.java
index bf2576b..da5a9ff 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerTest.java
@@ -21,11 +21,11 @@ package org.apache.flink.runtime.jobmaster;
import org.apache.flink.api.common.JobID;
import org.apache.flink.configuration.BlobServerOptions;
import org.apache.flink.configuration.Configuration;
-import org.apache.flink.runtime.blob.BlobServer;
-import org.apache.flink.runtime.blob.VoidBlobStore;
+import org.apache.flink.runtime.blob.VoidPermanentBlobService;
import org.apache.flink.runtime.checkpoint.StandaloneCheckpointRecoveryFactory;
import org.apache.flink.runtime.clusterframework.types.ResourceID;
-import org.apache.flink.runtime.execution.librarycache.LibraryCacheManager;
+import org.apache.flink.runtime.execution.librarycache.BlobLibraryCacheManager;
+import org.apache.flink.runtime.execution.librarycache.FlinkUserCodeClassLoaders;
import org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph;
import org.apache.flink.runtime.heartbeat.HeartbeatServices;
import org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices;
@@ -72,8 +72,6 @@ public class JobManagerRunnerTest extends TestLogger {
private static TestingRpcService rpcService;
- private static BlobServer blobServer;
-
private static HeartbeatServices heartbeatServices = new HeartbeatServices(1000L, 1000L);
private static JobManagerSharedServices jobManagerSharedServices;
@@ -93,11 +91,7 @@ public class JobManagerRunnerTest extends TestLogger {
configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
- blobServer = new BlobServer(
- configuration,
- new VoidBlobStore());
-
- jobManagerSharedServices = JobManagerSharedServices.fromConfiguration(configuration, blobServer);
+ jobManagerSharedServices = new TestingJobManagerSharedServicesBuilder().build();
final JobVertex jobVertex = new JobVertex("Test vertex");
jobVertex.setInvokableClass(NoOpInvokable.class);
@@ -130,10 +124,6 @@ public class JobManagerRunnerTest extends TestLogger {
jobManagerSharedServices.shutdown();
}
- if (blobServer != null) {
- blobServer.close();
- }
-
if (rpcService != null) {
rpcService.stopService();
}
@@ -208,13 +198,18 @@ public class JobManagerRunnerTest extends TestLogger {
@Test
public void testLibraryCacheManagerRegistration() throws Exception {
- final JobManagerRunner jobManagerRunner = createJobManagerRunner();
+ final BlobLibraryCacheManager libraryCacheManager = new BlobLibraryCacheManager(
+ VoidPermanentBlobService.INSTANCE,
+ FlinkUserCodeClassLoaders.ResolveOrder.CHILD_FIRST,
+ new String[]{});
+ final JobManagerSharedServices jobManagerSharedServices = new TestingJobManagerSharedServicesBuilder()
+ .setLibraryCacheManager(libraryCacheManager)
+ .build();
+ final JobManagerRunner jobManagerRunner = createJobManagerRunner(jobManagerSharedServices);
try {
jobManagerRunner.start();
- final LibraryCacheManager libraryCacheManager = jobManagerSharedServices.getLibraryCacheManager();
-
final JobID jobID = jobGraph.getJobID();
assertThat(libraryCacheManager.hasClassLoader(jobID), is(true));
@@ -228,6 +223,11 @@ public class JobManagerRunnerTest extends TestLogger {
@Nonnull
private JobManagerRunner createJobManagerRunner() throws Exception {
+ return createJobManagerRunner(jobManagerSharedServices);
+ }
+
+ @Nonnull
+ private JobManagerRunner createJobManagerRunner(final JobManagerSharedServices jobManagerSharedServices) throws Exception {
return new JobManagerRunner(
ResourceID.generate(),
jobGraph,
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/TestingJobManagerSharedServicesBuilder.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/TestingJobManagerSharedServicesBuilder.java
index ae20d1e..1edffe4 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/TestingJobManagerSharedServicesBuilder.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/TestingJobManagerSharedServicesBuilder.java
@@ -20,6 +20,7 @@ package org.apache.flink.runtime.jobmaster;
import org.apache.flink.runtime.blob.BlobWriter;
import org.apache.flink.runtime.blob.VoidBlobWriter;
+import org.apache.flink.runtime.execution.librarycache.ContextClassLoaderLibraryCacheManager;
import org.apache.flink.runtime.execution.librarycache.LibraryCacheManager;
import org.apache.flink.runtime.executiongraph.restart.NoOrFixedIfCheckpointingEnabledRestartStrategyFactory;
import org.apache.flink.runtime.executiongraph.restart.RestartStrategyFactory;
@@ -51,7 +52,7 @@ public class TestingJobManagerSharedServicesBuilder {
public TestingJobManagerSharedServicesBuilder() {
scheduledExecutorService = TestingUtils.defaultExecutor();
- libraryCacheManager = mock(LibraryCacheManager.class);
+ libraryCacheManager = ContextClassLoaderLibraryCacheManager.INSTANCE;
restartStrategyFactory = new NoOrFixedIfCheckpointingEnabledRestartStrategyFactory();
stackTraceSampleCoordinator = mock(StackTraceSampleCoordinator.class);
backPressureStatsTracker = VoidBackPressureStatsTracker.INSTANCE;