public DefaultTwillRunnableSpecification(String className, TwillRunnableSpecification other) { this.className = className; this.name = other.getName(); this.arguments = Collections.unmodifiableMap(new HashMap<String, String>(other.getConfigs())); }
@Override public void initialize(TwillContext context) { this.context = context; this.args = context.getSpecification().getConfigs(); }
@Override public void initialize(TwillContext context) { this.context = context; this.args = context.getSpecification().getConfigs(); }
public DefaultTwillRunnableSpecification(String className, TwillRunnableSpecification other) { this.className = className; this.name = other.getName(); this.arguments = Collections.unmodifiableMap(new HashMap<String, String>(other.getConfigs())); }
@Override public JsonElement serialize(TwillRunnableSpecification src, Type typeOfSrc, JsonSerializationContext context) { JsonObject json = new JsonObject(); json.addProperty("classname", src.getClassName()); json.addProperty("name", src.getName()); json.add("arguments", context.serialize(src.getConfigs(), new TypeToken<Map<String, String>>() { }.getType())); return json; }
@Override public JsonElement serialize(TwillRunnableSpecification src, Type typeOfSrc, JsonSerializationContext context) { JsonObject json = new JsonObject(); json.addProperty("classname", src.getClassName()); json.addProperty("name", src.getName()); json.add("arguments", context.serialize(src.getConfigs(), new TypeToken<Map<String, String>>() { }.getType())); return json; }
@Override public RuntimeSpecificationAdder add(String name, TwillRunnable runnable, final ResourceSpecification resourceSpec) { final TwillRunnableSpecification spec = new DefaultTwillRunnableSpecification( runnable.getClass().getName(), name, runnable.configure().getConfigs()); return new RuntimeSpecificationAdder(new LocalFileCompleter() { @Override public RunnableSetter complete(Collection<LocalFile> files) { runnables.put(spec.getName(), new DefaultRuntimeSpecification(spec.getName(), spec, resourceSpec, files)); return RunnableSetter.this; } }); }
@Override public RuntimeSpecificationAdder add(String name, TwillRunnable runnable, final ResourceSpecification resourceSpec) { final TwillRunnableSpecification spec = new DefaultTwillRunnableSpecification( runnable.getClass().getName(), name, runnable.configure().getConfigs()); return new RuntimeSpecificationAdder(new LocalFileCompleter() { @Override public RunnableSetter complete(Collection<LocalFile> files) { runnables.put(spec.getName(), new DefaultRuntimeSpecification(spec.getName(), spec, resourceSpec, files)); return RunnableSetter.this; } }); }
@Override public final void initialize(TwillContext context) { Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()); super.initialize(context); name = context.getSpecification().getName(); LOG.info("Initializing runnable {}", name); Map<String, String> configs = context.getSpecification().getConfigs(); try { // Load configuration hConf = new Configuration(); hConf.clear(); hConf.addResource(new File(configs.get("hConf")).toURI().toURL()); UserGroupInformation.setConfiguration(hConf); cConf = CConfiguration.create(new File(configs.get("cConf"))); LOG.debug("{} cConf {}", name, cConf); LOG.debug("{} HBase conf {}", name, hConf); Injector injector = doInit(context); services = Lists.newArrayList(); // Add common base services services.add(injector.getInstance(ZKClientService.class)); services.add(injector.getInstance(KafkaClientService.class)); services.add(injector.getInstance(BrokerService.class)); services.add(injector.getInstance(MetricsCollectionService.class)); addServices(services); Preconditions.checkArgument(!services.isEmpty(), "Should have at least one service"); LOG.info("Runnable initialized {}", name); } catch (Throwable t) { throw Throwables.propagate(t); } }
@Override public final void initialize(TwillContext context) { Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()); super.initialize(context); name = context.getSpecification().getName(); LOG.info("Initializing runnable {}", name); Map<String, String> configs = context.getSpecification().getConfigs(); try { // Load configuration hConf = new Configuration(); hConf.clear(); hConf.addResource(new File(configs.get("hConf")).toURI().toURL()); UserGroupInformation.setConfiguration(hConf); cConf = CConfiguration.create(new File(configs.get("cConf"))); LOG.debug("{} cConf {}", name, cConf); LOG.debug("{} HBase conf {}", name, hConf); Injector injector = doInit(context); services = Lists.newArrayList(); // Add common base services services.add(injector.getInstance(ZKClientService.class)); services.add(injector.getInstance(KafkaClientService.class)); services.add(injector.getInstance(BrokerService.class)); services.add(injector.getInstance(MetricsCollectionService.class)); addServices(services); Preconditions.checkArgument(!services.isEmpty(), "Should have at least one service"); LOG.info("Runnable initialized {}", name); } catch (Throwable t) { throw Throwables.propagate(t); } }
@Override public final void initialize(TwillContext context) { super.initialize(context); name = context.getSpecification().getName(); Map<String, String> configs = context.getSpecification().getConfigs(); try { // Load configuration hConf = new Configuration(); hConf.clear(); hConf.addResource(new File(configs.get("hConf")).toURI().toURL()); UserGroupInformation.setConfiguration(hConf); cConf = CConfiguration.create(); cConf.clear(); cConf.addResource(new File(configs.get("cConf")).toURI().toURL()); LOG.debug("{} cConf {}", name, cConf); LOG.debug("{} HBase conf {}", name, hConf); doInit(context); services = Lists.newArrayList(); getServices(services); Preconditions.checkArgument(!services.isEmpty(), "Should have at least one service"); } catch (Throwable t) { throw Throwables.propagate(t); } }
runlatch = new CountDownLatch(1); name = context.getSpecification().getName(); Map<String, String> configs = context.getSpecification().getConfigs();
Map<String, String> configs = handlerSpec.getRunnableSpecification().getConfigs();
Map<String, String> configs = handlerSpec.getRunnableSpecification().getConfigs();
@Override public void run() { try { createFile(getContext().getSpecification().getConfigs().get(PARENT_FOLDER), getContext().getSpecification().getConfigs().get("runFile")); LOG.info("runFile created"); stopLatch.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
@Override public void run() { runThread = Thread.currentThread(); getContext().announce("sleep", Integer.parseInt(getContext().getSpecification().getConfigs().get("port"))); try { TimeUnit.SECONDS.sleep(120); } catch (InterruptedException e) { // Ignore. } }
@Override public void run() { // This heap size should be > 16, since the min allocation size is 128mb if (Runtime.getRuntime().maxMemory() <= 16 * 1024 * 1024) { LOG.error("Memory size is too small: {}", Runtime.getRuntime().maxMemory()); return; } runThread = Thread.currentThread(); getContext().announce("sleep", Integer.parseInt(getContext().getSpecification().getConfigs().get("port"))); try { TimeUnit.SECONDS.sleep(120); } catch (InterruptedException e) { // Ignore. } }