org.apache.curator.framework.recipes.cache.NodeCacheListener Java Examples

The following examples show how to use org.apache.curator.framework.recipes.cache.NodeCacheListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZookeeperConfigActivator.java    From sofa-ark with Apache License 2.0 6 votes vote down vote up
protected void subscribeIpConfig() {
    ipNodeCache = new NodeCache(zkClient, ipResourcePath);
    ipNodeCache.getListenable().addListener(new NodeCacheListener() {
        private int version = -1;

        @Override
        public void nodeChanged() throws Exception {
            if (ipNodeCache.getCurrentData() != null
                && ipNodeCache.getCurrentData().getStat().getVersion() > version) {
                version = ipNodeCache.getCurrentData().getStat().getVersion();
                String configData = new String(ipNodeCache.getCurrentData().getData());
                ipConfigDeque.add(configData);
                LOGGER.info("Receive ip config data: {}, version is {}.", configData, version);
            }
        }
    });
    try {
        LOGGER.info("Subscribe ip config: {}.", ipResourcePath);
        ipNodeCache.start(true);
    } catch (Exception e) {
        throw new ArkRuntimeException("Failed to subscribe ip resource path.", e);
    }
}
 
Example #2
Source File: ZookeeperConfigActivator.java    From sofa-ark with Apache License 2.0 6 votes vote down vote up
protected void subscribeBizConfig() {
    bizNodeCache = new NodeCache(zkClient, bizResourcePath);
    bizNodeCache.getListenable().addListener(new NodeCacheListener() {
        private int version = -1;

        @Override
        public void nodeChanged() throws Exception {
            if (bizNodeCache.getCurrentData() != null
                && bizNodeCache.getCurrentData().getStat().getVersion() > version) {
                version = bizNodeCache.getCurrentData().getStat().getVersion();
                String configData = new String(bizNodeCache.getCurrentData().getData());
                bizConfigDeque.add(configData);
                LOGGER.info("Receive app config data: {}, version is {}.", configData, version);
            }
        }
    });

    try {
        bizNodeCache.start(true);
    } catch (Exception e) {
        throw new ArkRuntimeException("Failed to subscribe resource path.", e);
    }
}
 
Example #3
Source File: ZkClient.java    From xio with Apache License 2.0 6 votes vote down vote up
public void registerUpdater(ConfigurationUpdater updater) {
  NodeCache cache = getOrCreateNodeCache(updater.getPath());
  if (client.getState().equals(CuratorFrameworkState.STARTED)) {
    startNodeCache(cache);
  }

  cache
      .getListenable()
      .addListener(
          new NodeCacheListener() {
            @Override
            public void nodeChanged() {
              updater.update(cache.getCurrentData().getData());
            }
          });
}
 
Example #4
Source File: NodeCacheObserver.java    From micro-service with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        CuratorFramework client = CuratorFrameworkFactory.newClient(ZOOKEEPER_CONNECT_STRING, new ExponentialBackoffRetry(1000, 3));
        client.start();

        String path = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL).forPath("/observer", "data".getBytes());
        final NodeCache nodeCache = new NodeCache(client, path, false);
        nodeCache.start();

        nodeCache.getListenable().addListener(new NodeCacheListener() {
            public void nodeChanged() throws Exception {
                if (nodeCache.getCurrentData() != null) {
                    logger.info(nodeCache.getPath());
                }
            }
        });
    }
 
Example #5
Source File: ZookeeperConfigService.java    From Zebra with Apache License 2.0 6 votes vote down vote up
private NodeCache newNodeCache(final String key) throws Exception {
	String path = getConfigPath(key);
	final NodeCache nodeCache = new NodeCache(client, path);
	nodeCache.getListenable().addListener(new NodeCacheListener() {
		@Override
		public void nodeChanged() throws Exception {
			String oldValue = keyMap.get(key);
			String newValue = new String(nodeCache.getCurrentData().getData());
			keyMap.put(key, newValue);
			notifyListeners(key, oldValue, newValue);
		}
	});
	nodeCache.start(true);

	keyMap.put(key, new String(nodeCache.getCurrentData().getData(), Constants.DEFAULT_CHARSET));

	return nodeCache;
}
 
