/** * Starts the application master. */ public static void main(String[] args) throws Exception { File twillSpec = new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.TWILL_SPEC); TwillRuntimeSpecification twillRuntimeSpec = TwillRuntimeSpecificationAdapter.create().fromJson(twillSpec); new ApplicationMasterMain(twillRuntimeSpec).doMain(); }
public void toJson(TwillRuntimeSpecification spec, File file) throws IOException { try (Writer writer = Files.newWriter(file, Charsets.UTF_8)) { toJson(spec, writer); } }
public static TwillRuntimeSpecificationAdapter create() { return new TwillRuntimeSpecificationAdapter(); }
public TwillRuntimeSpecification fromJson(File file) throws IOException { try (Reader reader = Files.newReader(file, Charsets.UTF_8)) { return fromJson(reader); } }
public ServiceSpecificationCodec() { twillSpecificationAdapter = TwillRuntimeSpecificationAdapter.create(); }
public TwillRuntimeSpecification fromJson(File file) throws IOException { try (Reader reader = Files.newReader(file, Charsets.UTF_8)) { return fromJson(reader); } }
public ServiceSpecificationCodec() { twillSpecificationAdapter = TwillRuntimeSpecificationAdapter.create(); }
@Override protected void doStart() throws Exception { LOG.info("Start application master with spec: {}", TwillRuntimeSpecificationAdapter.create().toJson(twillRuntimeSpec)); // initialize the event handler, if it fails, it will fail the application. eventHandler.initialize(new BasicEventHandlerContext(twillRuntimeSpec)); // call event handler started. eventHandler.started(); instanceChangeExecutor = Executors.newSingleThreadExecutor(Threads.createDaemonThreadFactory("instanceChanger")); // Creates ZK path for runnable. It's ok if the path already exists. // That's for the case when the AM get killed and restarted ZKOperations.ignoreError( zkClient.create("/" + runId.getId() + "/runnables", null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, null) .get(); runningContainers.addWatcher(Constants.DISCOVERY_PATH_PREFIX); runnableContainerRequests = initContainerRequests(); }
/** * Main method for launching a {@link TwillContainerService} which runs * a {@link org.apache.twill.api.TwillRunnable}. */ public static void main(String[] args) throws Exception { File twillSpecFile = new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.TWILL_SPEC); TwillRuntimeSpecification twillRuntimeSpec = TwillRuntimeSpecificationAdapter.create().fromJson(twillSpecFile); new TwillContainerMain(twillRuntimeSpec).doMain(); }
private ServiceSpecification decodeOldSpec(JsonObject json) { String className = json.get("classname").getAsString(); TwillSpecification twillSpec = twillSpecificationAdapter.fromJson(json.get("spec").getAsString()).getTwillSpecification(); Map<String, HttpServiceHandlerSpecification> handlers = Maps.newHashMap();
public void toJson(TwillRuntimeSpecification spec, File file) throws IOException { try (Writer writer = Files.newWriter(file, Charsets.UTF_8)) { toJson(spec, writer); } }
public static TwillRuntimeSpecificationAdapter create() { return new TwillRuntimeSpecificationAdapter(); }
/** * Starts the application master. */ public static void main(String[] args) throws Exception { File twillSpec = new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.TWILL_SPEC); TwillRuntimeSpecification twillRuntimeSpec = TwillRuntimeSpecificationAdapter.create().fromJson(twillSpec); new ApplicationMasterMain(twillRuntimeSpec).doMain(); }
private ServiceSpecification decodeOldSpec(JsonObject json) { String className = json.get("classname").getAsString(); TwillSpecification twillSpec = twillSpecificationAdapter.fromJson(json.get("spec").getAsString()).getTwillSpecification(); Map<String, HttpServiceHandlerSpecification> handlers = Maps.newHashMap();
@Override protected void doStart() throws Exception { LOG.info("Start application master with spec: {}", TwillRuntimeSpecificationAdapter.create().toJson(twillRuntimeSpec)); // initialize the event handler, if it fails, it will fail the application. eventHandler.initialize(new BasicEventHandlerContext(twillRuntimeSpec)); // call event handler started. eventHandler.started(); instanceChangeExecutor = Executors.newSingleThreadExecutor(Threads.createDaemonThreadFactory("instanceChanger")); // Creates ZK path for runnable. It's ok if the path already exists. // That's for the case when the AM get killed and restarted ZKOperations.ignoreError( zkClient.create("/" + runId.getId() + "/runnables", null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, null) .get(); runningContainers.addWatcher(Constants.DISCOVERY_PATH_PREFIX); runnableContainerRequests = initContainerRequests(); }
/** * Main method for launching a {@link TwillContainerService} which runs * a {@link org.apache.twill.api.TwillRunnable}. */ public static void main(String[] args) throws Exception { File twillSpecFile = new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.TWILL_SPEC); TwillRuntimeSpecification twillRuntimeSpec = TwillRuntimeSpecificationAdapter.create().fromJson(twillSpecFile); new TwillContainerMain(twillRuntimeSpec).doMain(); }