Package org.apache.accumulo.server.zookeeper

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


   */
  public static void updateTabletDataFile(KeyExtent extent, String path, String mergeFile, DataFileValue dfv, String time, AuthInfo credentials,
      Set<String> filesInUseByScans, String address, ZooLock zooLock, Set<String> unusedWalLogs, TServerInstance lastLocation, long flushId) {
    if (extent.equals(Constants.ROOT_TABLET_EXTENT)) {
      if (unusedWalLogs != null) {
        IZooReaderWriter zk = ZooReaderWriter.getInstance();
        // unusedWalLogs will contain the location/name of each log in a log set
        // the log set is stored under one of the log names, but not both
        // find the entry under one of the names and delete it.
        String root = getZookeeperLogLocation();
        boolean foundEntry = false;
        for (String entry : unusedWalLogs) {
          String[] parts = entry.split("/");
          String zpath = root + "/" + parts[1];
          while (true) {
            try {
              if (zk.exists(zpath)) {
                zk.recursiveDelete(zpath, NodeMissingPolicy.SKIP);
                foundEntry = true;
              }
              break;
            } catch (KeeperException e) {
              log.error(e, e);
View Full Code Here


    }
   
  }
 
  public static boolean recordRootTabletLocation(String address) {
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    for (int i = 0; i < SAVE_ROOT_TABLET_RETRIES; i++) {
      try {
        log.info("trying to write root tablet location to ZooKeeper as " + address);
        String zRootLocPath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZROOT_TABLET_LOCATION;
        zoo.putPersistentData(zRootLocPath, address.getBytes(), NodeExistsPolicy.OVERWRITE);
        return true;
      } catch (Exception e) {
        log.error("Master: unable to save root tablet location in zookeeper. exception: " + e, e);
      }
    }
View Full Code Here

    LogEntry entry = entries.get(0);
    if (entry.extent.equals(Constants.ROOT_TABLET_EXTENT)) {
      String root = getZookeeperLogLocation();
      while (true) {
        try {
          IZooReaderWriter zoo = ZooReaderWriter.getInstance();
          if (zoo.isLockHeld(zooLock.getLockID()))
            zoo.putPersistentData(root + "/" + entry.filename, entry.toBytes(), NodeExistsPolicy.OVERWRITE);
          break;
        } catch (KeeperException e) {
          log.error(e, e);
        } catch (InterruptedException e) {
          log.error(e, e);
View Full Code Here

    log.info("Returning logs " + result + " for extent " + extent);
    return result;
  }
 
  private static void getRootLogEntries(ArrayList<LogEntry> result) throws KeeperException, InterruptedException, IOException {
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    String root = getZookeeperLogLocation();
    for (String child : zoo.getChildren(root)) {
      LogEntry e = new LogEntry();
      e.fromBytes(zoo.getData(root + "/" + child, null));
      result.add(e);
    }
  }
View Full Code Here

      if (extent.equals(Constants.ROOT_TABLET_EXTENT)) {
        for (LogEntry entry : logEntries) {
        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

  private void upgradeZookeeper() {
    if (Accumulo.getAccumuloPersistentVersion() == Constants.PREV_DATA_VERSION) {
      try {
        log.info("Upgrading zookeeper");

        IZooReaderWriter zoo = ZooReaderWriter.getInstance();
       
        TablePropUtil.setTableProperty(Constants.METADATA_TABLE_ID, Property.TABLE_ITERATOR_PREFIX.getKey() + "majc.bulkLoadFilter", "20,"
            + MetadataBulkLoadFilter.class.getName());
       
        zoo.putPersistentData(ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, new byte[0], NodeExistsPolicy.SKIP);
        zoo.putPersistentData(ZooUtil.getRoot(instance) + Constants.ZHDFS_RESERVATIONS, new byte[0], NodeExistsPolicy.SKIP);
        zoo.putPersistentData(ZooUtil.getRoot(instance) + Constants.ZNEXT_FILE, new byte[] {'0'}, NodeExistsPolicy.SKIP);

        String[] tablePropsToDelete = new String[] {"table.scan.cache.size", "table.scan.cache.enable"};

        for (String id : Tables.getIdToNameMap(instance).keySet()) {
          zoo.putPersistentData(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + id + Constants.ZTABLE_FLUSH_ID, "0".getBytes(), NodeExistsPolicy.SKIP);
          zoo.putPersistentData(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + id + Constants.ZTABLE_COMPACT_ID, "0".getBytes(), NodeExistsPolicy.SKIP);
         
          for (String prop : tablePropsToDelete) {
            String propPath = ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + id + Constants.ZTABLE_CONF + "/" + prop;
            if (zoo.exists(propPath))
              zoo.delete(propPath, -1);
          }
        }
       
        setACLs(zoo, ZooUtil.getRoot(instance), ZooUtil.getRoot(instance) + Constants.ZUSERS);
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 long initiateFlush(TInfo tinfo, AuthInfo c, String tableId) throws ThriftSecurityException, ThriftTableOperationException, TException {
      verify(c, tableId, TableOperation.FLUSH, check(c, tableId, TablePermission.WRITE) || check(c, tableId, TablePermission.ALTER_TABLE));
     
      String zTablePath = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID() + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_FLUSH_ID;
     
      IZooReaderWriter zoo = ZooReaderWriter.getInstance();
      byte fid[];
      try {
        fid = zoo.mutate(zTablePath, null, null, new Mutator() {
          @Override
          public byte[] mutate(byte[] currentValue) throws Exception {
            long flushID = Long.parseLong(new String(currentValue));
            flushID++;
            return ("" + flushID).getBytes();
View Full Code Here

    return count;
  }
 
  private static int scanServers(Map<String,String> fileToServerMap) throws Exception {
    int count = 0;
    IZooReaderWriter zk = ZooReaderWriter.getInstance();
    String loggersDir = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZLOGGERS;
    List<String> servers = zk.getChildren(loggersDir, null);
    Collections.shuffle(servers);
    for (String server : servers) {
      String address = "no-data";
      count++;
      try {
        byte[] data = zk.getData(loggersDir + "/" + server, null);
        address = new String(data);
        Iface logger = ThriftUtil.getClient(new MutationLogger.Client.Factory(), address, Property.LOGGER_PORT, Property.TSERV_LOGGER_TIMEOUT,
            ServerConfiguration.getSystemConfiguration());
        for (String log : logger.getClosedLogs(null, SecurityConstants.getSystemCredentials())) {
          fileToServerMap.put(log, address);
View Full Code Here

  }
 

  private void registerInZooKeeper(String name) throws Exception {
    String root = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTRACERS;
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    String path = zoo.putEphemeralSequential(root + "/trace-", name.getBytes());
    zoo.exists(path, this);
  }
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.