Source:
private void becomeMaster() { synchronized (lock) { if (!started) { return; } log.info("I am the master, all must bow!"); try { master = true; databaseSegmentManager.start(); databaseRuleManager.start(); serverInventoryView.start(); final List<Pair<? extends MasterRunnable, Duration>> masterRunnables = Lists.newArrayList(); if (!defaultConfigsSet) { configManager.watch(DynamicConfigs.CONFIG_KEY, DynamicConfigs.class); configManager.set(DynamicConfigs.CONFIG_KEY, new DynamicConfigs(null,null,null,null)); defaultConfigsSet=true; } masterRunnables.add(Pair.of(new MasterComputeManagerRunnable(), config.getMasterPeriod())); if (indexingServiceClient != null) { masterRunnables.add( Pair.of( new MasterIndexingServiceRunnable( makeIndexingServiceHelpers(configManager.watch(MergerWhitelist.CONFIG_KEY, MergerWhitelist.class)) ), config.getMasterSegmentMergerPeriod() ) ); } for (final Pair<? extends MasterRunnable, Duration> masterRunnable : masterRunnables) { ScheduledExecutors.scheduleWithFixedDelay( exec, config.getMasterStartDelay(), masterRunnable.rhs, new Callable<ScheduledExecutors.Signal>() { private final MasterRunnable theRunnable = masterRunnable.lhs; @Override public ScheduledExecutors.Signal call() { if (master) { theRunnable.run(); } if (master) { return ScheduledExecutors.Signal.REPEAT; } else { return ScheduledExecutors.Signal.STOP; } } } ); } } catch (Exception e) { log.makeAlert(e, "Unable to become master") .emit(); final LeaderLatch oldLatch = createNewLeaderLatch(); Closeables.closeQuietly(oldLatch); try { leaderLatch.get().start(); } catch (Exception e1) { log.makeAlert(e1, "I am a zombie") .emit(); } } } }

Target:
private void becomeMaster() { synchronized (lock) { if (!started) { return; } log.info("I am the master, all must bow!"); try { master = true; databaseSegmentManager.start(); databaseRuleManager.start(); serverInventoryView.start(); final List<Pair<? extends MasterRunnable, Duration>> masterRunnables = Lists.newArrayList(); segmentSettingsAtomicReference = configManager.watch(MasterSegmentSettings.CONFIG_KEY, MasterSegmentSettings.class,new MasterSegmentSettings.Builder().build()); masterRunnables.add(Pair.of(new MasterComputeManagerRunnable(), config.getMasterPeriod())); if (indexingServiceClient != null) { masterRunnables.add( Pair.of( new MasterIndexingServiceRunnable( makeIndexingServiceHelpers(configManager.watch(MergerWhitelist.CONFIG_KEY, MergerWhitelist.class)) ), config.getMasterSegmentMergerPeriod() ) ); } for (final Pair<? extends MasterRunnable, Duration> masterRunnable : masterRunnables) { ScheduledExecutors.scheduleWithFixedDelay( exec, config.getMasterStartDelay(), masterRunnable.rhs, new Callable<ScheduledExecutors.Signal>() { private final MasterRunnable theRunnable = masterRunnable.lhs; @Override public ScheduledExecutors.Signal call() { if (master) { theRunnable.run(); } if (master) { return ScheduledExecutors.Signal.REPEAT; } else { return ScheduledExecutors.Signal.STOP; } } } ); } } catch (Exception e) { log.makeAlert(e, "Unable to become master") .emit(); final LeaderLatch oldLatch = createNewLeaderLatch(); Closeables.closeQuietly(oldLatch); try { leaderLatch.get().start(); } catch (Exception e1) { log.makeAlert(e1, "I am a zombie") .emit(); } } } }