@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())); }
final String workerAnnouncePath = JOINER.join(indexerZkConfig.getAnnouncementsPath(), workerId); final String workerStatusPath = JOINER.join(indexerZkConfig.getStatusPath(), workerId); if (!zkWorkers.containsKey(workerId) && cf.checkExists().forPath(workerAnnouncePath) == null) {
@Test public void testIndexerBaseOverride() { final String overrideValue = "/foo/bar/baz"; final String indexerPropertyKey = indexerPropertyString + ".base"; final String priorValue = System.getProperty(indexerPropertyKey); System.setProperty(indexerPropertyKey, overrideValue); // Set it here so that the binding picks it up final Injector injector = Initialization.makeInjectorWithModules( GuiceInjectors.makeStartupInjector(), ImmutableList.of(simpleZkConfigModule) ); propertyValues.clear(); propertyValues.setProperty(indexerPropertyKey, overrideValue); // Have to set it here as well annoyingly enough JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get(); JsonConfigProvider<IndexerZkConfig> indexerPathsConfig = JsonConfigProvider.of( indexerPropertyString, IndexerZkConfig.class ); indexerPathsConfig.inject(propertyValues, configurator); IndexerZkConfig indexerZkConfig = indexerPathsConfig.get().get(); // Rewind value before we potentially fail if (priorValue == null) { System.clearProperty(indexerPropertyKey); } else { System.setProperty(indexerPropertyKey, priorValue); } Assert.assertEquals(overrideValue, indexerZkConfig.getBase()); Assert.assertEquals(overrideValue + "/announcements", indexerZkConfig.getAnnouncementsPath()); }
this.indexerZkConfig = indexerZkConfig; this.cf = cf; this.workerPathCache = pathChildrenCacheFactory.build().make(cf, indexerZkConfig.getAnnouncementsPath()); this.workerStatusPathChildrenCacheExecutor = PathChildrenCacheFactory.Builder.createDefaultExecutor(); this.workerStatusPathChildrenCacheFactory = pathChildrenCacheFactory
@Test public void testExactConfig() { final Injector injector = Initialization.makeInjectorWithModules( GuiceInjectors.makeStartupInjector(), ImmutableList.of(simpleZkConfigModule) ); propertyValues.setProperty(zkServiceConfigString + ".base", "/druid/metrics"); JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get(); JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of( zkServiceConfigString, ZkPathsConfig.class ); zkPathsConfig.inject(propertyValues, configurator); ZkPathsConfig zkPathsConfig1 = zkPathsConfig.get().get(); IndexerZkConfig indexerZkConfig = new IndexerZkConfig(zkPathsConfig1, null, null, null, null); Assert.assertEquals("/druid/metrics/indexer", indexerZkConfig.getBase()); Assert.assertEquals("/druid/metrics/indexer/announcements", indexerZkConfig.getAnnouncementsPath()); }
@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())); }
final String workerAnnouncePath = JOINER.join(indexerZkConfig.getAnnouncementsPath(), workerId); final String workerStatusPath = JOINER.join(indexerZkConfig.getStatusPath(), workerId); if (!zkWorkers.containsKey(workerId) && cf.checkExists().forPath(workerAnnouncePath) == null) {
this.indexerZkConfig = indexerZkConfig; this.cf = cf; this.workerPathCache = pathChildrenCacheFactory.build().make(cf, indexerZkConfig.getAnnouncementsPath()); this.workerStatusPathChildrenCacheExecutor = PathChildrenCacheFactory.Builder.createDefaultExecutor(); this.workerStatusPathChildrenCacheFactory = pathChildrenCacheFactory