public List<String> list(String path) { path = "/" + path; try { List<String> children; if (_curator.checkExists().forPath(path) == null) { children = new ArrayList<>(); } else { children = _curator.getChildren().forPath(path); } LOG.debug("List [path = {}], [children = {}]", path, children); return children; } catch (Exception e) { throw new RuntimeException(e); } }
private static void verifyAclStrictRecursive(CuratorFramework zk, List<ACL> strictAcl, String path, boolean fixUp) throws Exception { verifyAclStrict(zk, strictAcl, path, fixUp); for (String child : zk.getChildren().forPath(path)) { String newPath = path + ClusterUtils.ZK_SEPERATOR + child; verifyAclStrictRecursive(zk, strictAcl, newPath, fixUp); } }
public static Set<NimbusInfo> getNimbodesWithLatestSequenceNumberOfBlob(CuratorFramework zkClient, String key) throws Exception { List<String> stateInfoList; try { stateInfoList = zkClient.getChildren().forPath("/blobstore/" + key); } catch (KeeperException.NoNodeException e) { // there's a race condition with a delete: blobstore // this should be thrown to the caller to indicate that the key is invalid now throw new WrappedKeyNotFoundException(key); } Set<NimbusInfo> nimbusInfoSet = new HashSet<NimbusInfo>(); int latestSeqNumber = getLatestSequenceNumber(stateInfoList); LOG.debug("getNimbodesWithLatestSequenceNumberOfBlob stateInfo {} version {}", stateInfoList, latestSeqNumber); // Get the nimbodes with the latest version for (String state : stateInfoList) { BlobKeySequenceInfo sequenceInfo = normalizeNimbusHostPortSequenceNumberInfo(state); if (latestSeqNumber == Integer.parseInt(sequenceInfo.getSequenceNumber())) { nimbusInfoSet.add(NimbusInfo.parse(sequenceInfo.getNimbusHostPort())); } } LOG.debug("nimbusInfoList {}", nimbusInfoSet); return nimbusInfoSet; }
private static void verifyParentWithTopoChildrenDeleteDead(CuratorFramework zk, ACL superUserAcl, String path, Map<String, Id> topoToZkCreds, boolean fixUp, int perms) throws Exception { if (zk.checkExists().forPath(path) != null) { verifyAclStrict(zk, Arrays.asList(superUserAcl), path, fixUp); Set<String> possiblyBadIds = new HashSet<>(); for (String topoId : zk.getChildren().forPath(path)) { String childPath = path + ClusterUtils.ZK_SEPERATOR + topoId; if (!topoToZkCreds.containsKey(topoId)) { //Save it to try again later... possiblyBadIds.add(topoId); } else { List<ACL> rwAcl = getTopoAcl(path, topoId, topoToZkCreds, superUserAcl, fixUp, perms); verifyAclStrictRecursive(zk, rwAcl, childPath, fixUp); } } if (!possiblyBadIds.isEmpty()) { //Lets reread the children in STORMS as the source of truth and see if a new one was created in the background possiblyBadIds.removeAll(zk.getChildren().forPath(ClusterUtils.STORMS_SUBTREE)); for (String topoId : possiblyBadIds) { //Now we know for sure that this is a bad id String childPath = path + ClusterUtils.ZK_SEPERATOR + topoId; zk.delete().deletingChildrenIfNeeded().forPath(childPath); } } } }
private static void verifyParentWithTopoChildren(CuratorFramework zk, ACL superUserAcl, String path, Map<String, Id> topoToZkCreds, boolean fixUp, int perms) throws Exception { if (zk.checkExists().forPath(path) != null) { verifyAclStrict(zk, Arrays.asList(superUserAcl), path, fixUp); for (String topoId : zk.getChildren().forPath(path)) { String childPath = path + ClusterUtils.ZK_SEPERATOR + topoId; List<ACL> rwAcl = getTopoAcl(path, topoId, topoToZkCreds, superUserAcl, fixUp, perms); verifyAclStrictRecursive(zk, rwAcl, childPath, fixUp); } } }
return; stateInfo = zkClient.getChildren().forPath(BLOBSTORE_SUBTREE + "/" + key); if (CollectionUtils.isEmpty(stateInfo)) { return;
public static List<String> getChildren(CuratorFramework zk, String path, boolean watch) { try { String npath = normalizePath(path); if (watch) { return zk.getChildren().watched().forPath(npath); } else { return zk.getChildren().forPath(npath); } } catch (Exception e) { throw Utils.wrapInRuntime(e); } }
@Override public int getBlobReplication(String key, Subject who) throws Exception { int replicationCount = 0; validateKey(key); SettableBlobMeta meta = getStoredBlobMeta(key); _aclHandler.hasPermissions(meta.get_acl(), READ, who, key); if (zkClient.checkExists().forPath(BLOBSTORE_SUBTREE + key) == null) { return 0; } try { replicationCount = zkClient.getChildren().forPath(BLOBSTORE_SUBTREE + key).size(); } catch (KeeperException.NoNodeException e) { //Race with delete //If it is not here the replication is 0 } return replicationCount; }
List<String> stateInfoList = zkClient.getChildren().forPath(BlobStoreUtils.getBlobStoreSubtree() + "/" + key); LOG.debug("stateInfoList-size {} stateInfoList-data {}", stateInfoList.size(), stateInfoList); if (stateInfoList.isEmpty()) {
topoIds.addAll(zk.getChildren().forPath(ClusterUtils.STORMS_SUBTREE));
public List<String> list(String path) { path = "/" + path; try { if(_curator.checkExists().forPath(path)==null) { return new ArrayList<String>(); } else { return _curator.getChildren().forPath(path); } } catch(Exception e) { throw new RuntimeException(e); } }
public List<String> list(String path) { path = "/" + path; try { List<String> children; if(_curator.checkExists().forPath(path)==null) { children = new ArrayList<>(); } else { children = _curator.getChildren().forPath(path); } LOG.debug("List [path = {}], [children = {}]", path, children); return children; } catch(Exception e) { throw new RuntimeException(e); } }
private static void verifyAclStrictRecursive(CuratorFramework zk, List<ACL> strictAcl, String path, boolean fixUp) throws Exception { verifyAclStrict(zk, strictAcl, path, fixUp); for (String child: zk.getChildren().forPath(path)) { String newPath = path + ClusterUtils.ZK_SEPERATOR + child; verifyAclStrictRecursive(zk, strictAcl, newPath, fixUp); } }
private static void verifyParentWithTopoChildrenDeleteDead(CuratorFramework zk, ACL superUserAcl, String path, Map<String, Id> topoToZkCreds, boolean fixUp, int perms) throws Exception { if (zk.checkExists().forPath(path) != null) { verifyAclStrict(zk, Arrays.asList(superUserAcl), path, fixUp); Set<String> possiblyBadIds = new HashSet<>(); for (String topoId : zk.getChildren().forPath(path)) { String childPath = path + ClusterUtils.ZK_SEPERATOR + topoId; if (!topoToZkCreds.containsKey(topoId)) { //Save it to try again later... possiblyBadIds.add(topoId); } else { List<ACL> rwAcl = getTopoAcl(path, topoId, topoToZkCreds, superUserAcl, fixUp, perms); verifyAclStrictRecursive(zk, rwAcl, childPath, fixUp); } } if (!possiblyBadIds.isEmpty()) { //Lets reread the children in STORMS as the source of truth and see if a new one was created in the background possiblyBadIds.removeAll(zk.getChildren().forPath(ClusterUtils.STORMS_SUBTREE)); for (String topoId: possiblyBadIds) { //Now we know for sure that this is a bad id String childPath = path + ClusterUtils.ZK_SEPERATOR + topoId; zk.delete().deletingChildrenIfNeeded().forPath(childPath); } } } }
public static Set<NimbusInfo> getNimbodesWithLatestSequenceNumberOfBlob(CuratorFramework zkClient, String key) throws Exception { List<String> stateInfoList; try { stateInfoList = zkClient.getChildren().forPath("/blobstore/" + key); } catch (KeeperException.NoNodeException e) { // there's a race condition with a delete: blobstore // this should be thrown to the caller to indicate that the key is invalid now throw new KeyNotFoundException(key); } Set<NimbusInfo> nimbusInfoSet = new HashSet<NimbusInfo>(); int latestSeqNumber = getLatestSequenceNumber(stateInfoList); LOG.debug("getNimbodesWithLatestSequenceNumberOfBlob stateInfo {} version {}", stateInfoList, latestSeqNumber); // Get the nimbodes with the latest version for(String state : stateInfoList) { BlobKeySequenceInfo sequenceInfo = normalizeNimbusHostPortSequenceNumberInfo(state); if (latestSeqNumber == Integer.parseInt(sequenceInfo.getSequenceNumber())) { nimbusInfoSet.add(NimbusInfo.parse(sequenceInfo.getNimbusHostPort())); } } LOG.debug("nimbusInfoList {}", nimbusInfoSet); return nimbusInfoSet; }
private static void verifyParentWithTopoChildren(CuratorFramework zk, ACL superUserAcl, String path, Map<String, Id> topoToZkCreds, boolean fixUp, int perms) throws Exception { if (zk.checkExists().forPath(path) != null) { verifyAclStrict(zk, Arrays.asList(superUserAcl), path, fixUp); for (String topoId : zk.getChildren().forPath(path)) { String childPath = path + ClusterUtils.ZK_SEPERATOR + topoId; List<ACL> rwAcl = getTopoAcl(path, topoId, topoToZkCreds, superUserAcl, fixUp, perms); verifyAclStrictRecursive(zk, rwAcl, childPath, fixUp); } } }
@Override public int getBlobReplication(String key, Subject who) throws Exception { int replicationCount = 0; validateKey(key); SettableBlobMeta meta = getStoredBlobMeta(key); _aclHandler.hasPermissions(meta.get_acl(), READ, who, key); if (zkClient.checkExists().forPath(BLOBSTORE_SUBTREE + key) == null) { return 0; } replicationCount = zkClient.getChildren().forPath(BLOBSTORE_SUBTREE + key).size(); return replicationCount; }
public static List<String> getChildren(CuratorFramework zk, String path, boolean watch) { try { String npath = normalizePath(path); if (watch) { return zk.getChildren().watched().forPath(npath); } else { return zk.getChildren().forPath(npath); } } catch (Exception e) { throw Utils.wrapInRuntime(e); } }
return; stateInfo = zkClient.getChildren().forPath(BLOBSTORE_SUBTREE + "/" + key); if (CollectionUtils.isEmpty(stateInfo)) { return;
List<String> stateInfoList = zkClient.getChildren().forPath(BlobStoreUtils.getBlobStoreSubtree() + "/" + key); LOG.debug("stateInfoList-size {} stateInfoList-data {}", stateInfoList.size(), stateInfoList); if (stateInfoList.isEmpty()) {