You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by kk...@apache.org on 2020/04/30 20:10:47 UTC
[flink] 03/13: [FLINK-16661] Move the
ClassPathPackagedProgramRetriever to flink-clients
This is an automated email from the ASF dual-hosted git repository.
kkloudas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 93d4c35cad0cd95160f8269b661f01e6d7fa0bb9
Author: Kostas Kloudas <kk...@gmail.com>
AuthorDate: Thu Apr 16 13:31:20 2020 +0200
[FLINK-16661] Move the ClassPathPackagedProgramRetriever to flink-clients
This is done because the ClassPathPackagedProgramRetriever is going to be
also used by other ApplicationEntrypoints in the future, including the
YarnApplicationClusterEntryPoint.
---
flink-clients/pom.xml | 37 ++++-
.../ClassPathPackagedProgramRetriever.java | 22 +--
.../deployment/application}/JarManifestParser.java | 2 +-
...test-assembly-test-user-classloader-job-jar.xml | 2 +-
...-assembly-test-user-classloader-job-lib-jar.xml | 2 +-
.../flink/client/cli/CliFrontendInfoTest.java | 8 +-
.../flink/client/cli/CliFrontendTestUtils.java | 2 +-
.../ClassPathPackagedProgramRetrieverTest.java | 18 +--
.../application}/JarManifestParserTest.java | 8 +-
.../org/apache/flink/client/testjar}/TestJob.java | 7 +-
.../apache/flink/client}/testjar/TestJobInfo.java | 6 +-
.../client}/testjar/TestUserClassLoaderJob.java | 2 +-
.../client}/testjar/TestUserClassLoaderJobLib.java | 2 +-
.../org/apache/flink/client/testjar/WordCount.java | 171 ---------------------
flink-container/pom.xml | 93 -----------
.../entrypoint/StandaloneJobClusterEntryPoint.java | 1 +
.../src/test/assembly/test-assembly.xml | 35 -----
17 files changed, 78 insertions(+), 340 deletions(-)
diff --git a/flink-clients/pom.xml b/flink-clients/pom.xml
index 8781d7b..6505844 100644
--- a/flink-clients/pom.xml
+++ b/flink-clients/pom.xml
@@ -108,7 +108,7 @@ under the License.
<configuration>
<archive>
<manifest>
- <mainClass>org.apache.flink.client.testjar.WordCount</mainClass>
+ <mainClass>org.apache.flink.client.testjar.TestJob</mainClass>
</manifest>
</archive>
<finalName>maven</finalName>
@@ -118,6 +118,39 @@ under the License.
</descriptors>
</configuration>
</execution>
+ <execution>
+ <id>create-test-dependency-user-jar</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.flink.client.testjar.TestUserClassLoaderJob</mainClass>
+ </manifest>
+ </archive>
+ <finalName>maven</finalName>
+ <attach>false</attach>
+ <descriptors>
+ <descriptor>src/test/assembly/test-assembly-test-user-classloader-job-jar.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>create-test-dependency-user-jar-depend</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>maven</finalName>
+ <attach>false</attach>
+ <descriptors>
+ <descriptor>src/test/assembly/test-assembly-test-user-classloader-job-lib-jar.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
</executions>
</plugin>
<!--Remove the external jar test code from the test-classes directory since it mustn't be in the
@@ -139,7 +172,7 @@ under the License.
<fileset>
<directory>${project.build.testOutputDirectory}</directory>
<includes>
- <include>**/testjar/*.class</include>
+ <include>**/testjar/TestUser*.class</include>
</includes>
</fileset>
</filesets>
diff --git a/flink-container/src/main/java/org/apache/flink/container/entrypoint/ClassPathPackagedProgramRetriever.java b/flink-clients/src/main/java/org/apache/flink/client/deployment/application/ClassPathPackagedProgramRetriever.java
similarity index 91%
rename from flink-container/src/main/java/org/apache/flink/container/entrypoint/ClassPathPackagedProgramRetriever.java
rename to flink-clients/src/main/java/org/apache/flink/client/deployment/application/ClassPathPackagedProgramRetriever.java
index 6530d75..580af9c 100644
--- a/flink-container/src/main/java/org/apache/flink/container/entrypoint/ClassPathPackagedProgramRetriever.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/deployment/application/ClassPathPackagedProgramRetriever.java
@@ -16,13 +16,12 @@
* limitations under the License.
*/
-package org.apache.flink.container.entrypoint;
+package org.apache.flink.client.deployment.application;
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.client.program.PackagedProgram;
import org.apache.flink.client.program.PackagedProgramRetriever;
import org.apache.flink.client.program.ProgramInvocationException;
-import org.apache.flink.container.entrypoint.JarManifestParser.JarFileWithEntryClass;
import org.apache.flink.util.ExceptionUtils;
import org.apache.flink.util.FileUtils;
import org.apache.flink.util.FlinkException;
@@ -56,7 +55,7 @@ import static java.util.Objects.requireNonNull;
* which creates the {@link org.apache.flink.client.program.PackagedProgram PackagedProgram} containing
* the user's {@code main()} from a class on the class path.
*/
-class ClassPathPackagedProgramRetriever implements PackagedProgramRetriever {
+public class ClassPathPackagedProgramRetriever implements PackagedProgramRetriever {
private static final Logger LOG = LoggerFactory.getLogger(ClassPathPackagedProgramRetriever.class);
@@ -178,7 +177,7 @@ class ClassPathPackagedProgramRetriever implements PackagedProgramRetriever {
.collect(Collectors.toList());
}
- final JarFileWithEntryClass jobJar = JarManifestParser.findOnlyEntryClass(jars);
+ final JarManifestParser.JarFileWithEntryClass jobJar = JarManifestParser.findOnlyEntryClass(jars);
LOG.info("Using {} as job jar", jobJar);
return jobJar.getEntryClass();
}
@@ -208,7 +207,10 @@ class ClassPathPackagedProgramRetriever implements PackagedProgramRetriever {
}
}
- static class Builder {
+ /**
+ * A builder for the {@link ClassPathPackagedProgramRetriever}.
+ */
+ public static class Builder {
private final String[] programArguments;
@@ -224,22 +226,22 @@ class ClassPathPackagedProgramRetriever implements PackagedProgramRetriever {
this.programArguments = requireNonNull(programArguments);
}
- Builder setJobClassName(@Nullable String jobClassName) {
+ public Builder setJobClassName(@Nullable String jobClassName) {
this.jobClassName = jobClassName;
return this;
}
- Builder setUserLibDirectory(File userLibDirectory) {
+ public Builder setUserLibDirectory(File userLibDirectory) {
this.userLibDirectory = userLibDirectory;
return this;
}
- Builder setJarsOnClassPath(Supplier<Iterable<File>> jarsOnClassPath) {
+ public Builder setJarsOnClassPath(Supplier<Iterable<File>> jarsOnClassPath) {
this.jarsOnClassPath = jarsOnClassPath;
return this;
}
- ClassPathPackagedProgramRetriever build() throws IOException {
+ public ClassPathPackagedProgramRetriever build() throws IOException {
return new ClassPathPackagedProgramRetriever(
programArguments,
jobClassName,
@@ -248,7 +250,7 @@ class ClassPathPackagedProgramRetriever implements PackagedProgramRetriever {
}
}
- static Builder newBuilder(String[] programArguments) {
+ public static Builder newBuilder(String[] programArguments) {
return new Builder(programArguments);
}
}
diff --git a/flink-container/src/main/java/org/apache/flink/container/entrypoint/JarManifestParser.java b/flink-clients/src/main/java/org/apache/flink/client/deployment/application/JarManifestParser.java
similarity index 98%
rename from flink-container/src/main/java/org/apache/flink/container/entrypoint/JarManifestParser.java
rename to flink-clients/src/main/java/org/apache/flink/client/deployment/application/JarManifestParser.java
index f9c7490..39123ea 100644
--- a/flink-container/src/main/java/org/apache/flink/container/entrypoint/JarManifestParser.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/deployment/application/JarManifestParser.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.flink.container.entrypoint;
+package org.apache.flink.client.deployment.application;
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.client.program.PackagedProgram;
diff --git a/flink-container/src/test/assembly/test-assembly-test-user-classloader-job-jar.xml b/flink-clients/src/test/assembly/test-assembly-test-user-classloader-job-jar.xml
similarity index 91%
rename from flink-container/src/test/assembly/test-assembly-test-user-classloader-job-jar.xml
rename to flink-clients/src/test/assembly/test-assembly-test-user-classloader-job-jar.xml
index ac08f68..3430eec 100644
--- a/flink-container/src/test/assembly/test-assembly-test-user-classloader-job-jar.xml
+++ b/flink-clients/src/test/assembly/test-assembly-test-user-classloader-job-jar.xml
@@ -28,7 +28,7 @@ under the License.
<directory>${project.build.testOutputDirectory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
- <include>org/apache/flink/container/entrypoint/testjar/TestUserClassLoaderJob.class</include>
+ <include>org/apache/flink/client/testjar/TestUserClassLoaderJob.class</include>
</includes>
</fileSet>
</fileSets>
diff --git a/flink-container/src/test/assembly/test-assembly-test-user-classloader-job-lib-jar.xml b/flink-clients/src/test/assembly/test-assembly-test-user-classloader-job-lib-jar.xml
similarity index 91%
rename from flink-container/src/test/assembly/test-assembly-test-user-classloader-job-lib-jar.xml
rename to flink-clients/src/test/assembly/test-assembly-test-user-classloader-job-lib-jar.xml
index b151321..d8e52a3 100644
--- a/flink-container/src/test/assembly/test-assembly-test-user-classloader-job-lib-jar.xml
+++ b/flink-clients/src/test/assembly/test-assembly-test-user-classloader-job-lib-jar.xml
@@ -28,7 +28,7 @@ under the License.
<directory>${project.build.testOutputDirectory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
- <include>org/apache/flink/container/entrypoint/testjar/TestUserClassLoaderJobLib.class</include>
+ <include>org/apache/flink/client/testjar/TestUserClassLoaderJobLib.class</include>
</includes>
</fileSet>
</fileSets>
diff --git a/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendInfoTest.java b/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendInfoTest.java
index 3d71858..693c1cf 100644
--- a/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendInfoTest.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendInfoTest.java
@@ -63,13 +63,13 @@ public class CliFrontendInfoTest extends CliFrontendTestBase {
replaceStdOut();
try {
- String[] parameters = new String[]{CliFrontendTestUtils.getTestJarPath(), "-f", "true"};
+ String[] parameters = new String[]{CliFrontendTestUtils.getTestJarPath(), "-f", "true", "--arg", "suffix"};
Configuration configuration = getConfiguration();
CliFrontend testFrontend = new CliFrontend(
configuration,
Collections.singletonList(getCli(configuration)));
testFrontend.info(parameters);
- assertTrue(buffer.toString().contains("\"parallelism\": \"4\""));
+ assertTrue(buffer.toString().contains("\"parallelism\" : 4"));
}
finally {
restoreStdOut();
@@ -80,13 +80,13 @@ public class CliFrontendInfoTest extends CliFrontendTestBase {
public void testShowExecutionPlanWithParallelism() {
replaceStdOut();
try {
- String[] parameters = {"-p", "17", CliFrontendTestUtils.getTestJarPath()};
+ String[] parameters = {"-p", "17", CliFrontendTestUtils.getTestJarPath(), "--arg", "suffix"};
Configuration configuration = getConfiguration();
CliFrontend testFrontend = new CliFrontend(
configuration,
Collections.singletonList(getCli(configuration)));
testFrontend.info(parameters);
- assertTrue(buffer.toString().contains("\"parallelism\": \"17\""));
+ assertTrue(buffer.toString().contains("\"parallelism\" : 17"));
}
catch (Exception e) {
e.printStackTrace();
diff --git a/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendTestUtils.java b/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendTestUtils.java
index b47986f..9857664 100644
--- a/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendTestUtils.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendTestUtils.java
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertEquals;
*/
public class CliFrontendTestUtils {
- public static final String TEST_JAR_MAIN_CLASS = "org.apache.flink.client.testjar.WordCount";
+ public static final String TEST_JAR_MAIN_CLASS = "org.apache.flink.client.testjar.TestJob";
public static final String TEST_JAR_CLASSLOADERTEST_CLASS = "org.apache.flink.client.testjar.JobWithExternalDependency";
diff --git a/flink-container/src/test/java/org/apache/flink/container/entrypoint/ClassPathPackagedProgramRetrieverTest.java b/flink-clients/src/test/java/org/apache/flink/client/deployment/application/ClassPathPackagedProgramRetrieverTest.java
similarity index 94%
rename from flink-container/src/test/java/org/apache/flink/container/entrypoint/ClassPathPackagedProgramRetrieverTest.java
rename to flink-clients/src/test/java/org/apache/flink/client/deployment/application/ClassPathPackagedProgramRetrieverTest.java
index 4f52865..a6856e2 100644
--- a/flink-container/src/test/java/org/apache/flink/container/entrypoint/ClassPathPackagedProgramRetrieverTest.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/deployment/application/ClassPathPackagedProgramRetrieverTest.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.flink.container.entrypoint;
+package org.apache.flink.client.deployment.application;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.dag.Pipeline;
@@ -24,13 +24,13 @@ import org.apache.flink.client.deployment.executors.PipelineExecutorUtils;
import org.apache.flink.client.program.PackagedProgram;
import org.apache.flink.client.program.PackagedProgramUtils;
import org.apache.flink.client.program.ProgramInvocationException;
+import org.apache.flink.client.testjar.TestJob;
+import org.apache.flink.client.testjar.TestJobInfo;
import org.apache.flink.configuration.ConfigUtils;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.CoreOptions;
import org.apache.flink.configuration.PipelineOptions;
import org.apache.flink.configuration.PipelineOptionsInternal;
-import org.apache.flink.container.entrypoint.ClassPathPackagedProgramRetriever.JarsOnClassPath;
-import org.apache.flink.container.entrypoint.testjar.TestJobInfo;
import org.apache.flink.runtime.jobgraph.JobGraph;
import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings;
import org.apache.flink.util.ExceptionUtils;
@@ -202,7 +202,7 @@ public class ClassPathPackagedProgramRetrieverTest extends TestLogger {
@Test
public void testJarFromClassPathSupplierSanityCheck() {
- Iterable<File> jarFiles = JarsOnClassPath.INSTANCE.get();
+ Iterable<File> jarFiles = ClassPathPackagedProgramRetriever.JarsOnClassPath.INSTANCE.get();
// Junit executes this test, so it should be returned as part of JARs on the class path
assertThat(jarFiles, hasItem(hasProperty("name", containsString("junit"))));
@@ -312,18 +312,18 @@ public class ClassPathPackagedProgramRetrieverTest extends TestLogger {
}
private static String javaClassPath(String... entries) {
- String pathSeparator = System.getProperty(JarsOnClassPath.PATH_SEPARATOR);
+ String pathSeparator = System.getProperty(ClassPathPackagedProgramRetriever.JarsOnClassPath.PATH_SEPARATOR);
return String.join(pathSeparator, entries);
}
private static Iterable<File> setClassPathAndGetJarsOnClassPath(String classPath) {
- final String originalClassPath = System.getProperty(JarsOnClassPath.JAVA_CLASS_PATH);
+ final String originalClassPath = System.getProperty(ClassPathPackagedProgramRetriever.JarsOnClassPath.JAVA_CLASS_PATH);
try {
- System.setProperty(JarsOnClassPath.JAVA_CLASS_PATH, classPath);
- return JarsOnClassPath.INSTANCE.get();
+ System.setProperty(ClassPathPackagedProgramRetriever.JarsOnClassPath.JAVA_CLASS_PATH, classPath);
+ return ClassPathPackagedProgramRetriever.JarsOnClassPath.INSTANCE.get();
} finally {
// Reset property
- System.setProperty(JarsOnClassPath.JAVA_CLASS_PATH, originalClassPath);
+ System.setProperty(ClassPathPackagedProgramRetriever.JarsOnClassPath.JAVA_CLASS_PATH, originalClassPath);
}
}
}
diff --git a/flink-container/src/test/java/org/apache/flink/container/entrypoint/JarManifestParserTest.java b/flink-clients/src/test/java/org/apache/flink/client/deployment/application/JarManifestParserTest.java
similarity index 94%
rename from flink-container/src/test/java/org/apache/flink/container/entrypoint/JarManifestParserTest.java
rename to flink-clients/src/test/java/org/apache/flink/client/deployment/application/JarManifestParserTest.java
index f414659..4829290 100644
--- a/flink-container/src/test/java/org/apache/flink/container/entrypoint/JarManifestParserTest.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/deployment/application/JarManifestParserTest.java
@@ -16,10 +16,10 @@
* limitations under the License.
*/
-package org.apache.flink.container.entrypoint;
+package org.apache.flink.client.deployment.application;
import org.apache.flink.client.program.PackagedProgram;
-import org.apache.flink.container.entrypoint.JarManifestParser.JarFileWithEntryClass;
+import org.apache.flink.client.testjar.TestJob;
import org.apache.flink.util.TestLogger;
import org.apache.flink.shaded.guava18.com.google.common.collect.ImmutableList;
@@ -124,7 +124,7 @@ public class JarManifestParserTest extends TestLogger {
public void testFindOnlyEntryClassSingleJar() throws IOException {
File jarFile = TestJob.getTestJobJar();
- JarFileWithEntryClass jarFileWithEntryClass = JarManifestParser.findOnlyEntryClass(ImmutableList.of(jarFile));
+ JarManifestParser.JarFileWithEntryClass jarFileWithEntryClass = JarManifestParser.findOnlyEntryClass(ImmutableList.of(jarFile));
assertThat(jarFileWithEntryClass.getEntryClass(), is(equalTo(TestJob.class.getCanonicalName())));
}
@@ -141,7 +141,7 @@ public class JarManifestParserTest extends TestLogger {
File jarWithNoManifest = createJarFileWithManifest(ImmutableMap.of());
File jarFile = TestJob.getTestJobJar();
- JarFileWithEntryClass jarFileWithEntryClass = JarManifestParser
+ JarManifestParser.JarFileWithEntryClass jarFileWithEntryClass = JarManifestParser
.findOnlyEntryClass(ImmutableList.of(jarWithNoManifest, jarFile));
assertThat(jarFileWithEntryClass.getEntryClass(), is(equalTo(TestJob.class.getCanonicalName())));
diff --git a/flink-container/src/test/java/org/apache/flink/container/entrypoint/TestJob.java b/flink-clients/src/test/java/org/apache/flink/client/testjar/TestJob.java
similarity index 91%
rename from flink-container/src/test/java/org/apache/flink/container/entrypoint/TestJob.java
rename to flink-clients/src/test/java/org/apache/flink/client/testjar/TestJob.java
index d4c17d0..59d66ed 100644
--- a/flink-container/src/test/java/org/apache/flink/container/entrypoint/TestJob.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/testjar/TestJob.java
@@ -16,9 +16,10 @@
* limitations under the License.
*/
-package org.apache.flink.container.entrypoint;
+package org.apache.flink.client.testjar;
import org.apache.flink.api.java.utils.ParameterTool;
+import org.apache.flink.client.deployment.application.ClassPathPackagedProgramRetrieverTest;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -49,12 +50,12 @@ public class TestJob {
* @return Test jar file
* @throws FileNotFoundException If test-jar can not be found
*/
- static File getTestJobJar() throws FileNotFoundException {
+ public static File getTestJobJar() throws FileNotFoundException {
// Check the module's pom.xml for how we create the JAR
File f = new File("target/maven-test-jar.jar");
if (!f.exists()) {
throw new FileNotFoundException("Test jar not present. Invoke tests using Maven "
- + "or build the jar using 'mvn process-test-classes' in flink-container");
+ + "or build the jar using 'mvn process-test-classes' in flink-clients");
}
return f;
}
diff --git a/flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestJobInfo.java b/flink-clients/src/test/java/org/apache/flink/client/testjar/TestJobInfo.java
similarity index 80%
rename from flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestJobInfo.java
rename to flink-clients/src/test/java/org/apache/flink/client/testjar/TestJobInfo.java
index d682ecc..73c3815 100644
--- a/flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestJobInfo.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/testjar/TestJobInfo.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.flink.container.entrypoint.testjar;
+package org.apache.flink.client.testjar;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -26,8 +26,8 @@ import java.nio.file.Paths;
*/
public class TestJobInfo {
- public static final String JOB_CLASS = "org.apache.flink.container.entrypoint.testjar.TestUserClassLoaderJob";
- public static final String JOB_LIB_CLASS = "org.apache.flink.container.entrypoint.testjar.TestUserClassLoaderJobLib";
+ public static final String JOB_CLASS = "org.apache.flink.client.testjar.TestUserClassLoaderJob";
+ public static final String JOB_LIB_CLASS = "org.apache.flink.client.testjar.TestUserClassLoaderJobLib";
public static final Path JOB_JAR_PATH = Paths.get("target", "maven-test-user-classloader-job-jar.jar");
public static final Path JOB_LIB_JAR_PATH = Paths.get("target", "maven-test-user-classloader-job-lib-jar.jar");
}
diff --git a/flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestUserClassLoaderJob.java b/flink-clients/src/test/java/org/apache/flink/client/testjar/TestUserClassLoaderJob.java
similarity index 97%
rename from flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestUserClassLoaderJob.java
rename to flink-clients/src/test/java/org/apache/flink/client/testjar/TestUserClassLoaderJob.java
index 1f68db0..ca8df68 100644
--- a/flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestUserClassLoaderJob.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/testjar/TestUserClassLoaderJob.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.flink.container.entrypoint.testjar;
+package org.apache.flink.client.testjar;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
diff --git a/flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestUserClassLoaderJobLib.java b/flink-clients/src/test/java/org/apache/flink/client/testjar/TestUserClassLoaderJobLib.java
similarity index 94%
rename from flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestUserClassLoaderJobLib.java
rename to flink-clients/src/test/java/org/apache/flink/client/testjar/TestUserClassLoaderJobLib.java
index 82f5a29..0996e6f 100644
--- a/flink-container/src/test/java/org/apache/flink/container/entrypoint/testjar/TestUserClassLoaderJobLib.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/testjar/TestUserClassLoaderJobLib.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.flink.container.entrypoint.testjar;
+package org.apache.flink.client.testjar;
/**
* This class is depended by {@link TestUserClassLoaderJob}.
diff --git a/flink-clients/src/test/java/org/apache/flink/client/testjar/WordCount.java b/flink-clients/src/test/java/org/apache/flink/client/testjar/WordCount.java
deleted file mode 100644
index a7070ef..0000000
--- a/flink-clients/src/test/java/org/apache/flink/client/testjar/WordCount.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.client.testjar;
-
-import org.apache.flink.api.common.functions.RichFlatMapFunction;
-import org.apache.flink.api.java.DataSet;
-import org.apache.flink.api.java.ExecutionEnvironment;
-import org.apache.flink.api.java.aggregation.Aggregations;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.util.Collector;
-
-/**
- * WordCount for placing at least something into the jar file.
- */
-public class WordCount {
-
- // *************************************************************************
- // PROGRAM
- // *************************************************************************
-
- public static void main(String[] args) throws Exception {
-
- if (!parseParameters(args)) {
- return;
- }
-
- // set up the execution environment
- final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
-
- // get input data
- DataSet<String> text = getTextDataSet(env);
-
- DataSet<Tuple2<String, Integer>> counts =
- // split up the lines in pairs (2-tuples) containing: (word,1)
- text.flatMap(new Tokenizer())
- // group by the tuple field "0" and sum up tuple field "1"
- .groupBy(0)
- .aggregate(Aggregations.SUM, 1);
-
- // emit result
- if (fileOutput) {
- counts.writeAsCsv(outputPath, "\n", " ");
- // execute program
- env.execute("WordCount Example");
- } else {
- counts.print();
- }
- }
-
- // *************************************************************************
- // USER FUNCTIONS
- // *************************************************************************
-
- /**
- * Implements the string tokenizer that splits sentences into words as a user-defined
- * FlatMapFunction. The function takes a line (String) and splits it into
- * multiple pairs in the form of "(word,1)" (Tuple2<String, Integer>).
- */
- public static final class Tokenizer extends RichFlatMapFunction<String, Tuple2<String, Integer>> {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void flatMap(String value, Collector<Tuple2<String, Integer>> out) {
- // normalize and split the line
- String[] tokens = value.toLowerCase().split("\\W+");
-
- // emit the pairs
- for (String token : tokens) {
- if (token.length() > 0) {
- out.collect(new Tuple2<String, Integer>(token, 1));
- }
- }
- }
- }
-
- // *************************************************************************
- // UTIL METHODS
- // *************************************************************************
-
- private static boolean fileOutput = false;
-
- private static String textPath;
- private static String outputPath;
-
- private static boolean parseParameters(String[] args) {
-
- if (args.length > 0) {
- // parse input arguments
- fileOutput = true;
- if (args.length == 2) { // cli line: program {textPath} {outputPath}
- textPath = args[0];
- outputPath = args[1];
- } else if (args.length == 4 && (args[0].startsWith("-v") || args[0].startsWith("--verbose"))) { // cli line: program {optArg} {optVal} {textPath} {outputPath}
- Boolean.valueOf(args[1]); // parse verbosity flag
- textPath = args[2];
- outputPath = args[3];
- } else {
- System.err.println("Usage: WordCount <text path> <result path>");
- return false;
- }
- } else {
- System.out.println("Executing WordCount example with built-in default data.");
- System.out.println(" Provide parameters to read input data from a file.");
- System.out.println(" Usage: WordCount <text path> <result path>");
- }
- return true;
- }
-
- private static DataSet<String> getTextDataSet(ExecutionEnvironment env) {
- if (fileOutput) {
- // read the text file from given input path
- return env.readTextFile(textPath);
- } else {
- // get default test text data
- return env.fromElements(
- "To be, or not to be,--that is the question:--",
- "Whether 'tis nobler in the mind to suffer",
- "The slings and arrows of outrageous fortune",
- "Or to take arms against a sea of troubles,",
- "And by opposing end them?--To die,--to sleep,--",
- "No more; and by a sleep to say we end",
- "The heartache, and the thousand natural shocks",
- "That flesh is heir to,--'tis a consummation",
- "Devoutly to be wish'd. To die,--to sleep;--",
- "To sleep! perchance to dream:--ay, there's the rub;",
- "For in that sleep of death what dreams may come,",
- "When we have shuffled off this mortal coil,",
- "Must give us pause: there's the respect",
- "That makes calamity of so long life;",
- "For who would bear the whips and scorns of time,",
- "The oppressor's wrong, the proud man's contumely,",
- "The pangs of despis'd love, the law's delay,",
- "The insolence of office, and the spurns",
- "That patient merit of the unworthy takes,",
- "When he himself might his quietus make",
- "With a bare bodkin? who would these fardels bear,",
- "To grunt and sweat under a weary life,",
- "But that the dread of something after death,--",
- "The undiscover'd country, from whose bourn",
- "No traveller returns,--puzzles the will,",
- "And makes us rather bear those ills we have",
- "Than fly to others that we know not of?",
- "Thus conscience does make cowards of us all;",
- "And thus the native hue of resolution",
- "Is sicklied o'er with the pale cast of thought;",
- "And enterprises of great pith and moment,",
- "With this regard, their currents turn awry,",
- "And lose the name of action.--Soft you now!",
- "The fair Ophelia!--Nymph, in thy orisons",
- "Be all my sins remember'd."
- );
- }
- }
-}
diff --git a/flink-container/pom.xml b/flink-container/pom.xml
index 80755d7..8ad5847 100644
--- a/flink-container/pom.xml
+++ b/flink-container/pom.xml
@@ -66,97 +66,4 @@ under the License.
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <!-- Assemble a test jar for EntryClassParserTest. More information on this:
- http://stackoverflow.com/questions/1401857/using-maven-to-build-separate-jar-files-for-unit-testing-a-custom-class-loader
- -->
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.4</version><!--$NO-MVN-MAN-VER$-->
- <executions>
- <execution>
- <id>create-test-dependency</id>
- <phase>process-test-classes</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.apache.flink.container.entrypoint.TestJob</mainClass>
- </manifest>
- </archive>
- <finalName>maven</finalName>
- <attach>false</attach>
- <descriptors>
- <descriptor>src/test/assembly/test-assembly.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- <execution>
- <id>create-test-dependency-user-jar</id>
- <phase>process-test-classes</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.apache.flink.container.entrypoint.testjar.TestUserClassLoaderJob</mainClass>
- </manifest>
- </archive>
- <finalName>maven</finalName>
- <attach>false</attach>
- <descriptors>
- <descriptor>src/test/assembly/test-assembly-test-user-classloader-job-jar.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- <execution>
- <id>create-test-dependency-user-jar-depend</id>
- <phase>process-test-classes</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <finalName>maven</finalName>
- <attach>false</attach>
- <descriptors>
- <descriptor>src/test/assembly/test-assembly-test-user-classloader-job-lib-jar.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!--Remove the external jar test code from the test-classes directory since it mustn't be in the
- classpath when running the tests to actually test whether the user code class loader
- is properly used.-->
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.5</version><!--$NO-MVN-MAN-VER$-->
- <executions>
- <execution>
- <id>remove-externaltestclasses</id>
- <phase>process-test-classes</phase>
- <goals>
- <goal>clean</goal>
- </goals>
- <configuration>
- <excludeDefaultDirectories>true</excludeDefaultDirectories>
- <filesets>
- <fileset>
- <directory>${project.build.testOutputDirectory}</directory>
- <includes>
- <include>**/testjar/TestUser*.class</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/flink-container/src/main/java/org/apache/flink/container/entrypoint/StandaloneJobClusterEntryPoint.java b/flink-container/src/main/java/org/apache/flink/container/entrypoint/StandaloneJobClusterEntryPoint.java
index d28052c..3490d38 100644
--- a/flink-container/src/main/java/org/apache/flink/container/entrypoint/StandaloneJobClusterEntryPoint.java
+++ b/flink-container/src/main/java/org/apache/flink/container/entrypoint/StandaloneJobClusterEntryPoint.java
@@ -21,6 +21,7 @@ package org.apache.flink.container.entrypoint;
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.api.common.JobID;
import org.apache.flink.client.deployment.application.ApplicationDispatcherLeaderProcessFactoryFactory;
+import org.apache.flink.client.deployment.application.ClassPathPackagedProgramRetriever;
import org.apache.flink.client.deployment.application.executors.EmbeddedExecutor;
import org.apache.flink.client.program.PackagedProgram;
import org.apache.flink.client.program.PackagedProgramRetriever;
diff --git a/flink-container/src/test/assembly/test-assembly.xml b/flink-container/src/test/assembly/test-assembly.xml
deleted file mode 100644
index e29953c..0000000
--- a/flink-container/src/test/assembly/test-assembly.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
-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.
--->
-
-<assembly>
- <id>test-jar</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.testOutputDirectory}</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>org/apache/flink/container/entrypoint/TestJob</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>