public static LocalClusterMap prepareLocalCluster() { LocalClusterMap state = new LocalClusterMap(); try { List<String> tmpDirs = new ArrayList(); String zkDir = getTmpDir(); tmpDirs.add(zkDir); Factory zookeeper = startLocalZookeeper(zkDir); Map conf = getLocalConf(zookeeper.getZooKeeperServer().getClientPort()); String nimbusDir = getTmpDir(); tmpDirs.add(nimbusDir); Map nimbusConf = deepCopyMap(conf); nimbusConf.put(Config.STORM_LOCAL_DIR, nimbusDir); NimbusServer instance = new NimbusServer(); Map supervisorConf = deepCopyMap(conf); String supervisorDir = getTmpDir(); tmpDirs.add(supervisorDir); supervisorConf.put(Config.STORM_LOCAL_DIR, supervisorDir); Supervisor supervisor = new Supervisor(); IContext context = getLocalContext(supervisorConf); state.setNimbusServer(instance); state.setNimbus(instance.launcherLocalServer(nimbusConf, new DefaultInimbus())); state.setZookeeper(zookeeper); state.setConf(conf); state.setTmpDir(tmpDirs); state.setSupervisor(supervisor.mkSupervisor(supervisorConf, context)); return state; } catch (Exception e) { LOG.error("prepare cluster error!", e); state.clean(); } return null; }
/** * supervisor daemon enter entrance * * @param args */ public static void main(String[] args) { Supervisor instance = new Supervisor(); instance.run(); }