gpt4 book ai didi

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

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

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

ZooCache.get介绍

[英]Gets data at the given path. Status information is not returned. A watch is established by this call.
[中]获取给定路径上的数据。不会返回状态信息。通过这个呼叫建立了一个手表。

代码示例

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

/**
 * Gets data at the given path. Status information is not returned. A watch is established by this
 * call.
 *
 * @param zPath
 *          path to get
 * @return path data, or null if non-existent
 */
public byte[] get(final String zPath) {
 return get(zPath, null);
}

代码示例来源: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

@Override
public boolean userExists(String user) {
 return zooCache.get(ZKUserPath + "/" + user) != null;
}

代码示例来源: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

private String get(String path) {
 byte[] v = propCache.get(path);
 if (v != null) {
  return new String(v, UTF_8);
 } else {
  return null;
 }
}

代码示例来源: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

public synchronized String getRootUsername() {
 if (rootUserName == null)
  rootUserName = new String(zooCache.get(ZKUserPath), UTF_8);
 return rootUserName;
}

代码示例来源: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

private String getRaw(String key) {
 String zPath = propPathPrefix + "/" + key;
 byte[] v = propCache.get(zPath);
 String value = null;
 if (v != null)
  value = new String(v, UTF_8);
 return value;
}

代码示例来源: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 boolean hasCachedTablePermission(String user, String table, TablePermission permission) {
 byte[] serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
 if (serializedPerms != null) {
  return ZKSecurityTool.convertTablePermissions(serializedPerms).contains(permission);
 }
 return false;
}

代码示例来源: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

@Override
public boolean hasCachedNamespacePermission(String user, String namespace,
  NamespacePermission permission) {
 byte[] serializedPerms = zooCache
   .get(ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace);
 if (serializedPerms != null) {
  return ZKSecurityTool.convertNamespacePermissions(serializedPerms).contains(permission);
 }
 return false;
}

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

@Override
public boolean hasCachedSystemPermission(String user, SystemPermission permission) {
 byte[] perms = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
 if (perms == null)
  return false;
 return ZKSecurityTool.convertSystemPermissions(perms).contains(permission);
}

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

@Override
public Authorizations getCachedUserAuthorizations(String user) {
 byte[] authsBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserAuths);
 if (authsBytes != null)
  return ZKSecurityTool.convertAuthorizations(authsBytes);
 return Authorizations.EMPTY;
}

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

/**
 * Iterate over the queued work to remove entries that have been completed.
 */
@Override
protected void cleanupFinishedWork() {
 final Iterator<String> work = queuedWork.iterator();
 final String instanceId = client.getInstanceID();
 while (work.hasNext()) {
  String filename = work.next();
  // Null equates to the work was finished
  if (zooCache.get(ZooUtil.getRoot(instanceId) + ReplicationConstants.ZOO_WORK_QUEUE + "/"
    + filename) == null) {
   work.remove();
  }
 }
}

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

@Override
public byte[] get(String path) throws DistributedStoreException {
 try {
  return cache.get(relative(path));
 } catch (Exception ex) {
  throw new DistributedStoreException(ex);
 }
}

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

/**
 * Look for namespace name in ZK. Throw NamespaceNotFoundException if not found.
 */
public static String getNamespaceName(ClientContext context, Namespace.ID namespaceId)
  throws NamespaceNotFoundException {
 String name;
 ZooCache zc = context.getZooCache();
 byte[] path = zc.get(context.getZooKeeperRoot() + Constants.ZNAMESPACES + "/"
   + namespaceId.canonicalID() + Constants.ZNAMESPACE_NAME);
 if (path != null)
  name = new String(path, UTF_8);
 else
  throw new NamespaceNotFoundException(namespaceId.canonicalID(), null,
    "getNamespaceName() failed to find namespace");
 return name;
}

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

@Override
 public MonitorLocation get() {
  // lazily set up path and zooCache (see comment in constructor)
  if (this.context == null) {
   this.context = new ServerContext(new SiteConfiguration());
   this.path = context.getZooKeeperRoot() + Constants.ZMONITOR_LOG4J_ADDR;
   this.zooCache = context.getZooCache();
  }
  // get the current location from the cache and update if necessary
  ZcStat stat = new ZcStat();
  byte[] loc = zooCache.get(path, stat);
  // mzxid is 0 if location does not exist and the non-zero transaction id of the last
  // modification otherwise
  return new MonitorLocation(stat.getMzxid(), loc);
 }
}

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