Example #6
Source File: ZkValueStore.java    From emodb with Apache License 2.0 6 votes vote down vote up
@Override
public void start() throws Exception {
    // Create the zookeeper node
    createNode();
    // Initial data load (avoid race conditions w/"NodeCache.start(true)")
    updateFromZkBytes(_curator.getData().forPath(_zkPath), _defaultValue);

    // Re-load the data and watch for changes.
    _nodeCache.getListenable().addListener(new NodeCacheListener() {
        @Override
        public void nodeChanged() throws Exception {
            ChildData childData = _nodeCache.getCurrentData();
            if (childData != null) {
                updateFromZkBytes(childData.getData(), _defaultValue);
            }
        }
    });
    _nodeCache.start();
}
 
Example #7
Source File: ZktoXmlMain.java    From Mycat2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 进行zk的watch操作
* 方法描述
* @param zkConn zk的连接信息
* @param path 路径信息
* @param zkListen 监控路径信息
* @throws Exception
* @创建日期 2016年9月20日
*/
private static NodeCache runWatch(final CuratorFramework zkConn, final String path,
        final ZookeeperProcessListen zkListen) throws Exception {
    final NodeCache cache = new NodeCache(zkConn, path);

    NodeCacheListener listen = new NodeCacheListener() {
        @Override
        public void nodeChanged() throws Exception {
            LOGGER.info("ZktoxmlMain runWatch  process path  event start ");
            LOGGER.info("NodeCache changed, path is: " + cache.getCurrentData().getPath());
            String notPath = cache.getCurrentData().getPath();
            // 进行通知更新
            zkListen.notifly(notPath);
            LOGGER.info("ZktoxmlMain runWatch  process path  event over");
        }
    };

    // 添加监听
    cache.getListenable().addListener(listen);

    return cache;
}
 
Example #8
Source File: ConfigUpdate.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public boolean init() {
    if (StringUtils.isEmpty(controller.getBrokerConfig().getZkPath())) {
        return true;
    }

    client = CuratorFrameworkFactory.newClient(controller.getBrokerConfig().getZkPath(), new ExponentialBackoffRetry(1000, 3));
    client.start();

    String path = getBrokerConfigPath();
    try {
        if (client.checkExists().forPath(path) == null) {
            log.error("config path in not exist, path:{}", path);
            return false;
        }
        //add watcher
        cache = new NodeCache(client, path);
        NodeCacheListener listener = new NodeCacheListener() {
            @Override public void nodeChanged() throws Exception {
                log.info("config changed, update");
                ChildData data = cache.getCurrentData();
                if (null != data) {
                    String config = new String(cache.getCurrentData().getData());
                    updateConfig(config);
                } else {
                    log.warn("node is deleted");
                }
            }
        };

        cache.getListenable().addListener(listener);

        cache.start();
    } catch (Exception ex) {
        log.error("cache start failed", ex);
        return false;
    }

    return true;
}
 
Example #9
Source File: NodeCacheExample.java    From ZKRecipesByExample with Apache License 2.0 5 votes vote down vote up
private static void addListener(final NodeCache cache) {
	// a PathChildrenCacheListener is optional. Here, it's used just to log
	// changes
	NodeCacheListener listener = new NodeCacheListener() {

		@Override
		public void nodeChanged() throws Exception {
			if (cache.getCurrentData() != null)
				System.out.println("Node changed: " + cache.getCurrentData().getPath() + ", value: " + new String(cache.getCurrentData().getData()));
		}
	};
	cache.getListenable().addListener(listener);
}
 
Example #10
Source File: ZKGarbageCollector.java    From pravega with Apache License 2.0 5 votes vote down vote up
@SneakyThrows(Exception.class)
private NodeCache registerWatch(String watchPath) {
    NodeCache nodeCache = new NodeCache(zkStoreHelper.getClient(), watchPath);
    NodeCacheListener watchListener = () -> {
        currentBatch.set(nodeCache.getCurrentData().getStat().getVersion());
        log.debug("Current batch for {} changed to {}", gcName, currentBatch.get());
    };

    nodeCache.getListenable().addListener(watchListener);

    nodeCache.start();
    return nodeCache;
}
 
Example #11
Source File: MountsManager.java    From nnproxy with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStart() throws Exception {
    framework.start();
    nodeCache = new NodeCache(framework, zkMountTablePath, false);
    nodeCache.getListenable().addListener(new NodeCacheListener() {
        @Override
        public void nodeChanged() throws Exception {
            handleMountTableChange(nodeCache.getCurrentData().getData());
        }
    });
    nodeCache.start(false);
}
 
