/** * Parse command line arguments and create TANG configuration ready to be submitted to REEF. * * @param args Command line arguments, as passed into main(). * @return (immutable) TANG Configuration object. * @throws BindException if configuration commandLineInjector fails. * @throws InjectionException if configuration commandLineInjector fails. * @throws IOException error reading the configuration. */ private static Configuration getClientConfiguration(final String[] args) throws BindException, InjectionException, IOException { final Configuration commandLineConf = parseCommandLine(args); final Configuration clientConfiguration = ClientConfiguration.CONF .set(ClientConfiguration.ON_JOB_RUNNING, SuspendClient.RunningJobHandler.class) .set(ClientConfiguration.ON_JOB_FAILED, SuspendClient.FailedJobHandler.class) .set(ClientConfiguration.ON_JOB_COMPLETED, SuspendClient.CompletedJobHandler.class) .set(ClientConfiguration.ON_RUNTIME_ERROR, SuspendClient.RuntimeErrorHandler.class) .build(); final Injector commandLineInjector = Tang.Factory.getTang().newInjector(commandLineConf); final boolean isLocal = commandLineInjector.getNamedInstance(Local.class); final Configuration runtimeConfiguration; if (isLocal) { LOG.log(Level.INFO, "Running on the local runtime"); runtimeConfiguration = LocalRuntimeConfiguration.CONF .set(LocalRuntimeConfiguration.MAX_NUMBER_OF_EVALUATORS, MAX_NUMBER_OF_EVALUATORS) .build(); } else { LOG.log(Level.INFO, "Running on YARN"); runtimeConfiguration = YarnClientConfiguration.CONF.build(); } return Configurations.merge( runtimeConfiguration, clientConfiguration, cloneCommandLineConfiguration(commandLineConf)); }
/** @return the configuration of the runtime */ private static Configuration getRuntimeConfiguration() { return LocalRuntimeConfiguration.CONF .set(LocalRuntimeConfiguration.MAX_NUMBER_OF_EVALUATORS, MAX_NUMBER_OF_EVALUATORS) .build(); }