本文整理了Java中org.apache.accumulo.server.zookeeper.ZooCache
类的一些代码示例,展示了ZooCache
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooCache
类的具体详情如下:
包路径:org.apache.accumulo.server.zookeeper.ZooCache
类名称:ZooCache
暂无
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
public synchronized ZooCache getZooCache() {
if (zooCache == null)
zooCache = new ZooCache(this);
return zooCache;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
@Override
protected void finalize() {
if (zooCache != null)
zooCache.clear();
}
代码示例来源:origin: org.apache.accumulo/accumulo-server
/**
* Checks if a user exists
*/
@Override
public boolean userExists(String user) {
return zooCache.get(ZKUserPath + "/" + user) != null;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
private void updateTableStateCache() {
synchronized (tableStateCache) {
for (String tableId : zooStateCache
.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES))
if (zooStateCache.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId
+ Constants.ZTABLE_STATE) != null)
updateTableStateCache(tableId);
}
}
代码示例来源: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
@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
@Override
public Set<String> listUsers() {
return new TreeSet<String>(zooCache.getChildren(ZKUserPath));
}
代码示例来源: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;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
@Override
public void cleanTablePermissions(String table) throws AccumuloSecurityException {
try {
synchronized (zooCache) {
zooCache.clear();
IZooReaderWriter zoo = ZooReaderWriter.getInstance();
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: org.apache.accumulo/accumulo-server
private void updateTableStateCache() {
synchronized (tableStateCache) {
for (String tableId : zooStateCache.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES))
if (zooStateCache.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE) != null)
updateTableStateCache(tableId);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
@Override
public Set<String> listUsers() {
return new TreeSet<>(zooCache.getChildren(ZKUserPath));
}
代码示例来源:origin: org.apache.accumulo/accumulo-server
@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<TablePermission>();
try {
if (tablePerms.add(permission)) {
synchronized (zooCache) {
zooCache.clear(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table, ZKSecurityTool.convertTablePermissions(tablePerms),
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
protected void finalize() {
if (zooCache != null)
zooCache.clear();
}
代码示例来源:origin: org.apache.accumulo/accumulo-server
public synchronized ZooCache getZooCache() {
if (zooCache == null)
zooCache = new ZooCache(this);
return zooCache;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
@Override
public boolean userExists(String user) {
return zooCache.get(ZKUserPath + "/" + user) != null;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
@Override
public void cleanNamespacePermissions(String namespace) throws AccumuloSecurityException {
try {
synchronized (zooCache) {
zooCache.clear();
IZooReaderWriter zoo = ZooReaderWriter.getInstance();
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-server
@Override
public List<String> getChildren(String path) throws DistributedStoreException {
try {
return cache.getChildren(relative(path));
} catch (Exception ex) {
throw new DistributedStoreException(ex);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-server
@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();
ZooReaderWriter.getRetryingInstance().putPersistentData(ZKUserPath + "/" + user + ZKUserSysPerms, ZKSecurityTool.convertSystemPermissions(sysPerms),
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-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
public ZKPermHandler() {
zooCache = new ZooCache();
}
内容来源于网络,如有侵权,请联系作者删除!