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 void initialize(TwillContext context) { this.context = context; this.args = context.getSpecification().getConfigs(); }
@SuppressWarnings("unchecked") @Override protected void doStart() throws Exception { for (Map.Entry<String, String> entry : containerLiveNodeData.getLogLevels().entrySet()) { String loggerName = entry.getKey(); String oldLogLevel = setLogLevel(loggerName, entry.getValue()); if (!defaultLogLevels.containsKey(loggerName)) { oldLogLevels.put(loggerName, oldLogLevel); } } commandExecutor = Executors.newSingleThreadExecutor( Threads.createDaemonThreadFactory("runnable-command-executor")); Class<?> runnableClass = classLoader.loadClass(specification.getClassName()); Preconditions.checkArgument(TwillRunnable.class.isAssignableFrom(runnableClass), "Class %s is not instance of TwillRunnable.", specification.getClassName()); runnable = Instances.newInstance((Class<TwillRunnable>) runnableClass); runnable.initialize(context); }
@Override public void initialize(TwillContext context) { this.context = context; this.args = context.getSpecification().getConfigs(); }
@SuppressWarnings("unchecked") @Override protected void doStart() throws Exception { for (Map.Entry<String, String> entry : containerLiveNodeData.getLogLevels().entrySet()) { String loggerName = entry.getKey(); String oldLogLevel = setLogLevel(loggerName, entry.getValue()); if (!defaultLogLevels.containsKey(loggerName)) { oldLogLevels.put(loggerName, oldLogLevel); } } commandExecutor = Executors.newSingleThreadExecutor( Threads.createDaemonThreadFactory("runnable-command-executor")); Class<?> runnableClass = classLoader.loadClass(specification.getClassName()); Preconditions.checkArgument(TwillRunnable.class.isAssignableFrom(runnableClass), "Class %s is not instance of TwillRunnable.", specification.getClassName()); runnable = Instances.newInstance((Class<TwillRunnable>) runnableClass); runnable.initialize(context); }
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 final void initialize(TwillContext context) { this.context = context; if (name == null) { name = context.getSpecification().getName(); } LOG.info("Initializing runnable: " + name); try { doInitialize(new File(context.getApplicationArguments()[0])); LOG.info("Runnable initialized: {}", name); } catch (Throwable t) { LOG.error(t.getMessage(), t); throw Throwables.propagate(t); } }
@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; } }); }
getJvmOptions().getRunnableExtraOptions(runnableName), RemoteLauncher.class.getName(), runtimeSpec.getRunnableSpecification().getClassName(), logsDir, logsDir);
@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) { this.context = context; if (name == null) { name = context.getSpecification().getName(); } LOG.info("Initializing runnable: " + name); try { doInitialize(new File(context.getApplicationArguments()[0])); LOG.info("Runnable initialized: {}", name); } catch (Throwable t) { LOG.error(t.getMessage(), t); throw Throwables.propagate(t); } }
@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; } }); }
getJvmOptions().getRunnableExtraOptions(runnableName), RemoteLauncher.class.getName(), runtimeSpec.getRunnableSpecification().getClassName(), logsDir, logsDir);
@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 RuntimeSpecificationAdder add(TwillRunnable runnable, ResourceSpecification resourceSpec) { return add(runnable.configure().getName(), runnable, resourceSpec); }
Map<String, String> configs = handlerSpec.getRunnableSpecification().getConfigs();