本文整理了Java中org.apache.accumulo.fate.zookeeper.ZooReaderWriter.putPersistentData()
方法的一些代码示例,展示了ZooReaderWriter.putPersistentData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooReaderWriter.putPersistentData()
方法的具体详情如下:
包路径:org.apache.accumulo.fate.zookeeper.ZooReaderWriter
类名称:ZooReaderWriter
方法名:putPersistentData
暂无
代码示例来源:origin: apache/accumulo
public void post(String server, String cause) {
try {
zoo.putPersistentData(path + "/" + server, cause.getBytes(UTF_8), NodeExistsPolicy.SKIP);
} catch (Exception ex) {
log.error("post failed with exception", ex);
}
}
}
代码示例来源:origin: apache/accumulo
public static boolean setTableProperty(ZooReaderWriter zoo, String zkRoot, Table.ID tableId,
String property, String value) throws KeeperException, InterruptedException {
if (!isPropertyValid(property, value))
return false;
// create the zk node for per-table properties for this table if it doesn't already exist
String zkTablePath = getTablePath(zkRoot, tableId);
zoo.putPersistentData(zkTablePath, new byte[0], NodeExistsPolicy.SKIP);
// create the zk node for this property and set it's data to the specified value
String zPath = zkTablePath + "/" + property;
zoo.putPersistentData(zPath, value.getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
return true;
}
代码示例来源:origin: apache/accumulo
public void addWork(String workId, byte[] data) throws KeeperException, InterruptedException {
if (workId.equalsIgnoreCase(LOCKS_NODE))
throw new IllegalArgumentException("locks is reserved work id");
zoo.mkdirs(path);
zoo.putPersistentData(path + "/" + workId, data, NodeExistsPolicy.SKIP);
}
代码示例来源:origin: apache/accumulo
@Override
public void initUser(String user) throws AccumuloSecurityException {
try {
zoo.putPersistentData(ZKUserPath + "/" + user, new byte[0], NodeExistsPolicy.SKIP);
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms, new byte[0],
NodeExistsPolicy.SKIP);
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserNamespacePerms, new byte[0],
NodeExistsPolicy.SKIP);
} 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 void mkdirs(String path) throws KeeperException, InterruptedException {
if (path.equals(""))
return;
if (!path.startsWith("/"))
throw new IllegalArgumentException(path + "does not start with /");
if (exists(path))
return;
String parent = path.substring(0, path.lastIndexOf("/"));
mkdirs(parent);
putPersistentData(path, new byte[] {}, NodeExistsPolicy.SKIP);
}
代码示例来源:origin: apache/accumulo
private void updateState(TServerInstance tsi, Path path, WalState state)
throws WalMarkerException {
byte[] data = (state + "," + path).getBytes(UTF_8);
try {
NodeExistsPolicy policy = NodeExistsPolicy.OVERWRITE;
if (state == WalState.OPEN) {
policy = NodeExistsPolicy.FAIL;
}
log.debug("Setting {} to {}", path.getName(), state);
zoo.putPersistentData(root() + "/" + tsi + "/" + path.getName(), data, policy);
} catch (KeeperException | InterruptedException e) {
throw new WalMarkerException(e);
}
}
代码示例来源:origin: apache/accumulo
public MasterTime(Master master) throws IOException {
this.zPath = master.getZooKeeperRoot() + Constants.ZMASTER_TICK;
this.zk = master.getContext().getZooReaderWriter();
this.master = master;
try {
zk.putPersistentData(zPath, "0".getBytes(UTF_8), NodeExistsPolicy.SKIP);
skewAmount = Long.parseLong(new String(zk.getData(zPath, null), UTF_8)) - System.nanoTime();
} catch (Exception ex) {
throw new IOException("Error updating master time", ex);
}
this.timer = new Timer();
timer.schedule(this, 0, MILLISECONDS.convert(10, SECONDS));
}
代码示例来源:origin: apache/accumulo
/**
* 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, Namespace.ID namespace,
Set<NamespacePermission> perms) throws KeeperException, InterruptedException {
synchronized (zooCache) {
zooCache.clear();
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace,
ZKSecurityTool.convertNamespacePermissions(perms), NodeExistsPolicy.FAIL);
}
}
代码示例来源:origin: apache/accumulo
public void initWalMarker(TServerInstance tsi) throws WalMarkerException {
byte[] data = new byte[0];
try {
zoo.putPersistentData(root() + "/" + tsi, data, NodeExistsPolicy.FAIL);
} catch (KeeperException | InterruptedException e) {
throw new WalMarkerException(e);
}
}
代码示例来源:origin: apache/accumulo
/**
* 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, Table.ID table, Set<TablePermission> perms)
throws KeeperException, InterruptedException {
synchronized (zooCache) {
zooCache.clear();
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table,
ZKSecurityTool.convertTablePermissions(perms), NodeExistsPolicy.FAIL);
}
}
代码示例来源:origin: apache/accumulo
void setMasterGoalState(MasterGoalState state) {
try {
context.getZooReaderWriter().putPersistentData(
getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, state.name().getBytes(),
NodeExistsPolicy.OVERWRITE);
} catch (Exception ex) {
log.error("Unable to set master goal state in zookeeper");
}
}
代码示例来源:origin: apache/accumulo
@Override
public void initializeSecurity(TCredentials itw, String rootuser)
throws AccumuloSecurityException {
ZooReaderWriter zoo = context.getZooReaderWriter();
// create the root user with all system privileges, no table privileges, and no record-level
// authorizations
Set<SystemPermission> rootPerms = new TreeSet<>();
for (SystemPermission p : SystemPermission.values())
rootPerms.add(p);
Map<Table.ID,Set<TablePermission>> tablePerms = new HashMap<>();
// Allow the root user to flush the metadata tables
tablePerms.put(MetadataTable.ID, Collections.singleton(TablePermission.ALTER_TABLE));
tablePerms.put(RootTable.ID, Collections.singleton(TablePermission.ALTER_TABLE));
try {
// prep parent node of users with root username
if (!zoo.exists(ZKUserPath))
zoo.putPersistentData(ZKUserPath, rootuser.getBytes(UTF_8), NodeExistsPolicy.FAIL);
initUser(rootuser);
zoo.putPersistentData(ZKUserPath + "/" + rootuser + ZKUserAuths,
ZKSecurityTool.convertAuthorizations(Authorizations.EMPTY), NodeExistsPolicy.FAIL);
} catch (KeeperException | InterruptedException e) {
log.error("{}", e.getMessage(), e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/accumulo
@Override
public void put(String path, byte[] bs) throws DistributedStoreException {
try {
path = relative(path);
context.getZooReaderWriter().putPersistentData(path, bs, NodeExistsPolicy.OVERWRITE);
cache.clear();
log.debug("Wrote {} to {}", new String(bs, UTF_8), path);
} catch (Exception ex) {
throw new DistributedStoreException(ex);
}
}
代码示例来源:origin: apache/accumulo
@Override
public void changeAuthorizations(String user, Authorizations authorizations)
throws AccumuloSecurityException {
try {
synchronized (zooCache) {
zooCache.clear();
context.getZooReaderWriter().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: apache/accumulo
private String root() throws WalMarkerException {
String root = context.getZooKeeperRoot() + ZWALS;
try {
if (!checkedExistance && !zoo.exists(root)) {
zoo.putPersistentData(root, new byte[0], NodeExistsPolicy.SKIP);
}
checkedExistance = true;
} catch (KeeperException | InterruptedException e) {
throw new WalMarkerException(e);
}
return root;
}
代码示例来源: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
void saveToZooKeeper(ServerContext context)
throws IOException, KeeperException, InterruptedException {
context.getZooReaderWriter().putPersistentData(getZPath(context.getZooKeeperRoot()), encode(),
NodeExistsPolicy.OVERWRITE);
}
代码示例来源:origin: apache/accumulo
/**
* Utility program that will change the goal state for the master from the command line.
*/
public static void main(String[] args) throws Exception {
if (args.length != 1 || MasterGoalState.valueOf(args[0]) == null) {
System.err.println(
"Usage: accumulo " + SetGoalState.class.getName() + " [NORMAL|SAFE_MODE|CLEAN_STOP]");
System.exit(-1);
}
ServerContext context = new ServerContext(new SiteConfiguration());
SecurityUtil.serverLogin(context.getConfiguration());
ServerUtil.waitForZookeeperAndHdfs(context);
context.getZooReaderWriter().putPersistentData(
context.getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(UTF_8),
NodeExistsPolicy.OVERWRITE);
}
代码示例来源:origin: apache/accumulo
@Override
public Repo<Master> call(long tid, Master master) throws Exception {
// suppress assignment of tablets to the server
if (force) {
ZooReaderWriter zoo = master.getContext().getZooReaderWriter();
String path = master.getZooKeeperRoot() + Constants.ZTSERVERS + "/" + server.getLocation();
ZooLock.deleteLock(zoo, path);
path = master.getZooKeeperRoot() + Constants.ZDEADTSERVERS + "/" + server.getLocation();
zoo.putPersistentData(path, "forced down".getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
}
return null;
}
代码示例来源:origin: apache/accumulo
public void setMergeState(MergeInfo info, MergeState state)
throws KeeperException, InterruptedException {
synchronized (mergeLock) {
String path = getZooKeeperRoot() + Constants.ZTABLES + "/" + info.getExtent().getTableId()
+ "/merge";
info.setState(state);
if (state.equals(MergeState.NONE)) {
context.getZooReaderWriter().recursiveDelete(path, NodeMissingPolicy.SKIP);
} else {
DataOutputBuffer out = new DataOutputBuffer();
try {
info.write(out);
} catch (IOException ex) {
throw new RuntimeException("Unlikely", ex);
}
context.getZooReaderWriter().putPersistentData(path, out.getData(),
state.equals(MergeState.STARTED) ? ZooUtil.NodeExistsPolicy.FAIL
: ZooUtil.NodeExistsPolicy.OVERWRITE);
}
mergeLock.notifyAll();
}
nextEvent.event("Merge state of %s set to %s", info.getExtent(), state);
}
内容来源于网络,如有侵权,请联系作者删除!