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

x33g5p2x  于2022-02-05 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(76)

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

ZooCache.clear介绍

暂无

代码示例

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

@Override
protected void finalize() {
 if (zooCache != null)
  zooCache.clear();
}

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

protected void finalize() {
 if (zooCache != null)
  zooCache.clear();
}

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

private void createUserNodeInZk(String principal) throws KeeperException, InterruptedException {
 synchronized (zooCache) {
  zooCache.clear();
  IZooReaderWriter zoo = ZooReaderWriter.getInstance();
  zoo.putPrivatePersistentData(zkUserPath + "/" + principal, new byte[0],
    NodeExistsPolicy.FAIL);
 }
}

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

/**
 * Sets up the user in ZK for the provided user. No checking for existence is done here, it should
 * be done before calling.
 */
private void constructUser(String user, byte[] pass)
  throws KeeperException, InterruptedException {
 synchronized (zooCache) {
  zooCache.clear();
  IZooReaderWriter zoo = ZooReaderWriter.getInstance();
  zoo.putPrivatePersistentData(ZKUserPath + "/" + user, pass, NodeExistsPolicy.FAIL);
 }
}

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

/**
 * Sets up the user in ZK for the provided user. No checking for existence is done here, it should be done before calling.
 */
private void constructUser(String user, byte[] pass) throws KeeperException, InterruptedException {
 synchronized (zooCache) {
  zooCache.clear();
  IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
  zoo.putPrivatePersistentData(ZKUserPath + "/" + user, pass, NodeExistsPolicy.FAIL);
 }
}

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

@Override
public void put(String path, byte[] bs) throws DistributedStoreException {
 try {
  path = relative(path);
  ZooReaderWriter.getInstance().putPersistentData(path, bs, NodeExistsPolicy.OVERWRITE);
  cache.clear();
  log.debug("Wrote " + new String(bs, UTF_8) + " to " + path);
 } catch (Exception ex) {
  throw new DistributedStoreException(ex);
 }
}

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

@Override
public void put(String path, byte[] bs) throws DistributedStoreException {
 try {
  path = relative(path);
  ZooReaderWriter.getInstance().putPersistentData(path, bs, NodeExistsPolicy.OVERWRITE);
  cache.clear();
  log.debug("Wrote " + new String(bs, UTF_8) + " to " + path);
 } catch (Exception ex) {
  throw new DistributedStoreException(ex);
 }
}

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

@Override
public void changeAuthorizations(String user, Authorizations authorizations) throws AccumuloSecurityException {
 try {
  synchronized (zooCache) {
   zooCache.clear();
   ZooReaderWriter.getRetryingInstance().putPersistentData(ZKUserPath + "/" + user + ZKUserAuths, ZKSecurityTool.convertAuthorizations(authorizations),
     NodeExistsPolicy.OVERWRITE);
  }
 } catch (KeeperException e) {
  log.error(e, e);
  throw new AccumuloSecurityException(user, SecurityErrorCode.CONNECTION_ERROR, e);
 } catch (InterruptedException e) {
  log.error(e, e);
  throw new RuntimeException(e);
 }
}

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

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

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

