private Optional<LeaderService> startService(final String name) { if (!isOwner(name)) { return Optional.absent(); } _log.info("Starting owned service {}: {}", _group, name); String zkLeaderPath = String.format("/leader/%s/%s", _group.toLowerCase(), name); String threadName = String.format("Leader-%s-%s", _group, name); String taskName = String.format("%s-%s", _group.toLowerCase(), name); LeaderService leaderService = new LeaderService(_curator, zkLeaderPath, _selfId, threadName, 1, TimeUnit.MINUTES, new Supplier<Service>() { @Override public Service get() { return _factory.create(name); } }); ServiceFailureListener.listenTo(leaderService, _metricRegistry); _dropwizardTask.register(taskName, leaderService); leaderService.start(); return Optional.of(leaderService); }
@Override public LeaderService get() { LeaderService service = new LeaderService( curator, "/leader/table-maintenance", self.toString(), "Leader-TableMaintenance-" + scope, 1, TimeUnit.MINUTES, maintenanceServiceFactory); ServiceFailureListener.listenTo(service, metricRegistry); dropwizardTask.register(scope.toLowerCase() + "-maintenance", service); return service; } };
private Optional<LeaderService> startService(final String name) { if (!isOwner(name)) { return Optional.absent(); } _log.info("Starting owned service {}: {}", _group, name); String zkLeaderPath = String.format("/leader/%s/%s", _group.toLowerCase(), name); String threadName = String.format("Leader-%s-%s", _group, name); String taskName = String.format("%s-%s", _group.toLowerCase(), name); LeaderService leaderService = new LeaderService(_curator, zkLeaderPath, _selfId, threadName, 1, TimeUnit.MINUTES, new Supplier<Service>() { @Override public Service get() { return _factory.create(name); } }); ServiceFailureListener.listenTo(leaderService, _metricRegistry); _dropwizardTask.register(taskName, leaderService); leaderService.start(); return Optional.of(leaderService); }
@Override public LeaderService get() { LeaderService service = new LeaderService( curator, "/leader/table-maintenance", self.toString(), "Leader-TableMaintenance-" + scope, 1, TimeUnit.MINUTES, maintenanceServiceFactory); ServiceFailureListener.listenTo(service, metricRegistry); dropwizardTask.register(scope.toLowerCase() + "-maintenance", service); return service; } };
PartitionLeader(int partition) { _partition = partition; String leaderPath = ZKPaths.makePath(_basePath, String.format(LEADER_PATH_PATTERN, partition)); _leaderService = new LeaderService(_curator, leaderPath, _instanceId, _serviceName, _reacquireDelay, _delayUnit, this::leadershipAcquired); _leaderService.addListener(new Service.Listener() { @Override public void running() { _startedFuture.set(null); } @Override public void terminated(Service.State from) { _terminatedFuture.set(null); } }, MoreExecutors.sameThreadExecutor()); }
PartitionLeader(int partition) { _partition = partition; String leaderPath = ZKPaths.makePath(_basePath, String.format(LEADER_PATH_PATTERN, partition)); _leaderService = new LeaderService(_curator, leaderPath, _instanceId, _serviceName, _reacquireDelay, _delayUnit, this::leadershipAcquired); _leaderService.addListener(new Service.Listener() { @Override public void running() { _startedFuture.set(null); } @Override public void terminated(Service.State from) { _terminatedFuture.set(null); } }, MoreExecutors.sameThreadExecutor()); }
String zkLeaderPath = "/leader/hints/" + clusterName; String threadName = "Leader-HintsPoller-" + clusterName; LeaderService leaderService = new LeaderService( curator, zkLeaderPath, serverId, threadName, 1, TimeUnit.MINUTES, new Supplier<Service>() {
String zkLeaderPath = "/leader/hints/" + clusterName; String threadName = "Leader-HintsPoller-" + clusterName; LeaderService leaderService = new LeaderService( curator, zkLeaderPath, serverId, threadName, 1, TimeUnit.MINUTES, new Supplier<Service>() {
@Inject CompactionControlMonitorManager(LifeCycleRegistry lifeCycle, @LocalCompactionControl CompactionControlSource compactionControlSource, @GlobalFullConsistencyZooKeeper CuratorFramework curator, @SelfHostAndPort HostAndPort self, Clock clock, LeaderServiceTask dropwizardTask, final MetricRegistry metricRegistry) { LeaderService leaderService = new LeaderService( curator, "/leader/compaction-control-monitor", self.toString(), "Leader-CompactionControlMonitor", 30, TimeUnit.MINUTES, () -> new CompactionControlMonitor(compactionControlSource, clock, metricRegistry) ); ServiceFailureListener.listenTo(leaderService, metricRegistry); dropwizardTask.register("stash-runtime-monitor", leaderService); lifeCycle.manage(new ManagedGuavaService(leaderService)); } }
@Inject SystemQueueMonitorManager(LifeCycleRegistry lifeCycle, final DatabusEventStore eventStore, final DataCenters dataCenters, @DatabusClusterInfo final Collection<ClusterInfo> clusterInfo, @DatabusZooKeeper CuratorFramework curator, @SelfHostAndPort HostAndPort self, @MasterFanoutPartitions int masterFanoutPartitions, @DataCenterFanoutPartitions int dataCenterFanoutPartitions, LeaderServiceTask dropwizardTask, final MetricRegistry metricRegistry) { LeaderService leaderService = new LeaderService( curator, "/leader/queue-monitor", self.toString(), "Leader-QueueMonitor", 1, TimeUnit.MINUTES, new Supplier<Service>() { @Override public Service get() { return new SystemQueueMonitor(eventStore, dataCenters, clusterInfo, masterFanoutPartitions, dataCenterFanoutPartitions, metricRegistry); } }); ServiceFailureListener.listenTo(leaderService, metricRegistry); dropwizardTask.register("queue-monitor", leaderService); lifeCycle.manage(new ManagedGuavaService(leaderService)); } }
@Inject SystemQueueMonitorManager(LifeCycleRegistry lifeCycle, final DatabusEventStore eventStore, final DataCenters dataCenters, @DatabusClusterInfo final Collection<ClusterInfo> clusterInfo, @DatabusZooKeeper CuratorFramework curator, @SelfHostAndPort HostAndPort self, @MasterFanoutPartitions int masterFanoutPartitions, @DataCenterFanoutPartitions int dataCenterFanoutPartitions, LeaderServiceTask dropwizardTask, final MetricRegistry metricRegistry) { LeaderService leaderService = new LeaderService( curator, "/leader/queue-monitor", self.toString(), "Leader-QueueMonitor", 1, TimeUnit.MINUTES, new Supplier<Service>() { @Override public Service get() { return new SystemQueueMonitor(eventStore, dataCenters, clusterInfo, masterFanoutPartitions, dataCenterFanoutPartitions, metricRegistry); } }); ServiceFailureListener.listenTo(leaderService, metricRegistry); dropwizardTask.register("queue-monitor", leaderService); lifeCycle.manage(new ManagedGuavaService(leaderService)); } }