Search in sources :

Example 1 with Factory

use of com.alibaba.jstorm.zk.Factory in project jstorm by alibaba.

the class LocalUtils method prepareLocalCluster.

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;
}
Also used : Supervisor(com.alibaba.jstorm.daemon.supervisor.Supervisor) NimbusServer(com.alibaba.jstorm.daemon.nimbus.NimbusServer) IContext(backtype.storm.messaging.IContext) ArrayList(java.util.ArrayList) LoggerFactory(org.slf4j.LoggerFactory) Factory(com.alibaba.jstorm.zk.Factory) HashMap(java.util.HashMap) Map(java.util.Map) DefaultInimbus(com.alibaba.jstorm.daemon.nimbus.DefaultInimbus)

Aggregations

IContext (backtype.storm.messaging.IContext)1 DefaultInimbus (com.alibaba.jstorm.daemon.nimbus.DefaultInimbus)1 NimbusServer (com.alibaba.jstorm.daemon.nimbus.NimbusServer)1 Supervisor (com.alibaba.jstorm.daemon.supervisor.Supervisor)1 Factory (com.alibaba.jstorm.zk.Factory)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 LoggerFactory (org.slf4j.LoggerFactory)1