Search in sources :

Example 86 with Stat

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project lightconf by haifeiWu.

the class XxlConfZkClient method getPathDataByKey.

/**
 * get data from node
 * @param key
 * @return
 */
public static String getPathDataByKey(String key) {
    String path = keyToPath(key);
    try {
        Stat stat = getInstance().exists(path, true);
        if (stat != null) {
            String znodeValue = null;
            byte[] resultData = getInstance().getData(path, true, null);
            if (resultData != null) {
                znodeValue = new String(resultData);
            }
            return znodeValue;
        } else {
            logger.info(">>>>>>>>>> xxl conf, znodeKey[{}] not found.", key);
        }
    } catch (KeeperException e) {
        logger.error(e.getMessage(), e);
    } catch (InterruptedException e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}
Also used : Stat(org.apache.zookeeper.data.Stat)

Example 87 with Stat

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project fabric8 by jboss-fuse.

the class ZooKeeperGroup method internalRebuildNode.

private void internalRebuildNode(String fullPath) throws Exception {
    try {
        Stat stat = new Stat();
        byte[] bytes = client.getData().storingStatIn(stat).forPath(fullPath);
        currentData.put(fullPath, new ChildData<T>(fullPath, stat, bytes, decode(bytes)));
    } catch (KeeperException.NoNodeException ignore) {
        // node no longer exists - remove it
        currentData.remove(fullPath);
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat) KeeperException(org.apache.zookeeper.KeeperException)

Example 88 with Stat

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project fabric8 by jboss-fuse.

the class ZooKeeperGroupTest method putChildData.

private static void putChildData(ZooKeeperGroup<NodeState> group, String path, String container) throws Exception {
    NodeState node = new NodeState("test", container);
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).writeValue(data, node);
    ChildData<NodeState> child = new ChildData<>(path, new Stat(), data.toByteArray(), node);
    group.currentData.put(path, child);
}
Also used : NodeState(io.fabric8.groups.NodeState) Stat(org.apache.zookeeper.data.Stat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 89 with Stat

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project fabric8 by jboss-fuse.

the class TreeCacheExtended method getDataAndStat.

void getDataAndStat(final String fullPath) throws Exception {
    if (client.checkExists().forPath(fullPath) == null) {
        return;
    }
    final List<String> children = client.getChildren().usingWatcher(watcher).forPath(fullPath);
    if (cacheData) {
        Stat stat = new Stat();
        byte[] data = null;
        if (dataIsCompressed) {
            data = client.getData().decompressed().storingStatIn(stat).usingWatcher(watcher).forPath(fullPath);
        } else {
            data = client.getData().storingStatIn(stat).usingWatcher(watcher).forPath(fullPath);
        }
        applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, data, children);
    } else {
        Stat stat = client.checkExists().usingWatcher(watcher).forPath(fullPath);
        applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, null, children);
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat)

Example 90 with Stat

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project fabric8 by jboss-fuse.

the class NodeCacheExtended method internalRebuild.

private void internalRebuild() throws Exception {
    try {
        Stat stat = new Stat();
        byte[] bytes = dataIsCompressed ? client.getData().decompressed().storingStatIn(stat).forPath(path) : client.getData().storingStatIn(stat).forPath(path);
        data.set(new ChildData(path, stat, bytes));
    } catch (KeeperException.NoNodeException e) {
        data.set(null);
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

Stat (org.apache.zookeeper.data.Stat)799 KeeperException (org.apache.zookeeper.KeeperException)266 Test (org.junit.Test)124 IOException (java.io.IOException)120 ZooKeeper (org.apache.zookeeper.ZooKeeper)88 ArrayList (java.util.ArrayList)67 Test (org.testng.annotations.Test)58 Test (org.junit.jupiter.api.Test)53 Watcher (org.apache.zookeeper.Watcher)49 AsyncCallback (org.apache.zookeeper.AsyncCallback)48 ACL (org.apache.zookeeper.data.ACL)47 List (java.util.List)43 CountDownLatch (java.util.concurrent.CountDownLatch)43 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)39 WatchedEvent (org.apache.zookeeper.WatchedEvent)38 CuratorFramework (org.apache.curator.framework.CuratorFramework)37 Map (java.util.Map)34 HashMap (java.util.HashMap)32 WebApplicationException (javax.ws.rs.WebApplicationException)29 ExecutionException (java.util.concurrent.ExecutionException)27