Example #12
Source File: ZktoXmlMain.java    From dble with GNU General Public License v2.0 5 votes vote down vote up
private static void runWatch(final NodeCache cache, final ZookeeperProcessListen zkListen)
        throws Exception {
    cache.getListenable().addListener(new NodeCacheListener() {

        @Override
        public void nodeChanged() {
            LOGGER.info("ZktoxmlMain runWatch  process path  event start ");
            String notPath = cache.getCurrentData().getPath();
            LOGGER.info("NodeCache changed, path is: " + notPath);
            // notify
            zkListen.notify(notPath);
            LOGGER.info("ZktoxmlMain runWatch  process path  event over");
        }
    });
}
 
Example #13
Source File: CuratorWatcher.java    From BigData-In-Practice with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    final String nodePath = "/testZK";
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(10000, 5);
    CuratorFramework client = CuratorFrameworkFactory.builder().connectString(zkServerIps)
            .sessionTimeoutMs(10000).retryPolicy(retryPolicy).build();
    try {
        client.start();
        client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(nodePath, "this is a test data".getBytes());

        final NodeCache cacheNode = new NodeCache(client, nodePath, false);
        cacheNode.start(true);  // true 表示启动时立即从Zookeeper上获取节点
        cacheNode.getListenable().addListener(new NodeCacheListener() {
            @Override
            public void nodeChanged() throws Exception {
                System.out.println("节点数据更新,新的内容是: " + new String(cacheNode.getCurrentData().getData()));
            }
        });
        for (int i = 0; i < 5; i++) {
            client.setData().forPath(nodePath, ("new test data " + i).getBytes());
            Thread.sleep(1000);
        }
        Thread.sleep(10000); // 等待100秒,手动在 zkCli 客户端操作节点,触发事件
    } finally {
        client.delete().deletingChildrenIfNeeded().forPath(nodePath);
        client.close();
        System.out.println("客户端关闭......");
    }
}
 
Example #14
Source File: ConfigUpdate.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public boolean init() {
    if (StringUtils.isEmpty(controller.getBrokerConfig().getZkPath())) {
        return true;
    }

    client = CuratorFrameworkFactory.newClient(controller.getBrokerConfig().getZkPath(), new ExponentialBackoffRetry(1000, 3));
    client.start();

    String path = getBrokerConfigPath();
    try {
        if (client.checkExists().forPath(path) == null) {
            log.error("config path in not exist, path:{}", path);
            return false;
        }
        //add watcher
        cache = new NodeCache(client, path);
        NodeCacheListener listener = new NodeCacheListener() {
            @Override public void nodeChanged() throws Exception {
                log.info("config changed, update");
                ChildData data = cache.getCurrentData();
                if (null != data) {
                    String config = new String(cache.getCurrentData().getData());
                    updateConfig(config);
                } else {
                    log.warn("node is deleted");
                }
            }
        };

        cache.getListenable().addListener(listener);

        cache.start();
    } catch (Exception ex) {
        log.error("cache start failed", ex);
        return false;
    }

    return true;
}
 
Example #15
Source File: ZookeeperDataSource.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 4 votes vote down vote up
private void initZookeeperListener(final String serverAddr, final List<AuthInfo> authInfos) {
    try {

        this.listener = new NodeCacheListener() {
            @Override
            public void nodeChanged() {

                try {
                    T newValue = loadConfig();
                    RecordLog.info(String.format("[ZookeeperDataSource] New property value received for (%s, %s): %s",
                            serverAddr, path, newValue));
                    // Update the new value to the property.
                    getProperty().updateValue(newValue);
                } catch (Exception ex) {
                    RecordLog.warn("[ZookeeperDataSource] loadConfig exception", ex);
                }
            }
        };

        String zkKey = getZkKey(serverAddr, authInfos);
        if (zkClientMap.containsKey(zkKey)) {
            this.zkClient = zkClientMap.get(zkKey);
        } else {
            synchronized (lock) {
                if (!zkClientMap.containsKey(zkKey)) {
                    CuratorFramework zc = null;
                    if (authInfos == null || authInfos.size() == 0) {
                        zc = CuratorFrameworkFactory.newClient(serverAddr, new ExponentialBackoffRetry(SLEEP_TIME, RETRY_TIMES));
                    } else {
                        zc = CuratorFrameworkFactory.builder().
                                connectString(serverAddr).
                                retryPolicy(new ExponentialBackoffRetry(SLEEP_TIME, RETRY_TIMES)).
                                authorization(authInfos).
                                build();
                    }
                    this.zkClient = zc;
                    this.zkClient.start();
                    Map<String, CuratorFramework> newZkClientMap = new HashMap<>(zkClientMap.size());
                    newZkClientMap.putAll(zkClientMap);
                    newZkClientMap.put(zkKey, zc);
                    zkClientMap = newZkClientMap;
                } else {
                    this.zkClient = zkClientMap.get(zkKey);
                }
            }
        }

        this.nodeCache = new NodeCache(this.zkClient, this.path);
        this.nodeCache.getListenable().addListener(this.listener, this.pool);
        this.nodeCache.start();
    } catch (Exception e) {
        RecordLog.warn("[ZookeeperDataSource] Error occurred when initializing Zookeeper data source", e);
        e.printStackTrace();
    }
}
 
