Source:
<code>private void becomeLeader() { synchronized (lock) { if (!started) { return; } log.info("Go-Go Gadgetmobile! Starting bridge in %s", config.getStartDelay()); try { bridgeZkCoordinator.start(); serverInventoryView.start(); ScheduledExecutors.scheduleWithFixedDelay( exec, config.getStartDelay(), config.getPeriod(), new Callable<ScheduledExecutors.Signal>() { @Override public ScheduledExecutors.Signal call() { if (leader) { Iterable<DruidServer> servers = FunctionalIterable .create(serverInventoryView.getInventory()) .filter( new Predicate<DruidServer>() { @Override public boolean apply( DruidServer input ) { return !input.getType().equalsIgnoreCase("realtime"); } } ); long totalMaxSize = 0; for (DruidServer server : servers) { totalMaxSize += server.getMaxSize(); } if (totalMaxSize == 0) { log.warn("No servers founds!"); } else { DruidServerMetadata me = new DruidServerMetadata( self.getHost(), self.getHost(), totalMaxSize, NODE_TYPE, config.getTier(), config.getPriority() ); try { final String path = ZKPaths.makePath(config.getAnnouncementsPath(), self.getHost()); log.info("Updating [%s] to have a maxSize of[%,d] bytes", self.getHost(), totalMaxSize); announcer.update(path, jsonMapper.writeValueAsBytes(me)); } catch (Exception e) { throw Throwables.propagate(e); } } } <START> if (leader) { END> return ScheduledExecutors.Signal.REPEAT; } else { return ScheduledExecutors.Signal.STOP; } } } ); leader = true; } catch (Exception e) { log.makeAlert(e, "Exception becoming leader") .emit(); final LeaderLatch oldLatch = createNewLeaderLatch(); Closeables.closeQuietly(oldLatch); try { leaderLatch.get().start(); } catch (Exception e1) { log.makeAlert(e1, "I am a zombie") .emit(); } } } }</code><technical_language>"no longer leader"</technical_language>

Target:
private void becomeLeader() { synchronized (lock) { if (!started) { return; } log.info("Go-Go Gadgetmobile! Starting bridge in %s", config.getStartDelay()); try { bridgeZkCoordinator.start(); serverInventoryView.start(); ScheduledExecutors.scheduleWithFixedDelay( exec, config.getStartDelay(), config.getPeriod(), new Callable<ScheduledExecutors.Signal>() { @Override public ScheduledExecutors.Signal call() { if (leader) { Iterable<DruidServer> servers = FunctionalIterable .create(serverInventoryView.getInventory()) .filter( new Predicate<DruidServer>() { @Override public boolean apply( DruidServer input ) { return !input.isRealtime(); } } ); long totalMaxSize = 0; for (DruidServer server : servers) { totalMaxSize += server.getMaxSize(); } if (totalMaxSize == 0) { log.warn("No servers founds!"); } else { DruidServerMetadata me = new DruidServerMetadata( self.getHost(), self.getHost(), totalMaxSize, NODE_TYPE, config.getTier(), config.getPriority() ); try { final String path = ZKPaths.makePath(config.getAnnouncementsPath(), self.getHost()); log.info("Updating [%s] to have a maxSize of[%,d] bytes", self.getHost(), totalMaxSize); announcer.update(path, jsonMapper.writeValueAsBytes(me)); } catch (Exception e) { throw Throwables.propagate(e); } } } if (leader) { return ScheduledExecutors.Signal.REPEAT; } else { return ScheduledExecutors.Signal.STOP; } } } ); leader = true; } catch (Exception e) { log.makeAlert(e, "Exception becoming leader") .emit(); final LeaderLatch oldLatch = createNewLeaderLatch(); Closeables.closeQuietly(oldLatch); try { leaderLatch.get().start(); } catch (Exception e1) { log.makeAlert(e1, "I am a zombie") .emit(); } } } }