Package org.apache.accumulo.fate.zookeeper

Examples of org.apache.accumulo.fate.zookeeper.IZooReaderWriter


  /**
   * @param user
   * @throws AccumuloSecurityException
   */
  public void initUser(String user) throws AccumuloSecurityException {
    IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
    try {
      zoo.putPersistentData(ZKUserPath + "/" + user, new byte[0], NodeExistsPolicy.SKIP);
      zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms, new byte[0], NodeExistsPolicy.SKIP);
    } catch (KeeperException e) {
      log.error(e, e);
      throw new AccumuloSecurityException(user, SecurityErrorCode.CONNECTION_ERROR, e);
    } catch (InterruptedException e) {
      log.error(e, e);
View Full Code Here


 
  @Override
  public void cleanUser(String user) throws AccumuloSecurityException {
    try {
      synchronized (zooCache) {
        IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
        zoo.recursiveDelete(ZKUserPath + "/" + user + ZKUserSysPerms, NodeMissingPolicy.SKIP);
        zoo.recursiveDelete(ZKUserPath + "/" + user + ZKUserTablePerms, NodeMissingPolicy.SKIP);
        zooCache.clear(ZKUserPath + "/" + user);
      }
    } catch (InterruptedException e) {
      log.error(e, e);
      throw new RuntimeException(e);
View Full Code Here

 
  @Override
  public void initializeSecurity(TCredentials credentials, String principal, byte[] token) throws AccumuloSecurityException {
    try {
      // remove old settings from zookeeper first, if any
      IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
      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(), NodeExistsPolicy.FAIL);
       
        constructUser(principal, ZKSecurityTool.createPass(token));
      }
    } catch (KeeperException e) {
      log.error(e, e);
View Full Code Here

   * Sets up the user in ZK for the provided user. No checking for existence is done here, it should be done before calling.
   */
  private void constructUser(String user, byte[] pass) throws KeeperException, InterruptedException {
    synchronized (zooCache) {
      zooCache.clear();
      IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
      zoo.putPrivatePersistentData(ZKUserPath + "/" + user, pass, NodeExistsPolicy.FAIL);
    }
  }
View Full Code Here

  private static final Logger log = Logger.getLogger(DeadServerList.class);
  private final String path;
 
  public DeadServerList(String path) {
    this.path = path;
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    try {
      zoo.mkdirs(path);
    } catch (Exception ex) {
      log.error("Unable to make parent directories of " + path, ex);
    }
  }
View Full Code Here

    }
  }
 
  public List<DeadServer> getList() {
    List<DeadServer> result = new ArrayList<DeadServer>();
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    try {
      List<String> children = zoo.getChildren(path);
      if (children != null) {
        for (String child : children) {
          Stat stat = new Stat();
          byte[] data = zoo.getData(path + "/" + child, stat);
          DeadServer server = new DeadServer(child, stat.getMtime(), new String(data));
          result.add(server);
        }
      }
    } catch (Exception ex) {
View Full Code Here

    }
  }
 
  private static TreeMap<String,UUID> getInstanceNames() {
   
    IZooReaderWriter zk = ZooReaderWriter.getInstance();
    String instancesPath = Constants.ZROOT + Constants.ZINSTANCES;
   
    TreeMap<String,UUID> tm = new TreeMap<String,UUID>();
   
    List<String> names;
   
    try {
      names = zk.getChildren(instancesPath);
    } catch (Exception e) {
      handleException(e);
      return tm;
    }
   
    for (String name : names) {
      String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
      try {
        UUID iid = UUID.fromString(new String(zk.getData(instanceNamePath, null)));
        tm.put(name, iid);
      } catch (Exception e) {
        handleException(e);
        tm.put(name, null);
      }
View Full Code Here

    }
    return result;
  }
 
  public void delete(String server) {
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    try {
      zoo.recursiveDelete(path + "/" + server, NodeMissingPolicy.SKIP);
    } catch (Exception ex) {
      log.error(ex, ex);
    }
  }
View Full Code Here

      log.error(ex, ex);
    }
  }
 
  public void post(String server, String cause) {
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    try {
      zoo.putPersistentData(path + "/" + server, cause.getBytes(), NodeExistsPolicy.SKIP);
    } catch (Exception ex) {
      log.error(ex, ex);
    }
  }
View Full Code Here

  }
 
  private static TreeSet<UUID> getInstanceIDs() {
    TreeSet<UUID> ts = new TreeSet<UUID>();
   
    IZooReaderWriter zk = ZooReaderWriter.getInstance();
   
    try {
      List<String> children = zk.getChildren(Constants.ZROOT);
     
      for (String iid : children) {
        if (iid.equals("instances"))
          continue;
        try {
View Full Code Here

TOP

Related Classes of org.apache.accumulo.fate.zookeeper.IZooReaderWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.