Package org.apache.accumulo.server.zookeeper

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


    for (LogEntry entry : logEntries) {
      if (entry.extent.equals(Constants.ROOT_TABLET_EXTENT)) {
        String root = getZookeeperLogLocation();
        while (true) {
          try {
            IZooReaderWriter zoo = ZooReaderWriter.getInstance();
            if (zoo.isLockHeld(zooLock.getLockID()))
              zoo.recursiveDelete(root + "/" + entry.filename, NodeMissingPolicy.SKIP);
            break;
          } catch (Exception e) {
            log.error(e, e);
          }
          UtilWaitThread.sleep(1000);
View Full Code Here


          flushId);
    }
   
    void bringMinorCompactionOnline(Path tmpDatafile, Path newDatafile, Path absMergeFile, DataFileValue dfv, CommitSession commitSession, long flushId) {
     
      IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
      if (extent.equals(Constants.ROOT_TABLET_EXTENT)) {
        try {
          if (!zoo.isLockHeld(tabletServer.getLock().getLockID())) {
            throw new IllegalStateException();
          }
        } catch (Exception e) {
          throw new IllegalStateException("Can not bring major compaction online, lock not held", e);
        }
View Full Code Here

      TServerInstance lastLocation = null;
      synchronized (Tablet.this) {
       
        t1 = System.currentTimeMillis();
       
        IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
       
        dataSourceDeletions.incrementAndGet();
       
        if (extent.equals(Constants.ROOT_TABLET_EXTENT)) {
         
          waitForScansToFinish(oldDatafiles, true, Long.MAX_VALUE);
         
          try {
            if (!zoo.isLockHeld(tabletServer.getLock().getLockID())) {
              throw new IllegalStateException();
            }
          } catch (Exception e) {
            throw new IllegalStateException("Can not bring major compaction online, lock not held", e);
          }
View Full Code Here

   */
  public static void main(String[] args) throws Exception {
    String rootDir = args[0];
    File reportDir = new File(args[1]);
   
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
   
    if (zoo.exists(rootDir)) {
      zoo.recursiveDelete(rootDir, NodeMissingPolicy.FAIL);
    }
   
    if (!reportDir.exists()) {
      reportDir.mkdir();
    } else {
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

  }
 
  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

    if (args.length < 1) {
      System.err.println("Usage: " + CleanZookeeper.class.getName() + " hostname[:port] [auth]");
      System.exit(1);
    }
    String root = Constants.ZROOT;
    IZooReaderWriter zk = ZooReaderWriter.getInstance();
    if (args.length == 2) {
      zk.getZooKeeper().addAuthInfo("digest", args[1].getBytes());
    }
   
    try {
      for (String child : zk.getChildren(root)) {
        if (Constants.ZINSTANCES.equals("/" + child)) {
          for (String instanceName : zk.getChildren(root + Constants.ZINSTANCES)) {
            String instanceNamePath = root + Constants.ZINSTANCES + "/" + instanceName;
            byte[] id = zk.getData(instanceNamePath, null);
            if (id != null && !new String(id).equals(HdfsZooInstance.getInstance().getInstanceID())) {
              try {
                zk.recursiveDelete(instanceNamePath, NodeMissingPolicy.SKIP);
              } catch (KeeperException.NoAuthException ex) {
                log.warn("Unable to delete " + instanceNamePath);
              }
            }
          }
        } else if (!child.equals(HdfsZooInstance.getInstance().getInstanceID())) {
          String path = root + "/" + child;
          try {
            zk.recursiveDelete(path, NodeMissingPolicy.SKIP);
          } catch (KeeperException.NoAuthException ex) {
            log.warn("Unable to delete " + path);
          }
        }
      }
View Full Code Here

    if (force) {
      String tserver = AddressUtil.toString(server.getLocation());
      String path = ZooUtil.getRoot(m.getInstance()) + Constants.ZTSERVERS + "/" + tserver;
      ZooLock.deleteLock(path);
      path = ZooUtil.getRoot(m.getInstance()) + Constants.ZDEADTSERVERS + "/" + tserver;
      IZooReaderWriter zoo = ZooReaderWriter.getInstance();
      zoo.putPersistentData(path, "forced down".getBytes(), NodeExistsPolicy.OVERWRITE);
      return new DisconnectLogger(server.getLocation().getAddress().getHostAddress());
    }
   
    // TODO move this to isReady() and drop while loop?
    Listener listener = m.getEventCoordinator().getListener();
View Full Code Here

  public static void main(String[] args) throws Exception {
   
    String tserverPath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTSERVERS;
   
    if (args.length == 1 && args[0].equals("-list")) {
      IZooReaderWriter zoo = ZooReaderWriter.getInstance();
     
      List<String> tabletServers = zoo.getChildren(tserverPath);
     
      for (String tabletServer : tabletServers) {
        byte[] lockData = ZooLock.getLockData(tserverPath + "/" + tabletServer);
        String holder = null;
        if (lockData != null) {
View Full Code Here

  ZooLock getLock() {
    return tabletServerLock;
  }
 
  private void announceExistence() {
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    try {
      String zPath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTSERVERS + "/" + getClientAddressString();
     
      zoo.putPersistentData(zPath, new byte[] {}, NodeExistsPolicy.SKIP);
     
      tabletServerLock = new ZooLock(zPath);
     
      LockWatcher lw = new LockWatcher() {
       
        @Override
        public void lostLock(final LockLossReason reason) {
          Halt.halt(0, new Runnable() {
            public void run() {
              if (!serverStopRequested)
                log.fatal("Lost tablet server lock (reason = " + reason + "), exiting.");
              logGCInfo();
            }
          });
        }
      };
     
      byte[] lockContent = new ServerServices(getClientAddressString(), Service.TSERV_CLIENT).toString().getBytes();
      for (int i = 0; i < 120 / 5; i++) {
        zoo.putPersistentData(zPath, new byte[0], NodeExistsPolicy.SKIP);
       
        if (tabletServerLock.tryLock(lw, lockContent)) {
          log.debug("Obtained tablet server lock " + tabletServerLock.getLockPath());
          return;
        }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.server.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.