/** * Provider method for instantiating {@link org.apache.twill.yarn.YarnTwillRunnerService}. */ @Singleton @Provides private YarnTwillRunnerService provideYarnTwillRunnerService(CConfiguration configuration, YarnConfiguration yarnConfiguration, LocationFactory locationFactory) { String zkConnectStr = configuration.get(Constants.Zookeeper.QUORUM) + configuration.get(Constants.CFG_TWILL_ZK_NAMESPACE); // Copy the yarn config and set the max heap ratio. YarnConfiguration yarnConfig = new YarnConfiguration(yarnConfiguration); yarnConfig.set(Constants.CFG_TWILL_RESERVED_MEMORY_MB, configuration.get(Constants.CFG_TWILL_RESERVED_MEMORY_MB)); YarnTwillRunnerService runner = new YarnTwillRunnerService(yarnConfig, zkConnectStr, LocationFactories.namespace(locationFactory, "twill")); // Set JVM options based on configuration runner.setJVMOptions(configuration.get(Constants.Container.PROGRAM_JVM_OPTS)); return runner; } }
@Test public void testHelper() { LocationFactory factory = LocationFactories.namespace(locationFactoryCache.getUnchecked("helper"), "testhelper"); Location location = factory.create("test"); Assert.assertTrue(location.toURI().getPath().endsWith("testhelper/test")); location = factory.create(URI.create("test2")); Assert.assertTrue(location.toURI().getPath().endsWith("testhelper/test2")); }
@Override public TwillRunnerService get() { String zkConnectStr = cConf.get(Constants.Zookeeper.QUORUM) + cConf.get(Constants.CFG_TWILL_ZK_NAMESPACE); // Copy the yarn config and setup twill configs YarnConfiguration yarnConfig = new YarnConfiguration(yarnConf); // Always disable the location delegation update from twill, as we always do it from CDAP side yarnConfig.setBoolean(Configs.Keys.SECURE_STORE_UPDATE_LOCATION_ENABLED, false); YarnTwillRunnerService runner = new YarnTwillRunnerService(yarnConfig, zkConnectStr, LocationFactories.namespace(locationFactory, "twill")); // Set JVM options based on configuration String jvmOpts = cConf.get(Constants.AppFabric.PROGRAM_JVM_OPTS); runner.setJVMOptions(jvmOpts); return new ImpersonatedTwillRunnerService(yarnConf, runner, impersonator, secureStoreRenewer); } }
@Override public TwillRunnerService get() { String zkConnectStr = cConf.get(Constants.Zookeeper.QUORUM) + cConf.get(Constants.CFG_TWILL_ZK_NAMESPACE); // Copy the yarn config and setup twill configs YarnConfiguration yarnConfig = new YarnConfiguration(yarnConf); // Always disable the location delegation update from twill, as we always do it from CDAP side yarnConfig.setBoolean(Configs.Keys.SECURE_STORE_UPDATE_LOCATION_ENABLED, false); YarnTwillRunnerService runner = new YarnTwillRunnerService(yarnConfig, zkConnectStr, LocationFactories.namespace(locationFactory, "twill")); // Set JVM options based on configuration String jvmOpts = cConf.get(Constants.AppFabric.PROGRAM_JVM_OPTS); runner.setJVMOptions(jvmOpts); return new ImpersonatedTwillRunnerService(yarnConf, runner, impersonator, secureStoreRenewer); } }