gpt4 book ai didi

org.apache.accumulo.fate.zookeeper.ZooCache.getChildren()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 01:55:31 26 4
gpt4 key购买 nike

本文整理了Java中org.apache.accumulo.fate.zookeeper.ZooCache.getChildren()方法的一些代码示例,展示了ZooCache.getChildren()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooCache.getChildren()方法的具体详情如下:
包路径:org.apache.accumulo.fate.zookeeper.ZooCache
类名称:ZooCache
方法名:getChildren

ZooCache.getChildren介绍

[英]Gets the children of the given node. A watch is established by this call.
[中]获取给定节点的子节点。通过这个呼叫建立了一个手表。

代码示例

代码示例来源:origin: apache/accumulo

@Override
public Set<String> listUsers() {
 return new TreeSet<>(zooCache.getChildren(ZKUserPath));
}

代码示例来源:origin: apache/accumulo

public static byte[] getLockData(ZooCache zc, String path) {
 List<String> children = zc.getChildren(path);
 if (children == null || children.size() == 0) {
  return null;
 }
 children = new ArrayList<>(children);
 Collections.sort(children);
 String lockNode = children.get(0);
 return zc.get(path + "/" + lockNode);
}

代码示例来源:origin: apache/accumulo

public static byte[] getLockData(org.apache.accumulo.fate.zookeeper.ZooCache zc, String path,
  ZcStat stat) {
 List<String> children = zc.getChildren(path);
 if (children == null || children.size() == 0) {
  return null;
 }
 children = new ArrayList<>(children);
 Collections.sort(children);
 String lockNode = children.get(0);
 if (!lockNode.startsWith(LOCK_PREFIX)) {
  throw new RuntimeException("Node " + lockNode + " at " + path + " is not a lock node");
 }
 return zc.get(path + "/" + lockNode, stat);
}

代码示例来源:origin: apache/accumulo

/**
  * Given a zooCache and instanceId, look up the instance name.
  */
 public static String lookupInstanceName(ZooCache zooCache, UUID instanceId) {
  checkArgument(zooCache != null, "zooCache is null");
  checkArgument(instanceId != null, "instanceId is null");
  for (String name : zooCache.getChildren(Constants.ZROOT + Constants.ZINSTANCES)) {
   String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
   byte[] bytes = zooCache.get(instanceNamePath);
   UUID iid = UUID.fromString(new String(bytes, UTF_8));
   if (iid.equals(instanceId)) {
    return name;
   }
  }
  return null;
 }
}

代码示例来源:origin: apache/accumulo

public static boolean isLockHeld(ZooCache zc, LockID lid) {
 List<String> children = zc.getChildren(lid.path);
 if (children == null || children.size() == 0) {
  return false;
 }
 children = new ArrayList<>(children);
 Collections.sort(children);
 String lockNode = children.get(0);
 if (!lid.node.equals(lockNode))
  return false;
 ZcStat stat = new ZcStat();
 return zc.get(lid.path + "/" + lid.node, stat) != null && stat.getEphemeralOwner() == lid.eid;
}

代码示例来源:origin: apache/accumulo

@Override
public List<String> getTabletServers() {
 ZooCache cache = context.getZooCache();
 String path = context.getZooKeeperRoot() + Constants.ZTSERVERS;
 List<String> results = new ArrayList<>();
 for (String candidate : cache.getChildren(path)) {
  List<String> children = cache.getChildren(path + "/" + candidate);
  if (children != null && children.size() > 0) {
   List<String> copy = new ArrayList<>(children);
   Collections.sort(copy);
   byte[] data = cache.get(path + "/" + candidate + "/" + copy.get(0));
   if (data != null && !"master".equals(new String(data, UTF_8))) {
    results.add(candidate);
   }
  }
 }
 return results;
}

代码示例来源:origin: apache/accumulo

@Override
public void getProperties(Map<String,String> props, Predicate<String> filter) {
 parent.getProperties(props, filter);
 List<String> children = propCache.getChildren(propPathPrefix);
 if (children != null) {
  for (String child : children) {
   if (child != null && filter.test(child)) {
    String value = getRaw(child);
    if (value != null)
     props.put(child, value);
   }
  }
 }
}

代码示例来源:origin: apache/accumulo

public static long getSessionId(ZooCache zc, String path) {
 List<String> children = zc.getChildren(path);
 if (children == null || children.size() == 0) {
  return 0;
 }
 children = new ArrayList<>(children);
 Collections.sort(children);
 String lockNode = children.get(0);
 ZcStat stat = new ZcStat();
 if (zc.get(path + "/" + lockNode, stat) != null)
  return stat.getEphemeralOwner();
 return 0;
}

代码示例来源:origin: apache/accumulo

