You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by 윤형덕 <yn...@naver.com> on 2016/05/19 14:46:15 UTC
inheritance of Program interface in Program.java in org.apache.flink.api.common
hello first I'm sorry for my poor english.
I were looking at PackagedProgram.java from org.apache.flink.client.program
and in following cunstructor: PackagedProgram(File jarFile, List classpaths, String entryPointClassName, String... args)
there is some code I couldn't understand. please look blow
this.mainClass = loadMainClass(entryPointClassName, userCodeClassLoader);
if (Program.class.isAssignableFrom(this.mainClass)) {
Program prg = null;
try {
prg = InstantiationUtil.instantiate(this.mainClass.asSubclass(Program.class), Program.class);
}
how can this.mainClass that doesn't override getPlan method that is abstract method of Program interface(program.class) and has only static main method be instantiate as Program?
Thank you for your reading.
Re: inheritance of Program interface in Program.java in org.apache.flink.api.common
Posted by 윤형덕 <yn...@naver.com>.
then this.program of PackageProgram's object has null. [1]
in run() of CliFrontend.java, invokes executeProgramBlocking(program, client, userParallelism) [2]
and this method invokes client.runBlocking(program, parallelism) [3]
and this method invokes runBlocking(prog.getPlanWithJars(), parallelism, prog.getSavepointPath()) that is overloaded function[4]
and prog.getPlanWithJars() invokes getPlan() of PackagedProgram.java[5]
and getPlan() invokes createPlanFromProgram(this.program, this.args); [6]
and createPlanFromProgram's source is folowing
private static Plan createPlanFromProgram(Program program, String[] options) throws ProgramInvocationException {
try {
return program.getPlan(options);
} catch (Throwable t) {
throw new ProgramInvocationException("Error while calling the program: " + t.getMessage(), t);
}
}
as we checked, this.program has null. so if we invoke program.getPlan(options), exception will happen.
but when i runned program, exception didn't occur.
i'd appreciate if you explain this.
[1]
else if (hasMainMethod(mainClass)) {
this.program = null;
[2]
if (options.getDetachedMode() || (yarnCluster != null && yarnCluster.isDetached())) {
exitCode = executeProgramDetached(program, client, userParallelism);
} else {
exitCode = executeProgramBlocking(program, client, userParallelism);
}
[3]
protected int executeProgramBlocking(PackagedProgram program, Client client, int parallelism) {
LOG.info("Starting execution of program");
JobSubmissionResult result;
try {
result = client.runBlocking(program, parallelism);
}
[4]
public JobSubmissionResult runBlocking(PackagedProgram prog, int parallelism) throws ProgramInvocationException {
Thread.currentThread().setContextClassLoader(prog.getUserCodeClassLoader());
if (prog.isUsingProgramEntryPoint()) {
return runBlocking(prog.getPlanWithJars(), parallelism, prog.getSavepointPath());
}
[5]
public JobWithJars getPlanWithJars() throws ProgramInvocationException {
if (isUsingProgramEntryPoint()) {
return new JobWithJars(getPlan(), getAllLibraries(), classpaths, userCodeClassLoader);
[6]
private Plan getPlan() throws ProgramInvocationException {
if (this.plan == null) {
Thread.currentThread().setContextClassLoader(this.userCodeClassLoader);
this.plan = createPlanFromProgram(this.program, this.args);
}
return this.plan;
}
-----Original Message-----
From: "Ufuk Celebi"<uce@apache.org>
To: <user@flink.apache.org>; "윤형덕"<ynoohe1@naver.com>;
Cc:
Sent: 2016-05-20 (금) 19:30:01
Subject: Re: inheritance of Program interface in Program.java in org.apache.flink.api.common
On Thu, May 19, 2016 at 4:46 PM, 윤형덕 <ynoohe1@naver.com> wrote:
>
> how can this.mainClass that doesn't override getPlan method that is abstract method of Program interface(program.class) and has only static main method be instantiate as Program?
This is only called if the class is actually a subclass of Program. That's why there is the `isAssignable` check. Otherwise, we check that there is a mainMethod (else if (hasMainMethod(mainClass)). If this is not the case, a ProgramInvocationException is thrown.
Re: inheritance of Program interface in Program.java in org.apache.flink.api.common
Posted by Ufuk Celebi <uc...@apache.org>.
On Thu, May 19, 2016 at 4:46 PM, 윤형덕 <yn...@naver.com> wrote:
>
> how can this.mainClass that doesn't override getPlan method that is
abstract method of Program interface(program.class) and has only static
main method be instantiate as Program?
This is only called if the class is actually a subclass of Program. That's
why there is the `isAssignable` check. Otherwise, we check that there is a
mainMethod (else if (hasMainMethod(mainClass)). If this is not the case, a
ProgramInvocationException is thrown.