zentol commented on a change in pull request #7717: [FLINK-11533] [container]
Add option parse JAR manifest for jobClassName
URL: https://github.com/apache/flink/pull/7717#discussion_r260722788
##########
File path:
flink-container/src/main/java/org/apache/flink/container/entrypoint/ClassPathJobGraphRetriever.java
##########
@@ -82,11 +112,58 @@ public JobGraph retrieveJobGraph(Configuration
configuration) throws FlinkExcept
}
private PackagedProgram createPackagedProgram() throws FlinkException {
+ final String entryClass = getJobClassNameOrScanClassPath();
try {
- final Class<?> mainClass =
getClass().getClassLoader().loadClass(jobClassName);
+ final Class<?> mainClass =
getClass().getClassLoader().loadClass(entryClass);
return new PackagedProgram(mainClass, programArguments);
} catch (ClassNotFoundException | ProgramInvocationException e)
{
throw new FlinkException("Could not load the provided
entrypoint class.", e);
}
}
+
+ private String getJobClassNameOrScanClassPath() throws FlinkException {
+ if (jobClassName != null) {
+ return jobClassName;
+ }
+
+ try {
+ return scanClassPathForJobJar();
+ } catch (IOException | NoSuchElementException |
IllegalArgumentException e) {
+ throw new FlinkException("Failed to find job JAR on
class path. Please provide the job class name explicitly.", e);
+ }
+ }
+
+ private String scanClassPathForJobJar() throws IOException {
+ LOG.info("Scanning class path for job JAR");
+ String entryClass =
JarManifestParser.findOnlyEntryClass(jarsOnClassPath.get());
+
+ LOG.info("Using '{}' as entry class for job", entryClass);
Review comment:
log which jar the class manifest entry originates from
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services