Example #16
Source File: FollowerInitEventHandler.java    From hermes with Apache License 2.0 4 votes vote down vote up
protected void addBaseMetaVersionListener(long version) throws DalException {
	ListenerContainer<NodeCacheListener> listenerContainer = m_baseMetaVersionCache.getListenable();
	listenerContainer.addListener(new BaseMetaVersionListener(version, listenerContainer), m_eventBus.getExecutor());
}
 
Example #17
Source File: NodeCacheListenerWrapper.java    From curator with Apache License 2.0 4 votes vote down vote up
NodeCacheListenerWrapper(NodeCacheListener listener)
{
    this.listener = listener;
}
 
Example #18
Source File: ConfigCenterTest.java    From BigData-In-Practice with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // 最开始时设置MySQL配置信息为 mysqlConfig_1
    setMysqlConfig(mysqlConfig_1);
    // 启动 clientNums 个线程,模拟分布式系统中的节点,
    // 从Zookeeper中获取MySQL的配置信息,查询数据
    for (int i = 0; i < clientNums; i++) {
        String clientName = "client#" + i;
        new Thread(new Runnable() {
            @Override
            public void run() {
                CuratorFramework client = ZKUtils.getClient();
                client.start();
                try {
                    Stat stat = new Stat();
                    // 如果要监听多个子节点则应该使用 PathChildrenCache
                    final NodeCache cacheNode = new NodeCache(client, configPath, false);
                    cacheNode.start(true);  // true 表示启动时立即从Zookeeper上获取节点

                    byte[] nodeData = cacheNode.getCurrentData().getData();
                    MysqlConfig mysqlConfig = JSON.parseObject(new String(nodeData), MysqlConfig.class);
                    queryMysql(clientName, mysqlConfig);    // 查询数据

                    cacheNode.getListenable().addListener(new NodeCacheListener() {
                        @Override
                        public void nodeChanged() throws Exception {
                            byte[] newData = cacheNode.getCurrentData().getData();
                            MysqlConfig newMysqlConfig = JSON.parseObject(new String(newData), MysqlConfig.class);
                            queryMysql(clientName, newMysqlConfig);    // 查询数据
                        }
                    });
                    Thread.sleep(20 * 1000);
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    client.close();
                    countDownLatch.countDown();
                }
            }
        }).start();
    }
    Thread.sleep(10 * 1000);
    System.out.println("\n---------10秒钟后将MySQL配置信息修改为 mysqlConfig_2---------\n");
    setMysqlConfig(mysqlConfig_2);
    countDownLatch.await();
}
 
Example #19
Source File: NodeCacheWrapper.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public void addListener(NodeCacheListener listener) {
    wrapped.getListenable().addListener(listener);

}
 
Example #20
Source File: MockCurator.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public void addListener(NodeCacheListener listener) {
    listeners.add(path, listener);
}
 
Example #21
Source File: MockCurator.java    From vespa with Apache License 2.0 4 votes vote down vote up
public void add(Path path, NodeCacheListener listener) {
    fileListeners.put(path, listener);
}
 
Example #22
Source File: ServiceDiscoveryImpl.java    From xian with Apache License 2.0 4 votes vote down vote up
private NodeCache makeNodeCache(final ServiceInstance<T> instance)
{
    if ( !watchInstances )
    {
        return null;
    }

    final NodeCache nodeCache = new NodeCache(client, pathForInstance(instance.getName(), instance.getId()));
    try
    {
        nodeCache.start(true);
    }
    catch ( Exception e )
    {
        ThreadUtils.checkInterrupted(e);
        log.error("Could not start node cache for: " + instance, e);
    }
    NodeCacheListener listener = new NodeCacheListener()
    {
        @Override
        public void nodeChanged() throws Exception
        {
            if ( nodeCache.getCurrentData() != null )
            {
                ServiceInstance<T> newInstance = serializer.deserialize(nodeCache.getCurrentData().getData());
                Entry<T> entry = services.get(newInstance.getId());
                if ( entry != null )
                {
                    synchronized(entry)
                    {
                        entry.service = newInstance;
                    }
                }
            }
            else
            {
                log.warn("Instance data has been deleted for: " + instance);
            }
        }
    };
    nodeCache.getListenable().addListener(listener);
    return nodeCache;
}
 
