@Override public TwillPreparer setJVMOptions(String runnableName, String options) { getDelegate().setJVMOptions(runnableName, options); return this; }
@Override public TwillPreparer setJVMOptions(String options) { getDelegate().setJVMOptions(options); return this; }
@Override public TwillPreparer setJVMOptions(String options) { getDelegate().setJVMOptions(options); return this; }
@Override public TwillPreparer setJVMOptions(String runnableName, String options) { getDelegate().setJVMOptions(runnableName, options); return this; }
/** * Sets the configurations for each service. */ private TwillPreparer prepareServiceConfig(TwillPreparer preparer, Map<String, String> runnableConfigPrefixes) { for (Map.Entry<String, String> entry : runnableConfigPrefixes.entrySet()) { String runnableName = entry.getKey(); String configPrefix = entry.getValue() + "twill."; Map<String, String> config = new HashMap<>(); for (Map.Entry<String, String> confEntry : cConf) { if (confEntry.getKey().startsWith(configPrefix)) { // Get the key that twill recognize, which is prefixed with "twill." String key = confEntry.getKey().substring(entry.getValue().length()); // Special case for jvm options. if ("twill.jvm.opts".equals(key)) { preparer.setJVMOptions(runnableName, confEntry.getValue()); } else { config.put(key, confEntry.getValue()); } } } if (!config.isEmpty()) { preparer.withConfiguration(runnableName, config); } } return preparer; }
@Test public void testCustomClassLoader() throws Exception { TwillController controller = getTwillRunner().prepare(new CustomClassLoaderRunnable()) .setClassLoader(CustomClassLoader.class.getName()) .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true))) .setJVMOptions("-Dservice.port=54321") .setJVMOptions(CustomClassLoaderRunnable.class.getSimpleName(), "-Dservice.name=custom") .start(); Assert.assertTrue(waitForSize(controller.discoverService("custom"), 1, 120)); controller.terminate().get(); } }
@Test public void testExtraOptions() throws InterruptedException, ExecutionException { // Start the testing app with jvm options at both global level as well as for the specific runnables. TwillController controller = getTwillRunner() .prepare(new JvmOptionsApplication()) .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out))) .setJVMOptions("-Dservice.name=default") .setJVMOptions("r2", "-Dservice.name=r2") .start(); // For r1 and r3 will be using "default" as the service name. waitForSize(controller.discoverService("default"), 2, 120); // r2 will be use "r2" as the service name. waitForSize(controller.discoverService("r2"), 1, 120); controller.terminate().get(); }