Repository: reef Updated Branches: refs/heads/master 8be582f5f -> 9e299c564
[REEF-1700] Refactor HelloREEF example on YARN Update the code to the latest API and remove all historical crumbs JIRA: [REEF-1700](https://issues.apache.org/jira/browse/REEF-1700) Closes #1216 Project: http://git-wip-us.apache.org/repos/asf/reef/repo Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/9e299c56 Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/9e299c56 Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/9e299c56 Branch: refs/heads/master Commit: 9e299c564e6197b34016ceba0faf52a5072c017d Parents: 8be582f Author: Sergiy Matusevych <[email protected]> Authored: Wed Jan 11 18:05:39 2017 -0800 Committer: Yunseong Lee <[email protected]> Committed: Thu Jan 12 22:27:56 2017 +0900 ---------------------------------------------------------------------- .../reef/examples/hello/HelloREEFYarn.java | 42 ++++++-------------- 1 file changed, 13 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/reef/blob/9e299c56/lang/java/reef-examples/src/main/java/org/apache/reef/examples/hello/HelloREEFYarn.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-examples/src/main/java/org/apache/reef/examples/hello/HelloREEFYarn.java b/lang/java/reef-examples/src/main/java/org/apache/reef/examples/hello/HelloREEFYarn.java index 3817e4a..b4fc82e 100644 --- a/lang/java/reef-examples/src/main/java/org/apache/reef/examples/hello/HelloREEFYarn.java +++ b/lang/java/reef-examples/src/main/java/org/apache/reef/examples/hello/HelloREEFYarn.java @@ -23,8 +23,8 @@ import org.apache.reef.client.DriverLauncher; import org.apache.reef.client.LauncherStatus; import org.apache.reef.runtime.yarn.client.YarnClientConfiguration; import org.apache.reef.tang.Configuration; -import org.apache.reef.tang.exceptions.BindException; import org.apache.reef.tang.exceptions.InjectionException; +import org.apache.reef.util.EnvironmentUtils; import java.util.logging.Level; import java.util.logging.Logger; @@ -43,40 +43,24 @@ public final class HelloREEFYarn { */ private static final int JOB_TIMEOUT = 100000; // 100 sec. - /** - * @return the configuration of the runtime - */ - private static Configuration getRuntimeConfiguration() { - return YarnClientConfiguration.CONF.build(); - } + /** The configuration of the runtime. */ + private static final Configuration RUNTIME_CONF = YarnClientConfiguration.CONF.build(); - /** - * @return the configuration of the HelloREEF driver. - */ - private static Configuration getDriverConfiguration() { - return DriverConfiguration.CONF - .set(DriverConfiguration.GLOBAL_LIBRARIES, - HelloREEFYarn.class.getProtectionDomain().getCodeSource().getLocation().getFile()) - .set(DriverConfiguration.DRIVER_IDENTIFIER, "HelloREEF") - .set(DriverConfiguration.ON_DRIVER_STARTED, HelloDriver.StartHandler.class) - .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, HelloDriver.EvaluatorAllocatedHandler.class) - .build(); - } + /** The configuration of the HelloREEF driver. */ + private static final Configuration DRIVER_CONF = DriverConfiguration.CONF + .set(DriverConfiguration.DRIVER_IDENTIFIER, "HelloREEF") + .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(HelloREEFYarn.class)) + .set(DriverConfiguration.ON_DRIVER_STARTED, HelloDriver.StartHandler.class) + .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, HelloDriver.EvaluatorAllocatedHandler.class) + .build(); /** * Start Hello REEF job. - * - * @param args command line parameters. - * @throws BindException configuration error. + * @param args command line parameters. Not used. * @throws InjectionException configuration error. */ - public static void main(final String[] args) throws BindException, InjectionException { - final Configuration runtimeConf = getRuntimeConfiguration(); - final Configuration driverConf = getDriverConfiguration(); - - final LauncherStatus status = DriverLauncher - .getLauncher(runtimeConf) - .run(driverConf, JOB_TIMEOUT); + public static void main(final String[] args) throws InjectionException { + final LauncherStatus status = DriverLauncher.getLauncher(RUNTIME_CONF).run(DRIVER_CONF, JOB_TIMEOUT); LOG.log(Level.INFO, "REEF job completed: {0}", status); }