public synchronized void scanServers() {
 try {
  final Set<TServerInstance> updates = new HashSet<>();
  final Set<TServerInstance> doomed = new HashSet<>();
  final String path = context.getZooKeeperRoot() + Constants.ZTSERVERS;
  HashSet<String> all = new HashSet<>(current.keySet());
  all.addAll(getZooCache().getChildren(path));
  locklessServers.keySet().retainAll(all);
  for (String zPath : all) {
   checkServer(updates, doomed, path, zPath);
  }
  // log.debug("Current: " + current.keySet());
  this.cback.update(this, doomed, updates);
 } catch (Exception ex) {
  log.error("{}", ex.getMessage(), ex);
 }
}

代码示例来源:origin: apache/accumulo

@Override
public List<String> getChildren(String path) throws DistributedStoreException {
 try {
  return cache.getChildren(relative(path));
 } catch (Exception ex) {
  throw new DistributedStoreException(ex);
 }
}

代码示例来源:origin: apache/accumulo

public static boolean exists(ClientContext context, Namespace.ID namespaceId) {
 ZooCache zc = context.getZooCache();
 List<String> namespaceIds = zc.getChildren(context.getZooKeeperRoot() + Constants.ZNAMESPACES);
 return namespaceIds.contains(namespaceId.canonicalID());
}

代码示例来源:origin: apache/accumulo

public static boolean exists(ClientContext context, Table.ID tableId) {
 ZooCache zc = getZooCache(context);
 List<String> tableIds = zc.getChildren(context.getZooKeeperRoot() + Constants.ZTABLES);
 return tableIds.contains(tableId.canonicalID());
}

代码示例来源:origin: apache/accumulo

parent.getProperties(props, parentFilter != null ? parentFilter : filter);
List<String> children = propCache.getChildren(path);
if (children != null) {
 for (String child : children) {

代码示例来源:origin: apache/accumulo

@Override
public void cleanTablePermissions(String table) throws AccumuloSecurityException {
 try {
  synchronized (zooCache) {
   zooCache.clear();
   for (String user : zooCache.getChildren(ZKUserPath))
    zoo.recursiveDelete(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table,
      NodeMissingPolicy.SKIP);
  }
 } catch (KeeperException e) {
  log.error("{}", e.getMessage(), e);
  throw new AccumuloSecurityException("unknownUser", SecurityErrorCode.CONNECTION_ERROR, e);
 } catch (InterruptedException e) {
  log.error("{}", e.getMessage(), e);
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: apache/accumulo

@Override
public void cleanNamespacePermissions(String namespace) throws AccumuloSecurityException {
 try {
  synchronized (zooCache) {
   zooCache.clear();
   for (String user : zooCache.getChildren(ZKUserPath))
    zoo.recursiveDelete(ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace,
      NodeMissingPolicy.SKIP);
  }
 } catch (KeeperException e) {
  log.error("{}", e.getMessage(), e);
  throw new AccumuloSecurityException("unknownUser", SecurityErrorCode.CONNECTION_ERROR, e);
 } catch (InterruptedException e) {
  log.error("{}", e.getMessage(), e);
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: apache/accumulo

private void updateTableStateCache() {
 synchronized (tableStateCache) {
  for (String tableId : zooStateCache.getChildren(zkRoot + Constants.ZTABLES))
   if (zooStateCache
     .get(zkRoot + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE) != null)
    updateTableStateCache(Table.ID.of(tableId));
 }
}

代码示例来源:origin: apache/accumulo

/**
 * Gets all the namespaces from ZK. The first arg (t) the BiConsumer accepts is the ID and the
 * second (u) is the namespaceName.
 */
private static void getAllNamespaces(ClientContext context,
  BiConsumer<String,String> biConsumer) {
 final ZooCache zc = context.getZooCache();
 List<String> namespaceIds = zc.getChildren(context.getZooKeeperRoot() + Constants.ZNAMESPACES);
 for (String id : namespaceIds) {
  byte[] path = zc.get(context.getZooKeeperRoot() + Constants.ZNAMESPACES + "/" + id
    + Constants.ZNAMESPACE_NAME);
  if (path != null) {
   biConsumer.accept(id, new String(path, UTF_8));
  }
 }
}

代码示例来源:origin: apache/accumulo

public TableMap(ClientContext context, ZooCache zooCache) {
 List<String> tableIds = zooCache.getChildren(context.getZooKeeperRoot() + Constants.ZTABLES);
 Map<Namespace.ID,String> namespaceIdToNameMap = new HashMap<>();
 ImmutableMap.Builder<String,Table.ID> tableNameToIdBuilder = new ImmutableMap.Builder<>();

代码示例来源:origin: apache/accumulo

for (String tserver : zc.getChildren(context.getZooKeeperRoot() + Constants.ZTSERVERS)) {
 String path = context.getZooKeeperRoot() + Constants.ZTSERVERS + "/" + tserver;
 byte[] data = ZooUtil.getLockData(zc, path);

代码示例来源:origin: org.apache.accumulo/accumulo-fate

public static byte[] getLockData(ZooCache zc, String path) {
 List<String> children = zc.getChildren(path);
 if (children == null || children.size() == 0) {
  return null;
 }
 children = new ArrayList<>(children);
 Collections.sort(children);
 String lockNode = children.get(0);
 return zc.get(path + "/" + lockNode);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com