Search in sources :

Example 1 with ZookeeperAuthInfo

use of org.apache.storm.utils.ZookeeperAuthInfo in project storm by apache.

the class BlobStoreUtils method createZKClient.

public static CuratorFramework createZKClient(Map<String, Object> conf) {
    @SuppressWarnings("unchecked") List<String> zkServers = (List<String>) conf.get(Config.STORM_ZOOKEEPER_SERVERS);
    Object port = conf.get(Config.STORM_ZOOKEEPER_PORT);
    ZookeeperAuthInfo zkAuthInfo = new ZookeeperAuthInfo(conf);
    CuratorFramework zkClient = Utils.newCurator(conf, zkServers, port, (String) conf.get(Config.STORM_ZOOKEEPER_ROOT), zkAuthInfo);
    zkClient.start();
    return zkClient;
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) ZookeeperAuthInfo(org.apache.storm.utils.ZookeeperAuthInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ZookeeperAuthInfo

use of org.apache.storm.utils.ZookeeperAuthInfo in project storm by apache.

the class Zookeeper method mkClientImpl.

public CuratorFramework mkClientImpl(Map conf, List<String> servers, Object port, String root, final WatcherCallBack watcher, Map authConf) {
    CuratorFramework fk;
    if (authConf != null) {
        fk = Utils.newCurator(conf, servers, port, root, new ZookeeperAuthInfo(authConf));
    } else {
        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());
            }
        }
    });
    LOG.info("Staring ZK Curator");
    fk.start();
    return fk;
}
Also used : WatchedEvent(org.apache.zookeeper.WatchedEvent) CuratorFramework(org.apache.curator.framework.CuratorFramework) CuratorListener(org.apache.curator.framework.api.CuratorListener) ZookeeperAuthInfo(org.apache.storm.utils.ZookeeperAuthInfo) CuratorEvent(org.apache.curator.framework.api.CuratorEvent) BindException(java.net.BindException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) AuthorizationException(org.apache.storm.generated.AuthorizationException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException)

Aggregations

CuratorFramework (org.apache.curator.framework.CuratorFramework)2 ZookeeperAuthInfo (org.apache.storm.utils.ZookeeperAuthInfo)2 IOException (java.io.IOException)1 BindException (java.net.BindException)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CuratorEvent (org.apache.curator.framework.api.CuratorEvent)1 CuratorListener (org.apache.curator.framework.api.CuratorListener)1 AuthorizationException (org.apache.storm.generated.AuthorizationException)1 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)1 KeeperException (org.apache.zookeeper.KeeperException)1 WatchedEvent (org.apache.zookeeper.WatchedEvent)1