Search in sources :

Example 1 with ZKClient

use of com.continuuity.weave.zookeeper.ZKClient in project weave by continuuity.

the class YarnWeaveRunnerService method prepare.

@Override
public WeavePreparer prepare(WeaveApplication application) {
    Preconditions.checkState(isRunning(), "Service not start. Please call start() first.");
    final WeaveSpecification weaveSpec = application.configure();
    final String appName = weaveSpec.getName();
    return new YarnWeavePreparer(yarnConfig, weaveSpec, yarnAppClient, zkClientService, locationFactory, Suppliers.ofInstance(jvmOptions), new YarnWeaveControllerFactory() {

        @Override
        public YarnWeaveController create(RunId runId, Iterable<LogHandler> logHandlers, Callable<ProcessController<YarnApplicationReport>> startUp) {
            ZKClient zkClient = ZKClients.namespace(zkClientService, "/" + appName);
            YarnWeaveController controller = listenController(new YarnWeaveController(runId, zkClient, logHandlers, startUp));
            synchronized (YarnWeaveRunnerService.this) {
                Preconditions.checkArgument(!controllers.contains(appName, runId), "Application %s with runId %s is already running.", appName, runId);
                controllers.put(appName, runId, controller);
            }
            return controller;
        }
    });
}
Also used : LogHandler(com.continuuity.weave.api.logging.LogHandler) ProcessController(com.continuuity.weave.internal.ProcessController) ZKClient(com.continuuity.weave.zookeeper.ZKClient) WeaveSpecification(com.continuuity.weave.api.WeaveSpecification) RunId(com.continuuity.weave.api.RunId)

Aggregations

RunId (com.continuuity.weave.api.RunId)1 WeaveSpecification (com.continuuity.weave.api.WeaveSpecification)1 LogHandler (com.continuuity.weave.api.logging.LogHandler)1 ProcessController (com.continuuity.weave.internal.ProcessController)1 ZKClient (com.continuuity.weave.zookeeper.ZKClient)1