protected List<String> getAssignedTasks(Worker worker) throws Exception { final List<String> assignedTasks = Lists.newArrayList( cf.getChildren().forPath(JOINER.join(indexerZkConfig.getTasksPath(), worker.getHost())) ); for (Map.Entry<String, RemoteTaskRunnerWorkItem> entry : runningTasks.entrySet()) { if (entry.getValue() == null) { log.error( "Huh? null work item for [%s]", entry.getKey() ); } else if (entry.getValue().getWorker() == null) { log.error("Huh? no worker for [%s]", entry.getKey()); } else if (entry.getValue().getWorker().getHost().equalsIgnoreCase(worker.getHost())) { log.info("[%s]: Found [%s] running", worker.getHost(), entry.getKey()); assignedTasks.add(entry.getKey()); } } log.info("[%s]: Found %d tasks assigned", worker.getHost(), assignedTasks.size()); return assignedTasks; }
@Inject public WorkerCuratorCoordinator( ObjectMapper jsonMapper, IndexerZkConfig indexerZkConfig, RemoteTaskRunnerConfig config, CuratorFramework curatorFramework, Worker worker ) { this.jsonMapper = jsonMapper; this.config = config; this.curatorFramework = curatorFramework; this.worker = worker; this.announcer = new Announcer(curatorFramework, Execs.directExecutor()); this.baseAnnouncementsPath = getPath(Arrays.asList(indexerZkConfig.getAnnouncementsPath(), worker.getHost())); this.baseTaskPath = getPath(Arrays.asList(indexerZkConfig.getTasksPath(), worker.getHost())); this.baseStatusPath = getPath(Arrays.asList(indexerZkConfig.getStatusPath(), worker.getHost())); }
@Test public void testNullConfig() { propertyValues.clear(); final Injector injector = Initialization.makeInjectorWithModules( GuiceInjectors.makeStartupInjector(), ImmutableList.of(simpleZkConfigModule) ); JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get(); JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of(zkServiceConfigString, ZkPathsConfig.class); zkPathsConfig.inject(propertyValues, configurator); JsonConfigProvider<IndexerZkConfig> indexerZkConfig = JsonConfigProvider.of( indexerPropertyString, IndexerZkConfig.class ); indexerZkConfig.inject(propertyValues, configurator); Assert.assertEquals("/druid/indexer/tasks", indexerZkConfig.get().get().getTasksPath()); }
JOINER.join(indexerZkConfig.getTasksPath(), worker, task.getId()), CreateMode.EPHEMERAL, jsonMapper.writeValueAsBytes(task),
protected List<String> getAssignedTasks(Worker worker) throws Exception { final List<String> assignedTasks = Lists.newArrayList( cf.getChildren().forPath(JOINER.join(indexerZkConfig.getTasksPath(), worker.getHost())) ); for (Map.Entry<String, RemoteTaskRunnerWorkItem> entry : runningTasks.entrySet()) { if (entry.getValue() == null) { log.error( "Huh? null work item for [%s]", entry.getKey() ); } else if (entry.getValue().getWorker() == null) { log.error("Huh? no worker for [%s]", entry.getKey()); } else if (entry.getValue().getWorker().getHost().equalsIgnoreCase(worker.getHost())) { log.info("[%s]: Found [%s] running", worker.getHost(), entry.getKey()); assignedTasks.add(entry.getKey()); } } log.info("[%s]: Found %d tasks assigned", worker.getHost(), assignedTasks.size()); return assignedTasks; }
@Inject public WorkerCuratorCoordinator( ObjectMapper jsonMapper, IndexerZkConfig indexerZkConfig, RemoteTaskRunnerConfig config, CuratorFramework curatorFramework, Worker worker ) { this.jsonMapper = jsonMapper; this.config = config; this.curatorFramework = curatorFramework; this.worker = worker; this.announcer = new Announcer(curatorFramework, MoreExecutors.sameThreadExecutor()); this.baseAnnouncementsPath = getPath(Arrays.asList(indexerZkConfig.getAnnouncementsPath(), worker.getHost())); this.baseTaskPath = getPath(Arrays.asList(indexerZkConfig.getTasksPath(), worker.getHost())); this.baseStatusPath = getPath(Arrays.asList(indexerZkConfig.getStatusPath(), worker.getHost())); }
JOINER.join(indexerZkConfig.getTasksPath(), worker, task.getId()), CreateMode.EPHEMERAL, jsonMapper.writeValueAsBytes(task),