uce 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_r260744178
 
 

 ##########
 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:
   Don't have that information in the return value. Do you want me to change it?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to