[ 
https://issues.apache.org/jira/browse/FLINK-9800?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17283592#comment-17283592
 ] 

Chesnay Schepler commented on FLINK-9800:
-----------------------------------------

A workaround could be to encode additional information into the jar manifest 
and write them into the GlobaJobParameters of a job. They could then be 
accessed through the WebUI (on the Configuration page of the job).
This could include various revision-like data, like commit hashes. Ideally this 
information is also present in the jar to be able to correlate them.

I would try to go with this approach because it will work independently of how 
whether you submit jobs through the client or REST API.

Example for parsing something from the Manifest:
{code}
...
import com.jcabi.manifests.Manifests;
...

    public static runJob() {
        ...
env.getConfig().setGlobalJobParameters(createMetaData());
        ...
    }

    public static ExecutionConfig.GlobalJobParameters createMetaData() {
        Map<String, String> metaData = new HashMap<>();
        setFromManifest(metaData, "Commit-ID");
        setFromManifest(metaData, "Commit-Message");
        setFromManifest(metaData, "Commit-Time");

        return new MetaData(metaData);
    }


    private static void setFromManifest(Map<String, String> metaData, String 
property) {
        metaData.put(property, guard(() -> Manifests.read(property)));
    }

    private static String guard(Supplier<String> supplier) {
        try {
            return supplier.get();
        } catch (IllegalArgumentException iae) {
            return "unknown";
        }
    }

    private static class MetaData extends ExecutionConfig.GlobalJobParameters {
        private final Map<String, String> data;

        private MetaData(Map<String, String> data) {
            this.data = data;
        }

        @Override
        public Map<String, String> toMap() {
            return data;
        }
    }
{code}

Maven example for setting manifest:
{code}
<plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                        <configuration>
                            
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Commit-ID>${git.commit.id}</Commit-ID>
                            
<Commit-Message>${git.commit.message.short}</Commit-Message>
                            <Commit-Time>${git.commit.time}</Commit-Time>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
{code}

> Return the relation between a running job and the original jar in REST API
> --------------------------------------------------------------------------
>
>                 Key: FLINK-9800
>                 URL: https://issues.apache.org/jira/browse/FLINK-9800
>             Project: Flink
>          Issue Type: Improvement
>          Components: Runtime / REST
>            Reporter:  Lasse Nedergaard
>            Priority: Minor
>
> Extend the REST endpoint /jobs to include the jarid used to start the job.
> With this information it would be possible to find the original jar and 
> thereby information about the source for the job.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to