本文整理汇总了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;
}
}
}
示例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;
}
}
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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;
}