Example #23
Source File: ZookeeperDataSource.java    From Sentinel with Apache License 2.0 4 votes vote down vote up
private void initZookeeperListener(final String serverAddr, final List<AuthInfo> authInfos) {
    try {

        this.listener = new NodeCacheListener() {
            @Override
            public void nodeChanged() {

                try {
                    T newValue = loadConfig();
                    RecordLog.info(String.format("[ZookeeperDataSource] New property value received for (%s, %s): %s",
                            serverAddr, path, newValue));
                    // Update the new value to the property.
                    getProperty().updateValue(newValue);
                } catch (Exception ex) {
                    RecordLog.warn("[ZookeeperDataSource] loadConfig exception", ex);
                }
            }
        };

        String zkKey = getZkKey(serverAddr, authInfos);
        if (zkClientMap.containsKey(zkKey)) {
            this.zkClient = zkClientMap.get(zkKey);
        } else {
            synchronized (lock) {
                if (!zkClientMap.containsKey(zkKey)) {
                    CuratorFramework zc = null;
                    if (authInfos == null || authInfos.size() == 0) {
                        zc = CuratorFrameworkFactory.newClient(serverAddr, new ExponentialBackoffRetry(SLEEP_TIME, RETRY_TIMES));
                    } else {
                        zc = CuratorFrameworkFactory.builder().
                                connectString(serverAddr).
                                retryPolicy(new ExponentialBackoffRetry(SLEEP_TIME, RETRY_TIMES)).
                                authorization(authInfos).
                                build();
                    }
                    this.zkClient = zc;
                    this.zkClient.start();
                    Map<String, CuratorFramework> newZkClientMap = new HashMap<>(zkClientMap.size());
                    newZkClientMap.putAll(zkClientMap);
                    newZkClientMap.put(zkKey, zc);
                    zkClientMap = newZkClientMap;
                } else {
                    this.zkClient = zkClientMap.get(zkKey);
                }
            }
        }

        this.nodeCache = new NodeCache(this.zkClient, this.path);
        this.nodeCache.getListenable().addListener(this.listener, this.pool);
        this.nodeCache.start();
    } catch (Exception e) {
        RecordLog.warn("[ZookeeperDataSource] Error occurred when initializing Zookeeper data source", e);
        e.printStackTrace();
    }
}
 
Example #24
Source File: BaseNodeCacheListener.java    From hermes with Apache License 2.0 4 votes vote down vote up
protected BaseNodeCacheListener(long version, ListenerContainer<NodeCacheListener> listenerContainer) {
	m_version = version;
	m_eventBus = PlexusComponentLocator.lookup(EventBus.class);
	m_clusterStateHolder = PlexusComponentLocator.lookup(ClusterStateHolder.class);
	m_listenerContainer = listenerContainer;
}
 
