Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.TableDescriptor


  public boolean setTableStateIfNotInStates(TableName tableName,
                                            TableState.State newState,
                                            TableState.State... states)
          throws IOException {
    synchronized (tableStates) {
      TableDescriptor descriptor = readDescriptor(tableName);
      if (descriptor == null) {
        throw new TableNotFoundException(tableName);
      }
      if (!TableState.isInStates(descriptor.getTableState(), states)) {
        writeDescriptor(
            new TableDescriptor(descriptor.getHTableDescriptor(), newState));
        return true;
      } else {
        return false;
      }
    }
View Full Code Here


  }

  public TableState.State getTableState(TableName tableName) throws IOException {
    TableState.State tableState = tableStates.get(tableName);
    if (tableState == null) {
      TableDescriptor descriptor = readDescriptor(tableName);
      if (descriptor != null)
        tableState = descriptor.getTableState();
    }
    return tableState;
  }
View Full Code Here

   * @param table descriptor to read
   * @return descriptor
   * @throws IOException
   */
  private TableDescriptor readDescriptor(TableName tableName) throws IOException {
    TableDescriptor descriptor = descriptors.getDescriptor(tableName);
    if (descriptor == null)
      tableStates.remove(tableName);
    else
      tableStates.put(tableName, descriptor.getTableState());
    return descriptor;
  }
View Full Code Here

    if(FSTableDescriptors.getTableInfoPath(fs, newTablePath) == null) {
      LOG.info("Creating new tableDesc for ACL");
      HTableDescriptor newDesc = new HTableDescriptor(oldDesc);
      newDesc.setName(newTableName);
      new FSTableDescriptors(this.conf).createTableDescriptorForTableDirectory(
        newTablePath, new TableDescriptor(newDesc, TableState.State.ENABLED), true);
    }


    ServerName fakeServer = ServerName.valueOf("nsupgrade", 96, 123);
    String metaLogName = HLogUtil.getHLogDirectoryName(fakeServer.toString());
View Full Code Here

     */
    public void compact(final Path path, final boolean compactOnce, final boolean major) throws IOException {
      if (isFamilyDir(fs, path)) {
        Path regionDir = path.getParent();
        Path tableDir = regionDir.getParent();
        TableDescriptor htd = FSTableDescriptors.getTableDescriptorFromFs(fs, tableDir);
        HRegionInfo hri = HRegionFileSystem.loadRegionInfoFileContent(fs, regionDir);
        compactStoreFiles(tableDir, htd.getHTableDescriptor(), hri,
            path.getName(), compactOnce, major);
      } else if (isRegionDir(fs, path)) {
        Path tableDir = path.getParent();
        TableDescriptor htd = FSTableDescriptors.getTableDescriptorFromFs(fs, tableDir);
        compactRegion(tableDir, htd.getHTableDescriptor(), path, compactOnce, major);
      } else if (isTableDir(fs, path)) {
        compactTable(path, compactOnce, major);
      } else {
        throw new IOException(
          "Specified path is not a table, region or family directory. path=" + path);
View Full Code Here

      }
    }

    private void compactTable(final Path tableDir, final boolean compactOnce, final boolean major)
        throws IOException {
      TableDescriptor htd = FSTableDescriptors.getTableDescriptorFromFs(fs, tableDir);
      for (Path regionDir: FSUtils.getRegionDirs(fs, tableDir)) {
        compactRegion(tableDir, htd.getHTableDescriptor(), regionDir, compactOnce, major);
      }
    }
View Full Code Here

  public TableDescriptor getDescriptor(final TableName tablename)
  throws IOException {
    invocations++;
    if (TableName.META_TABLE_NAME.equals(tablename)) {
      cachehits++;
      return new TableDescriptor(metaTableDescritor, TableState.State.ENABLED);
    }
    // hbase:meta is already handled. If some one tries to get the descriptor for
    // .logs, .oldlogs or .corrupt throw an exception.
    if (HConstants.HBASE_NON_USER_TABLE_DIRS.contains(tablename.getNameAsString())) {
       throw new IOException("No descriptor found for non table = " + tablename);
    }

    if (usecache) {
      // Look in cache of descriptors.
      TableDescriptor cachedtdm = this.cache.get(tablename);
      if (cachedtdm != null) {
        cachehits++;
        return cachedtdm;
      }
    }
    TableDescriptor tdmt = null;
    try {
      tdmt = getTableDescriptorFromFs(fs, rootdir, tablename, !fsreadonly);
    } catch (NullPointerException e) {
      LOG.debug("Exception during readTableDecriptor. Current table name = "
          + tablename, e);
View Full Code Here

  public HTableDescriptor get(TableName tableName) throws IOException {
    if (TableName.META_TABLE_NAME.equals(tableName)) {
      cachehits++;
      return metaTableDescritor;
    }
    TableDescriptor descriptor = getDescriptor(tableName);
    return descriptor == null ? null : descriptor.getHTableDescriptor();
  }
View Full Code Here

      for (Map.Entry<TableName, TableDescriptor> entry: this.cache.entrySet()) {
        tds.put(entry.getKey().toString(), entry.getValue());
      }
      // add hbase:meta to the response
      tds.put(this.metaTableDescritor.getNameAsString(),
        new TableDescriptor(metaTableDescritor, TableState.State.ENABLED));
    } else {
      LOG.debug("Fetching table descriptors from the filesystem.");
      boolean allvisited = true;
      for (Path d : FSUtils.getTableDirs(fs, rootdir)) {
        TableDescriptor htd = null;
        try {
          htd = getDescriptor(FSUtils.getTableName(d));
        } catch (FileNotFoundException fnfe) {
          // inability of retrieving one HTD shouldn't stop getting the remaining
          LOG.warn("Trouble retrieving htd", fnfe);
        }
        if (htd == null) {
          allvisited = false;
          continue;
        } else {
          tds.put(htd.getHTableDescriptor().getTableName().getNameAsString(), htd);
        }
        fsvisited = allvisited;
      }
    }
    return tds;
View Full Code Here

    if (HConstants.HBASE_NON_USER_TABLE_DIRS.contains(tableName.getNameAsString())) {
      throw new NotImplementedException(
          "Cannot add a table descriptor for a reserved subdirectory name: "
              + htd.getNameAsString());
    }
    TableDescriptor descriptor = getDescriptor(htd.getTableName());
    if (descriptor == null)
      descriptor = new TableDescriptor(htd);
    else
      descriptor.setHTableDescriptor(htd);
    updateTableDescriptor(descriptor);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.TableDescriptor

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.