gpt4 book ai didi

org.apache.accumulo.fate.zookeeper.ZooCache类的使用及代码示例

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

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

ZooCache介绍

[英]A cache for values stored in ZooKeeper. Values are kept up to date as they change.
[中]存储在ZooKeeper中的值的缓存。值在更改时保持最新。

代码示例

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

public ZooLock(ZooReaderWriter zoo, String path) {
 this(new ZooCache(zoo), zoo, path);
}

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

@Override
public void invalidateCache() {
 if (propCache != null)
  propCache.clear();
}

代码示例来源: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 boolean authenticateUser(String principal, AuthenticationToken token)
  throws AccumuloSecurityException {
 if (!(token instanceof PasswordToken))
  throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN);
 PasswordToken pt = (PasswordToken) token;
 byte[] pass;
 String zpath = ZKUserPath + "/" + principal;
 pass = zooCache.get(zpath);
 boolean result = ZKSecurityTool.checkPass(pt.getPassword(), pass);
 if (!result) {
  zooCache.clear(zpath);
  pass = zooCache.get(zpath);
  result = ZKSecurityTool.checkPass(pt.getPassword(), pass);
 }
 return result;
}

代码示例来源: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: org.apache.accumulo/accumulo-test

ZooCache zcache = new ZooCache(instance.getZooKeepers(),
  instance.getZooKeepersSessionTimeOut());
zcache.clear();
String path = ZooUtil.getRoot(instance) + Constants.ZGC_LOCK;
byte[] gcLockData;

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

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

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

if (status != null) {
  zstat = lic.statCache.get(zPath);
  copyStats(status, zstat);
 copyStats(status, zstat);
 return data;
} finally {

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

@Override
public void grantTablePermission(String user, String table, TablePermission permission)
  throws AccumuloSecurityException {
 Set<TablePermission> tablePerms;
 byte[] serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
 if (serializedPerms != null)
  tablePerms = ZKSecurityTool.convertTablePermissions(serializedPerms);
 else
  tablePerms = new TreeSet<>();
 try {
  if (tablePerms.add(permission)) {
   synchronized (zooCache) {
    zooCache.clear(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
    zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table,
      ZKSecurityTool.convertTablePermissions(tablePerms), NodeExistsPolicy.OVERWRITE);
   }
  }
 } catch (KeeperException e) {
  log.error("{}", e.getMessage(), e);
  throw new AccumuloSecurityException(user, SecurityErrorCode.CONNECTION_ERROR, e);
 } catch (InterruptedException e) {
  log.error("{}", e.getMessage(), e);
  throw new RuntimeException(e);
 }
}

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

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

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

@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: org.apache.accumulo/accumulo-fate

if (status != null) {
  zstat = lic.statCache.get(zPath);
  copyStats(status, zstat);
 copyStats(status, zstat);
 return data;
} finally {

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

public synchronized ZooCache getZooCache() {
 if (zooCache == null)
  zooCache = new ZooCache(context.getZooReaderWriter(), this);
 return zooCache;
}

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

@Override
public void revokeSystemPermission(String user, SystemPermission permission)
  throws AccumuloSecurityException {
 byte[] sysPermBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
 // User had no system permission, nothing to revoke.
 if (sysPermBytes == null)
  return;
 Set<SystemPermission> sysPerms = ZKSecurityTool.convertSystemPermissions(sysPermBytes);
 try {
  if (sysPerms.remove(permission)) {
   synchronized (zooCache) {
    zooCache.clear();
    zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserSysPerms,
      ZKSecurityTool.convertSystemPermissions(sysPerms), NodeExistsPolicy.OVERWRITE);
   }
  }
 } catch (KeeperException e) {
  log.error("{}", e.getMessage(), e);
  throw new AccumuloSecurityException(user, SecurityErrorCode.CONNECTION_ERROR, e);
 } catch (InterruptedException e) {
  log.error("{}", e.getMessage(), e);
  throw new RuntimeException(e);
 }
}

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

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

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

/**
 * Clears the internal {@link ZooCache}.
 */
void invalidateCache() {
 propCache.clear();
}

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

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