Source:
public boolean runScheduler() { IScheduler scheduler = null; String statemgrClass = Context.stateManagerClass(config); IStateManager statemgr; try { statemgr = ReflectionUtils.newInstance(statemgrClass); } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { LOG.log(Level.SEVERE, "Failed to instantiate instances", e); return false; } SchedulerServer server = null; boolean isSuccessful = false; try { statemgr.initialize(config); SchedulerStateManagerAdaptor adaptor = new SchedulerStateManagerAdaptor(statemgr, 5000); PackingPlans.PackingPlan serializedPackingPlan = adaptor.getPackingPlan(topology.getName()); if (serializedPackingPlan == null) { LOG.severe("Failed to obtain a valid PackingPlan from the state manager"); return false; } LOG.log(Level.INFO, "Packing plan fetched from state: {0}", serializedPackingPlan); PackingPlan packedPlan = new PackingPlanProtoDeserializer().fromProto(serializedPackingPlan); LauncherUtils launcherUtils = LauncherUtils.getInstance(); Config runtime = Config.newBuilder() .putAll(launcherUtils.getPrimaryRuntime(topology, adaptor)) .put(Keys.schedulerShutdown(), getShutdown()) .put(Keys.SCHEDULER_PROPERTIES, properties) .build(); Config ytruntime = launcherUtils.createConfigWithPackingDetails(runtime, packedPlan); scheduler = launcherUtils.getSchedulerInstance(config, ytruntime); if (scheduler == null) { return false; } isSuccessful = scheduler.onSchedule(packedPlan); if (!isSuccessful) { LOG.severe("Failed to schedule topology"); return false; } server = getServer(ytruntime, scheduler, schedulerServerPort); server.start(); isSuccessful = SchedulerUtils.setSchedulerLocation( runtime, String.format("%s:%d", server.getHost(), server.getPort()), scheduler); if (isSuccessful) { LOG.info("Waiting for termination... "); Runtime.schedulerShutdown(ytruntime).await(); } } catch (IOException e) { LOG.log(Level.SEVERE, "Failed to start server", e); return false; } finally { if (server != null) { server.stop(); } SysUtils.closeIgnoringExceptions(scheduler); SysUtils.closeIgnoringExceptions(statemgr); } return isSuccessful; }

Target:
public boolean runScheduler() { IScheduler scheduler = null; String statemgrClass = Context.stateManagerClass(config); IStateManager statemgr; try { statemgr = ReflectionUtils.newInstance(statemgrClass); } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { LOG.log(Level.SEVERE, "Failed to instantiate instances", e); return false; } SchedulerServer server = null; boolean isSuccessful = false; try { statemgr.initialize(config); SchedulerStateManagerAdaptor adaptor = new SchedulerStateManagerAdaptor(statemgr, 5000); PackingPlans.PackingPlan serializedPackingPlan = adaptor.getPackingPlan(topology.getName()); if (serializedPackingPlan == null) { LOG.log(Level.SEVERE, "Failed to fetch PackingPlan for topology:{0} from the state manager", topology.getName()); return false; } LOG.log(Level.INFO, "Packing plan fetched from state: {0}", serializedPackingPlan); PackingPlan packedPlan = new PackingPlanProtoDeserializer().fromProto(serializedPackingPlan); LauncherUtils launcherUtils = LauncherUtils.getInstance(); Config runtime = Config.newBuilder() .putAll(launcherUtils.getPrimaryRuntime(topology, adaptor)) .put(Keys.schedulerShutdown(), getShutdown()) .put(Keys.SCHEDULER_PROPERTIES, properties) .build(); Config ytruntime = launcherUtils.createConfigWithPackingDetails(runtime, packedPlan); scheduler = launcherUtils.getSchedulerInstance(config, ytruntime); if (scheduler == null) { return false; } isSuccessful = scheduler.onSchedule(packedPlan); if (!isSuccessful) { LOG.severe("Failed to schedule topology"); return false; } server = getServer(ytruntime, scheduler, schedulerServerPort); server.start(); isSuccessful = SchedulerUtils.setSchedulerLocation( runtime, String.format("%s:%d", server.getHost(), server.getPort()), scheduler); if (isSuccessful) { LOG.info("Waiting for termination... "); Runtime.schedulerShutdown(ytruntime).await(); } } catch (IOException e) { LOG.log(Level.SEVERE, "Failed to start server", e); return false; } finally { if (server != null) { server.stop(); } SysUtils.closeIgnoringExceptions(scheduler); SysUtils.closeIgnoringExceptions(statemgr); } return isSuccessful; }