@Override
public void changeAuthorizations(String user, Authorizations authorizations)
  throws AccumuloSecurityException {
 try {
  synchronized (zooCache) {
   zooCache.clear();
   ZooReaderWriter.getInstance().putPersistentData(ZKUserPath + "/" + user + ZKUserAuths,
     ZKSecurityTool.convertAuthorizations(authorizations), 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: org.apache.accumulo/accumulo-server

/**
 * Sets up a new table configuration for the provided user/table. No checking for existence is done here, it should be done before calling.
 */
private void createTablePerm(String user, String table, Set<TablePermission> perms) throws KeeperException, InterruptedException {
 synchronized (zooCache) {
  zooCache.clear();
  ZooReaderWriter.getRetryingInstance().putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table,
    ZKSecurityTool.convertTablePermissions(perms), NodeExistsPolicy.FAIL);
 }
}

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

/**
 * Sets up a new table configuration for the provided user/table. No checking for existence is
 * done here, it should be done before calling.
 */
private void createTablePerm(String user, String table, Set<TablePermission> perms)
  throws KeeperException, InterruptedException {
 synchronized (zooCache) {
  zooCache.clear();
  ZooReaderWriter.getInstance().putPersistentData(
    ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table,
    ZKSecurityTool.convertTablePermissions(perms), NodeExistsPolicy.FAIL);
 }
}

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

/**
 * Sets up a new namespace configuration for the provided user/table. No checking for existence is
 * done here, it should be done before calling.
 */
private void createNamespacePerm(String user, String namespace, Set<NamespacePermission> perms)
  throws KeeperException, InterruptedException {
 synchronized (zooCache) {
  zooCache.clear();
  ZooReaderWriter.getInstance().putPersistentData(
    ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace,
    ZKSecurityTool.convertNamespacePermissions(perms), NodeExistsPolicy.FAIL);
 }
}

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

@Override
public void dropUser(String user) throws AccumuloSecurityException {
 try {
  synchronized (zooCache) {
   IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
   zoo.recursiveDelete(ZKUserPath + "/" + user + ZKUserAuths, NodeMissingPolicy.SKIP);
   zooCache.clear(ZKUserPath + "/" + user);
  }
 } catch (InterruptedException e) {
  log.error(e, e);
  throw new RuntimeException(e);
 } catch (KeeperException e) {
  log.error(e, e);
  if (e.code().equals(KeeperException.Code.NONODE))
   throw new AccumuloSecurityException(user, SecurityErrorCode.USER_DOESNT_EXIST, e);
  throw new AccumuloSecurityException(user, SecurityErrorCode.CONNECTION_ERROR, e);
 }
}

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

@Override
public void dropUser(String user) throws AccumuloSecurityException {
 try {
  synchronized (zooCache) {
   zooCache.clear();
   ZooReaderWriter.getRetryingInstance().recursiveDelete(ZKUserPath + "/" + user, NodeMissingPolicy.FAIL);
  }
 } catch (InterruptedException e) {
  log.error(e, e);
  throw new RuntimeException(e);
 } catch (KeeperException e) {
  if (e.code().equals(KeeperException.Code.NONODE))
   throw new AccumuloSecurityException(user, SecurityErrorCode.USER_DOESNT_EXIST, e);
  log.error(e, e);
  throw new AccumuloSecurityException(user, SecurityErrorCode.CONNECTION_ERROR, e);
 }
}

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

public synchronized void remove(TServerInstance server) {
  current.remove(server.hostPort());

  log.info("Removing zookeeper lock for " + server);
  String zpath = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + server.hostPort();
  try {
   ZooReaderWriter.getRetryingInstance().recursiveDelete(zpath, SKIP);
  } catch (Exception e) {
   String msg = "error removing tablet server lock";
   log.fatal(msg, e);
   Halt.halt(msg, -1);
  }
  getZooCache().clear(zpath);
 }
}

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

@Override
 public void remove(String path) throws DistributedStoreException {
  try {
   log.debug("Removing " + path);
   path = relative(path);
   IZooReaderWriter zoo = ZooReaderWriter.getInstance();
   if (zoo.exists(path))
    zoo.recursiveDelete(path, NodeMissingPolicy.SKIP);
   cache.clear();
  } catch (Exception ex) {
   throw new DistributedStoreException(ex);
  }
 }
}

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

@Override
 public void remove(String path) throws DistributedStoreException {
  try {
   log.debug("Removing " + path);
   path = relative(path);
   IZooReaderWriter zoo = ZooReaderWriter.getInstance();
   if (zoo.exists(path))
    zoo.recursiveDelete(path, NodeMissingPolicy.SKIP);
   cache.clear();
  } catch (Exception ex) {
   throw new DistributedStoreException(ex);
  }
 }
}

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

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

@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;
}

相关文章