<workflow-app name="read Crossref dump from HDFS" xmlns="uri:oozie:workflow:0.5">
    <parameters>
<!--        <property>-->
<!--            <name>workingPath</name>-->
<!--            <description>the working dir base path</description>-->
<!--        </property>-->
        <property>
            <name>sparkDriverMemory</name>
            <description>memory for driver process</description>
        </property>
        <property>
            <name>sparkExecutorMemory</name>
            <description>memory for individual executor</description>
        </property>
        <property>
            <name>sparkExecutorCores</name>
            <description>number of cores used by single executor</description>
        </property>

    </parameters>

    <start to="ReadCrossRefDump"/>

    <kill name="Kill">
        <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>

    <action name="ReadCrossRefDump">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.crossref.ExtractCrossrefRecords</main-class>
            <arg>--hdfsServerUri</arg><arg>${nameNode}</arg>
            <arg>--workingPath</arg><arg>/data/doiboost/crossref/</arg>
            <arg>--crossrefFileNameTarGz</arg><arg>crossref.tar.gz</arg>
        </java>
        <ok to="End"/>
        <error to="Kill"/>
    </action>

    <action name="SparkReadCrossRefDump">
        <spark xmlns="uri:oozie:spark-action:0.2">
            <master>yarn-cluster</master>
            <mode>cluster</mode>
            <name>SparkReadCrossRefDump</name>
            <class>eu.dnetlib.doiboost.crossref.ExtractCrossrefRecords</class>
            <jar>dhp-doiboost-${projectVersion}.jar</jar>
            <spark-opts>
                --conf spark.dynamicAllocation.enabled=true
                --conf spark.dynamicAllocation.maxExecutors=20
                --executor-memory=6G
                --driver-memory=7G
                --conf spark.extraListeners=${spark2ExtraListeners}
                --conf spark.yarn.historyServer.address=${spark2YarnHistoryServerAddress}
                --conf spark.eventLog.dir=${nameNode}${spark2EventLogDir}
                --conf spark.sql.queryExecutionListeners=${spark2SqlQueryExecutionListeners}
            </spark-opts>
            <arg>--hdfsServerUri</arg><arg>${nameNode}</arg>
            <arg>--workingPath</arg><arg>/data/doiboost/crossref/</arg>
            <arg>--crossrefFileNameTarGz</arg><arg>crossref.tar.gz</arg>

        </spark>
        <ok to="End"/>
        <error to="Kill"/>
    </action>

    <end name="End"/>
</workflow-app>