public void linkBasedScheduling( Topologies topos, Cluster cluster, GlobalState globalState, GlobalResources globalResources) { for (TopologyDetails td : topos.getTopologies()) { String topId = td.getId(); Map<Node, Collection<ExecutorDetails>> taskToNodesMap; if (cluster.needsScheduling(td) && cluster.getUnassignedExecutors(td).size() > 0) { LOG.info("/********Scheduling topology {} ************/", topId); int totalTasks = td.getExecutors().size(); int executorsNotRunning = cluster.getUnassignedExecutors(td).size(); LOG.info( "Total number of executors: {} " + "Total number of Unassigned Executors: {}", totalTasks, executorsNotRunning); LOG.info("executors that need scheduling: {}", cluster.getUnassignedExecutors(td)); LinkBasedStrategy rs = new LinkBasedStrategy(globalState, globalResources, null, td, cluster, topos); taskToNodesMap = rs.schedule(td, cluster.getUnassignedExecutors(td)); if (taskToNodesMap != null) { try { for (Map.Entry<Node, Collection<ExecutorDetails>> entry : taskToNodesMap.entrySet()) { entry.getKey().assign(td.getId(), entry.getValue(), cluster); LOG.info( "ASSIGNMENT TOPOLOGY: {} TASKS: {} To Node: " + entry.getKey().getId() + " Slots left: " + entry.getKey().totalSlotsFree(), td.getId(), entry.getValue()); } LOG.info( "Toplogy: {} assigned to {} nodes", td.getId(), taskToNodesMap.keySet().size()); HelperFuncs.setTopoStatus(td.getId(), "Fully Scheduled"); } catch (IllegalStateException ex) { LOG.error(ex.toString()); LOG.error("Unsuccessfull in scheduling topology {}", td.getId()); HelperFuncs.setTopoStatus(td.getId(), "Unsuccessfull in scheduling topology"); } } else { LOG.error("Unsuccessfull in scheduling topology {}", td.getId()); HelperFuncs.setTopoStatus(td.getId(), "Unsuccessfull in scheduling topology"); } } else { HelperFuncs.setTopoStatus(td.getId(), "Fully Scheduled"); } } }
@Override public void schedule(Topologies topologies, Cluster cluster) { LOG.info("\n\n\nRerunning LinkBasedScheduler..."); GlobalResources globalResources = new GlobalResources(cluster, topologies); GlobalState globalState = GlobalState.getInstance("LinkBasedScheduler"); globalState.updateInfo(cluster, topologies, globalResources); GetStats gs = GetStats.getInstance("LinkBasedScheduler"); gs.getStatistics(); linkBasedScheduling(topologies, cluster, globalState, globalResources); globalState.storeState(cluster, topologies, globalResources); LOG.info("GlobalState:\n{}", globalState); LOG.info("GlobalResources: \n{}\n", globalResources); HelperFuncs.printNodeResources(globalState.nodes); }