@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 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 void run() { try { File startedFile = new File(getContext().getApplicationArguments()[0], STARTED_FILE); // CompleteRunnable#run() method should be called after EventHandler#started() method is called if (startedFile.exists()) { new File(startedFile.getParent(), RUN_FILE).createNewFile(); } } catch (IOException e) { throw Throwables.propagate(e); } } }
CommandLine cmdLine = parseArgs(context.getApplicationArguments());
@Override public void initialize(TwillContext context) { super.initialize(context); running = true; try { serverSocket = new ServerSocket(0); LOG.info("Server started: " + serverSocket.getLocalSocketAddress() + ", id: " + context.getInstanceId() + ", count: " + context.getInstanceCount()); // Announce with service names as specified in app arguments and runnable arguments final List<Cancellable> cancellables = new ArrayList<>(); for (String[] args : new String[][] {context.getApplicationArguments(), context.getArguments()}) { if (args.length > 0) { cancellables.add(context.announce(args[0], serverSocket.getLocalPort())); } } canceller = new Cancellable() { @Override public void cancel() { for (Cancellable c : cancellables) { c.cancel(); } } }; } catch (IOException e) { throw Throwables.propagate(e); } }
@Override public void run() { final BlockingQueue<Discoverable> discoverables = new LinkedBlockingQueue<>(); ServiceDiscovered serviceDiscovered = getContext().discover(getContext().getApplicationArguments()[0]); serviceDiscovered.watchChanges(new ServiceDiscovered.ChangeListener() { @Override