Пример #1
0
 /**
  * sync getChildNames
  *
  * @return null if parentPath doesn't exist
  */
 @Override
 public List<String> getChildNames(String parentPath, int options) {
   try {
     List<String> childNames = _zkClient.getChildren(parentPath);
     Collections.sort(childNames);
     return childNames;
   } catch (ZkNoNodeException e) {
     return null;
   }
 }
Пример #2
0
  @SuppressWarnings("unchecked")
  private Element<T> getFirstElement() {
    try {
      while (true) {
        List<String> list = _zkClient.getChildren(_root);
        if (list.size() == 0) {
          return null;
        }
        String elementName = getSmallestElement(list);

        try {
          return new Element<T>(
              _root + "/" + elementName, (T) _zkClient.readData(_root + "/" + elementName));
        } catch (ZkNoNodeException e) {
          // somebody else picked up the element first, so we have to
          // retry with the new first element
        }
      }
    } catch (Exception e) {
      throw ExceptionUtil.convertToRuntimeException(e);
    }
  }
Пример #3
0
 public boolean isEmpty() {
   return _zkClient.getChildren(_root).size() == 0;
 }