当前位置: 首页>>代码示例>>Java>>正文


Java Utils.newCurator方法代码示例

本文整理汇总了Java中backtype.storm.utils.Utils.newCurator方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.newCurator方法的具体用法?Java Utils.newCurator怎么用?Java Utils.newCurator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backtype.storm.utils.Utils的用法示例。


在下文中一共展示了Utils.newCurator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMaster

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static String getMaster(Map storm_conf, Integer timeout) throws Exception {
    CuratorFramework zkobj = null;
    String masterHost = null;

    try {
        String root = String.valueOf(storm_conf.get(Config.STORM_ZOOKEEPER_ROOT));
        String zkMasterDir = root + MASTER_PATH;

        zkobj = Utils.newCurator(storm_conf, (List<String>) storm_conf.get(Config.STORM_ZOOKEEPER_SERVERS),
                storm_conf.get(Config.STORM_ZOOKEEPER_PORT), zkMasterDir);
        zkobj.start();
        if (zkobj.checkExists().forPath("/") == null) {
            throw new RuntimeException("No alive nimbus ");
        }

        masterHost = new String(zkobj.getData().forPath("/"));

        LOG.info("masterHost:" + masterHost);
        return masterHost;
    } finally {
        if (zkobj != null) {
            zkobj.close();
            zkobj = null;
        }
    }
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:27,代码来源:ThriftClient.java

示例2: getMasterByZk

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static String getMasterByZk(Map conf) throws Exception {

        CuratorFramework zkobj = null;
        String masterHost = null;

        try {
            String root = String.valueOf(conf.get(Config.STORM_ZOOKEEPER_ROOT));
            String zkMasterDir = root + Cluster.MASTER_SUBTREE;

            zkobj = Utils.newCurator(conf, (List<String>) conf.get(Config.STORM_ZOOKEEPER_SERVERS), conf.get(Config.STORM_ZOOKEEPER_PORT), zkMasterDir);
            zkobj.start();
            if (zkobj.checkExists().forPath("/") == null) {
                throw new RuntimeException("No alive nimbus ");
            }

            masterHost = new String(zkobj.getData().forPath("/"));

            LOG.info("masterHost:" + masterHost);
            return masterHost;
        } finally {
            if (zkobj != null) {
                zkobj.close();
                zkobj = null;
            }
        }
    }
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:27,代码来源:ThriftClient.java

示例3: ThriftClient

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public ThriftClient(Map storm_conf, Integer timeout) throws Exception {
	conf = storm_conf;
	String root = String.valueOf(storm_conf
			.get(Config.STORM_ZOOKEEPER_ROOT));
	zkMasterDir = root + MASTER_PATH;

	LOG.info("zkServer:"
			+ (List<String>) storm_conf.get(Config.STORM_ZOOKEEPER_SERVERS)
			+ ", zkPort:"
			+ Utils.getInt(storm_conf.get(Config.STORM_ZOOKEEPER_PORT)));
	zkobj = Utils.newCurator(storm_conf,
			(List<String>) storm_conf.get(Config.STORM_ZOOKEEPER_SERVERS),
			storm_conf.get(Config.STORM_ZOOKEEPER_PORT), zkMasterDir);
	zkobj.start();
	if (zkobj.checkExists().forPath("/") == null)
		throw new RuntimeException("No alive nimbus ");
	flushClient(storm_conf, timeout);
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:20,代码来源:ThriftClient.java

示例4: getMaster

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static String getMaster(Map storm_conf, Integer timeout) throws Exception {
	CuratorFramework zkobj = null;
	String  masterHost = null;
	
	try {
		String root = String.valueOf(storm_conf
				.get(Config.STORM_ZOOKEEPER_ROOT));
		String zkMasterDir = root + MASTER_PATH;

		
		zkobj = Utils.newCurator(storm_conf,
				(List<String>) storm_conf.get(Config.STORM_ZOOKEEPER_SERVERS),
				storm_conf.get(Config.STORM_ZOOKEEPER_PORT), zkMasterDir);
		zkobj.start();
		if (zkobj.checkExists().forPath("/") == null) {
			throw new RuntimeException("No alive nimbus ");
		}
		
		masterHost = new String(zkobj.getData().forPath("/"));

		LOG.info("masterHost:"  + masterHost);
		return masterHost;
	}finally {
		if (zkobj != null) {
			zkobj.close();
			zkobj = null;
		}
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:30,代码来源:ThriftClient.java

示例5: mkClient

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
/**
 * connect ZK, register Watch/unhandle Watch
 * 
 * @return
 */
public CuratorFramework mkClient(Map conf, List<String> servers,
		Object port, String root, final WatcherCallBack watcher) {

	CuratorFramework fk = Utils.newCurator(conf, servers, port, root);

	fk.getCuratorListenable().addListener(new CuratorListener() {
		@Override
		public void eventReceived(CuratorFramework _fk, CuratorEvent e)
				throws Exception {
			if (e.getType().equals(CuratorEventType.WATCHED)) {
				WatchedEvent event = e.getWatchedEvent();

				watcher.execute(event.getState(), event.getType(),
						event.getPath());
			}

		}
	});

	fk.getUnhandledErrorListenable().addListener(
			new UnhandledErrorListener() {
				@Override
				public void unhandledError(String msg, Throwable error) {
					String errmsg = "Unrecoverable Zookeeper error, halting process: "
							+ msg;
					LOG.error(errmsg, error);
					JStormUtils.halt_process(1,
							"Unrecoverable Zookeeper error");

				}
			});
	fk.start();
	return fk;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:40,代码来源:Zookeeper.java

示例6: mkClient

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
/**
 * connect ZK, register Watch/unhandle Watch
 * 
 * @return
 */
public CuratorFramework mkClient(Map conf, List<String> servers, Object port, String root, final WatcherCallBack watcher) {

    CuratorFramework fk = Utils.newCurator(conf, servers, port, root);

    fk.getCuratorListenable().addListener(new CuratorListener() {
        @Override
        public void eventReceived(CuratorFramework _fk, CuratorEvent e) throws Exception {
            if (e.getType().equals(CuratorEventType.WATCHED)) {
                WatchedEvent event = e.getWatchedEvent();

                watcher.execute(event.getState(), event.getType(), event.getPath());
            }

        }
    });

    fk.getUnhandledErrorListenable().addListener(new UnhandledErrorListener() {
        @Override
        public void unhandledError(String msg, Throwable error) {
            String errmsg = "Unrecoverable Zookeeper error, halting process: " + msg;
            LOG.error(errmsg, error);
            JStormUtils.halt_process(1, "Unrecoverable Zookeeper error");

        }
    });
    fk.start();
    return fk;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:34,代码来源:Zookeeper.java


注:本文中的backtype.storm.utils.Utils.newCurator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。