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_r258432536
 
 

 ##########
 File path: 
flink-container/src/main/java/org/apache/flink/container/entrypoint/ClassPathJobGraphRetriever.java
 ##########
 @@ -83,10 +98,38 @@ public JobGraph retrieveJobGraph(Configuration 
configuration) throws FlinkExcept
 
        private PackagedProgram createPackagedProgram() throws FlinkException {
                try {
-                       final Class<?> mainClass = 
getClass().getClassLoader().loadClass(jobClassName);
+                       final Class<?> mainClass = 
getClass().getClassLoader().loadClass(findEntryClass());
                        return new PackagedProgram(mainClass, programArguments);
-               } catch (ClassNotFoundException | ProgramInvocationException e) 
{
+               } catch (ClassNotFoundException | IOException | 
ProgramInvocationException e) {
                        throw new FlinkException("Could not load the provided 
entrypoint class.", e);
                }
        }
+
+       private String findEntryClass() throws IOException {
+               if (startsWithFromJarPrefix(jobClassName)) {
+                       File jarFile = getJarFile(jobClassName);
+                       LOG.info("Parsing manifest of '{}' to find job entry 
class", jarFile.getAbsolutePath());
+
+                       // We find the entry class manually here instead of 
providing the JAR to PackagedProgram, because
+                       // we want the exact same behavior in all cases, i.e. 
when providing a JAR or a job class name.
+                       //
+                       // Using PackagedProgram with a JAR as argument would 
have slightly different behavior than the code
 
 Review comment:
   what is the difference?

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

Reply via email to