Java Code Examples for org.apache.curator.framework.recipes.cache.TreeCache#getCurrentChildren()
The following examples show how to use
org.apache.curator.framework.recipes.cache.TreeCache#getCurrentChildren() .
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: ZKUtils.java From kafka-graphs with Apache License 2.0 | 6 votes |
public static PregelState maybeCreateReadyToReceiveNode( CuratorFramework curator, String id, PregelState pregelState, TreeCache treeCache) throws Exception { if (pregelState.superstep() < 0) { return pregelState.next(); } String barrierPath = barrierPath(id, pregelState); Map<String, ChildData> children = treeCache.getCurrentChildren(barrierPath); if (children == null) { return pregelState; } int childrenSize = children.size(); if (children.containsKey(READY)) childrenSize--; if (childrenSize == 0) { addReady(curator, id, pregelState); return pregelState.next(); } return pregelState; }
Example 2
Source File: ZKUtils.java From kafka-graphs with Apache License 2.0 | 5 votes |
public static PregelState maybeCreateReadyToSendNode( CuratorFramework curator, String id, PregelState pregelState, TreeCache treeCache, int groupSize) throws Exception { if (pregelState.superstep() < 0) { return pregelState.next(); } String barrierPath = barrierPath(id, pregelState); Map<String, ChildData> children = treeCache.getCurrentChildren(barrierPath); if (children == null) { return pregelState; } int childrenSize = children.size(); if (children.containsKey(READY)) childrenSize--; if (childrenSize == groupSize) { String nextBarrierPath = barrierPath(id, pregelState.next()); Map<String, ChildData> nextChildren = treeCache.getCurrentChildren(nextBarrierPath); if (nextChildren == null) { return pregelState.state(GraphAlgorithmState.State.COMPLETED); } int nextChildrenSize = nextChildren.size(); if (nextChildren.containsKey(READY)) nextChildrenSize--; if (nextChildrenSize == 0) { return pregelState.state(GraphAlgorithmState.State.COMPLETED); } else { // only advance superstep if there is more work to do addReady(curator, id, pregelState); return pregelState.next(); } } return pregelState; }