private void setUpAcls(String path) throws Exception { List<ACL> acls = createSecureAcls(); LinkedList<String> paths = new LinkedList<>(); paths.add(path); while (!paths.isEmpty()) { String currentPath = paths.poll(); List<String> children = zooKeeperClient.getChildren().forPath(currentPath); if (children != null) { for (String child : children) { paths.add(currentPath + "/" + child); } } zooKeeperClient.setACL().withACL(acls).forPath(currentPath); } }
@Override public void setAcl(final String path, final List<ACL> aclList) throws KeeperException { assertClusterIdFlagTrue(); try { client.setACL().withACL(aclList).forPath(path); } catch (Exception e) { throwIfInstanceOf(e, KeeperException.class); throw new RuntimeException(e); } }
"Current ACL's on the zookeeper root node differ from desired, updating: {} -> {}", curAcls, wantedAcls); client.getCuratorFramework().setACL().withACL(wantedAcls).forPath("/");
@Override public void registerServer(LoadBalanceZookeeperConf configuration, int pqsPort, String zookeeperConnectString, String pqsHost) throws Exception { this.client = CuratorFrameworkFactory.newClient(zookeeperConnectString, new ExponentialBackoffRetry(1000,10)); this.client.start(); HostAndPort hostAndPort = HostAndPort.fromParts(pqsHost,pqsPort); String path = configuration.getFullPathToNode(hostAndPort); String node = hostAndPort.toString(); this.client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(path ,node.getBytes(StandardCharsets.UTF_8)); Stat stat = this.client.setACL().withACL(configuration.getAcls()).forPath(path); if (stat != null) { LOG.info(" node created with right ACL"); } else { LOG.error("could not create node with right ACL. So, system would exit now."); throw new RuntimeException(" Unable to connect to Zookeeper"); } }
private void start() throws Exception{ curaFramework = CuratorFrameworkFactory.newClient(getZkConnectString(), new ExponentialBackoffRetry(1000, 3)); curaFramework.start(); curaFramework.setACL().withACL(CONFIG.getAcls()); connectionStateListener = getConnectionStateListener(); curaFramework.getConnectionStateListenable() .addListener(connectionStateListener); unhandledErrorListener = getUnhandledErrorListener(); curaFramework.getUnhandledErrorListenable() .addListener(unhandledErrorListener); cache = new PathChildrenCache(curaFramework, CONFIG.getParentPath(), true); cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE); closeAbles.add(cache); closeAbles.add(curaFramework); } }
@Override public SetACLBuilder setACL() { return new SetACLBuilderDecorator(inner.setACL()); }
private void checkAndSetACLs(String path) throws Exception { LOGGER.info("Setting acls on " + path); List<String> children = curatorFramework.getChildren().forPath(path); for (String child : children) { checkAndSetACLs(path + "/" + child); } curatorFramework.setACL().withACL(saslACL).forPath(path); }
private void setUpAcls(String path) throws Exception { List<ACL> acls = createSecureAcls(); LinkedList<String> paths = new LinkedList<>(); paths.add(path); while (!paths.isEmpty()) { String currentPath = paths.poll(); List<String> children = zooKeeperClient.getChildren().forPath(currentPath); if (children != null) { for (String child : children) { paths.add(currentPath + "/" + child); } } zooKeeperClient.setACL().withACL(acls).forPath(currentPath); } }
private void checkAndSetACLs(String path) throws Exception { List<String> children = client.getChildren().forPath(path); for (String child : children) { checkAndSetACLs(path + "/" + child); } client.setACL().withACL(saslACL).forPath(path); }
private void checkAndSetACLs(String path) throws Exception { List<String> children = client.getChildren().forPath(path); for (String child : children) { checkAndSetACLs(path + "/" + child); } client.setACL().withACL(saslACL).forPath(path); }
public void fenceOthers() throws Exception { LOG.info("Fencing any other Llamas assuming Active role..."); updateZKAuthsIfRequired(); client.setACL().withACL(exclusiveReadAccessACLs).forPath(fencingPath); LOG.info("Done fencing other Llamas."); }
private void fixAclInternal(CuratorFramework curator, String path, boolean recursive) throws Exception { List<ACL> aclList = getAclForPath(path); curator.setACL().withACL(aclList).forPath(path); if (recursive) { for (String child : curator.getChildren().forPath(path)) { fixAclInternal(curator, path.equals("/") ? "/" + child : path + "/" + child, recursive); } } }
private void fixAclInternal(CuratorFramework curator, String path, boolean recursive) throws Exception { List<ACL> aclList = getAclForPath(path); curator.setACL().withACL(aclList).forPath(path); if (recursive) { for (String child : curator.getChildren().forPath(path)) { fixAclInternal(curator, path.equals("/") ? "/" + child : path + "/" + child, recursive); } } }
private void setRootNodeAcls() throws Exception { if (LOG.isDebugEnabled()) { logRootNodeAcls("Before setting ACLs'\n"); } CuratorFramework curatorFramework = zkManager.getCurator(); if (HAUtil.isHAEnabled(getConfig())) { curatorFramework.setACL().withACL(zkRootNodeAcl).forPath(zkRootNodePath); } else { curatorFramework.setACL().withACL(zkAcl).forPath(zkRootNodePath); } if (LOG.isDebugEnabled()) { logRootNodeAcls("After setting ACLs'\n"); } }
@Override public void setACL(String path, List<EntryACL> entryACLs) { // Translate the abstract ACLs into ZooKeeper ACLs List<ACL> delegateACLs = new ArrayList<>(); for (EntryACL entryACL : entryACLs) { String scheme = entryACL.getType(); String id = entryACL.getId(); int permissions = 0; if (entryACL.canWrite()) { permissions = ZooDefs.Perms.ALL; } else if (entryACL.canRead()){ permissions = ZooDefs.Perms.READ; } delegateACLs.add(new ACL(permissions, new Id(scheme, id))); } try { // Set the ACLs for the path delegate.setACL().withACL(delegateACLs).forPath(path); } catch (Exception e) { log.errorSettingEntryACL(path, e); } }