Example #25
Source File: TestEndToEndScenariosWithHA.java    From phoenix-omid with Apache License 2.0 4 votes vote down vote up
@BeforeMethod(alwaysRun = true, timeOut = 30_000)
public void setup() throws Exception {
    // Get the zkConnection string from minicluster
    String zkConnection = "localhost:" + hBaseUtils.getZkCluster().getClientPort();

    zkClient = provideInitializedZookeeperClient(zkConnection);

    // Synchronize TSO start
    barrierTillTSOAddressPublication = new CountDownLatch(1);
    final NodeCache currentTSOZNode = new NodeCache(zkClient, CURRENT_TSO_PATH);
    currentTSOZNode.getListenable().addListener(new NodeCacheListener() {

        @Override
        public void nodeChanged() throws Exception {
            byte[] currentTSOAndEpochAsBytes = currentTSOZNode.getCurrentData().getData();
            String currentTSOAndEpoch = new String(currentTSOAndEpochAsBytes, Charsets.UTF_8);
            if (currentTSOAndEpoch.endsWith("#0")) { // Wait till a TSO instance publishes the epoch
                barrierTillTSOAddressPublication.countDown();
            }
        }

    });
    currentTSOZNode.start(true);

    // Configure TSO 1
    TSOServerConfig config1 = new TSOServerConfig();
    config1.setPort(TSO1_PORT);
    config1.setConflictMapSize(1000);
    config1.setLeaseModule(new TestHALeaseManagementModule(TEST_LEASE_PERIOD_MS, TSO_LEASE_PATH, CURRENT_TSO_PATH, zkConnection, NAMESPACE));
    Injector injector1 = Guice.createInjector(new TestTSOModule(hbaseConf, config1));
    LOG.info("===================== Starting TSO 1 =====================");
    tso1 = injector1.getInstance(TSOServer.class);
    leaseManager1 = (PausableLeaseManager) injector1.getInstance(LeaseManagement.class);
    tso1.startAndWait();
    TestUtils.waitForSocketListening("localhost", TSO1_PORT, 100);
    LOG.info("================ Finished loading TSO 1 ==================");

    // Configure TSO 2
    TSOServerConfig config2 = new TSOServerConfig();
    config2.setPort(TSO2_PORT);
    config2.setConflictMapSize(1000);
    config2.setLeaseModule(new TestHALeaseManagementModule(TEST_LEASE_PERIOD_MS, TSO_LEASE_PATH, CURRENT_TSO_PATH, zkConnection, NAMESPACE));
    Injector injector2 = Guice.createInjector(new TestTSOModule(hbaseConf, config2));
    LOG.info("===================== Starting TSO 2 =====================");
    tso2 = injector2.getInstance(TSOServer.class);
    injector2.getInstance(LeaseManagement.class);
    tso2.startAndWait();
    // Don't do this here: TestUtils.waitForSocketListening("localhost", 4321, 100);
    LOG.info("================ Finished loading TSO 2 ==================");

    // Wait till the master TSO is up
    barrierTillTSOAddressPublication.await();
    currentTSOZNode.close();

    // Configure HBase TM
    LOG.info("===================== Starting TM =====================");
    HBaseOmidClientConfiguration hbaseOmidClientConf = new HBaseOmidClientConfiguration();
    hbaseOmidClientConf.setConnectionType(HA);
    hbaseOmidClientConf.setConnectionString(zkConnection);
    hbaseOmidClientConf.getOmidClientConfiguration().setZkCurrentTsoPath(CURRENT_TSO_PATH);
    hbaseOmidClientConf.getOmidClientConfiguration().setZkNamespace(NAMESPACE);
    hbaseOmidClientConf.setHBaseConfiguration(hbaseConf);
    hbaseConf.setInt(HBASE_CLIENT_RETRIES_NUMBER, 3);
    tm = HBaseTransactionManager.builder(hbaseOmidClientConf).build();
    LOG.info("===================== TM Started =========================");
}
 
Example #26
Source File: LeaderInitEventHandler.java    From hermes with Apache License 2.0 4 votes vote down vote up
protected void addBaseMetaVersionListener(long version) throws DalException {
	ListenerContainer<NodeCacheListener> listenerContainer = m_baseMetaVersionCache.getListenable();
	listenerContainer.addListener(new BaseMetaVersionListener(version, listenerContainer), m_eventBus.getExecutor());
}
 
Example #27
Source File: LeaderInitEventHandler.java    From hermes with Apache License 2.0 4 votes vote down vote up
protected BaseMetaVersionListener(long version, ListenerContainer<NodeCacheListener> listenerContainer) {
	super(version, listenerContainer);
}
 
Example #28
Source File: FollowerInitEventHandler.java    From hermes with Apache License 2.0 4 votes vote down vote up
protected LeaderMetaVersionListener(long version, ListenerContainer<NodeCacheListener> listenerContainer) {
	super(version, listenerContainer);
}
 
Example #29
Source File: FollowerInitEventHandler.java    From hermes with Apache License 2.0 4 votes vote down vote up
protected BaseMetaVersionListener(long version, ListenerContainer<NodeCacheListener> listenerContainer) {
	super(version, listenerContainer);
}
 
Example #30
Source File: FollowerInitEventHandler.java    From hermes with Apache License 2.0 4 votes vote down vote up
protected void loadAndAddLeaderMetaVersionListener(long version) {
	ListenerContainer<NodeCacheListener> listenerContainer = m_leaderMetaVersionCache.getListenable();
	listenerContainer
	      .addListener(new LeaderMetaVersionListener(version, listenerContainer), m_eventBus.getExecutor());
	loadLeaderMeta(version);
}