@Override public void initializeSecurity(TCredentials credentials, String principal, byte[] token) throws AccumuloSecurityException { try { // remove old settings from zookeeper first, if any IZooReaderWriter zoo = ZooReaderWriter.getInstance(); synchronized (zooCache) { zooCache.clear(); if (zoo.exists(ZKUserPath)) { zoo.recursiveDelete(ZKUserPath, NodeMissingPolicy.SKIP); log.info("Removed " + ZKUserPath + "/" + " from zookeeper"); } // prep parent node of users with root username zoo.putPersistentData(ZKUserPath, principal.getBytes(UTF_8), NodeExistsPolicy.FAIL); constructUser(principal, ZKSecurityTool.createPass(token)); } } catch (KeeperException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } }
@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); } }
private void registerInZooKeeper(String name) throws Exception { String root = ZooUtil.getRoot(serverConfiguration.getInstance()) + Constants.ZTRACERS; IZooReaderWriter zoo = ZooReaderWriter.getInstance(); String path = zoo.putEphemeralSequential(root + "/trace-", name.getBytes()); zoo.exists(path, this); }