Java Code Examples for org.apache.hadoop.hbase.TableName#isSystemTable()

The following examples show how to use org.apache.hadoop.hbase.TableName#isSystemTable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NamespaceStateManager.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize namespace state cache by scanning meta table.
 */
private void initialize() throws IOException {
  List<NamespaceDescriptor> namespaces = this.master.getClusterSchema().getNamespaces();
  for (NamespaceDescriptor namespace : namespaces) {
    addNamespace(namespace.getName());
    List<TableName> tables = this.master.listTableNamesByNamespace(namespace.getName());
    for (TableName table : tables) {
      if (table.isSystemTable()) {
        continue;
      }
      List<RegionInfo> regions =
          MetaTableAccessor.getTableRegions(this.master.getConnection(), table, true);
      addTable(table, regions.size());
    }
  }
  LOG.info("Finished updating state of " + nsStateCache.size() + " namespaces. ");
  initialized = true;
}
 
Example 2
Source File: VisibilityController.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public DeleteTracker postInstantiateDeleteTracker(
    ObserverContext<RegionCoprocessorEnvironment> ctx, DeleteTracker delTracker)
    throws IOException {
  // Nothing to do if we are not filtering by visibility
  if (!authorizationEnabled) {
    return delTracker;
  }
  Region region = ctx.getEnvironment().getRegion();
  TableName table = region.getRegionInfo().getTable();
  if (table.isSystemTable()) {
    return delTracker;
  }
  // We are creating a new type of delete tracker here which is able to track
  // the timestamps and also the
  // visibility tags per cell. The covering cells are determined not only
  // based on the delete type and ts
  // but also on the visibility expression matching.
  return new VisibilityScanDeleteTracker(delTracker.getCellComparator());
}
 
Example 3
Source File: QuotaCache.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="GC_UNRELATED_TYPES",
  justification="I do not understand why the complaints, it looks good to me -- FIX")
protected void chore() {
  // Prefetch online tables/namespaces
  for (TableName table: ((HRegionServer)QuotaCache.this.rsServices).getOnlineTables()) {
    if (table.isSystemTable()) {
      continue;
    }
    QuotaCache.this.tableQuotaCache.computeIfAbsent(table, key -> new QuotaState());

    final String ns = table.getNamespaceAsString();

    QuotaCache.this.namespaceQuotaCache.computeIfAbsent(ns, key -> new QuotaState());
  }

  QuotaCache.this.regionServerQuotaCache.computeIfAbsent(
      QuotaTableUtil.QUOTA_REGION_SERVER_ROW_KEY, key -> new QuotaState());

  updateQuotaFactors();
  fetchNamespaceQuotaState();
  fetchTableQuotaState();
  fetchUserQuotaState();
  fetchRegionServerQuotaState();
  fetchExceedThrottleQuota();
  lastUpdate = EnvironmentEdgeManager.currentTime();
}
 
Example 4
Source File: NamespaceAuditor.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void checkTableTypeAndThrowException(TableName name) throws IOException {
  if (name.isSystemTable()) {
    LOG.debug("Namespace auditor checks not performed for table " + name.getNameAsString());
  } else {
    throw new HBaseIOException(
      name + " is being created even before namespace auditor has been initialized.");
  }
}
 
Example 5
Source File: CreateTableProcedure.java    From hbase with Apache License 2.0 5 votes vote down vote up
private boolean prepareCreate(final MasterProcedureEnv env) throws IOException {
  final TableName tableName = getTableName();
  if (MetaTableAccessor.tableExists(env.getMasterServices().getConnection(), tableName)) {
    setFailure("master-create-table", new TableExistsException(getTableName()));
    return false;
  }

  // check that we have at least 1 CF
  if (tableDescriptor.getColumnFamilyCount() == 0) {
    setFailure("master-create-table", new DoNotRetryIOException(
      "Table " + getTableName().toString() + " should have at least one column family."));
    return false;
  }
  if (!tableName.isSystemTable()) {
    // do not check rs group for system tables as we may block the bootstrap.
    Supplier<String> forWhom = () -> "table " + tableName;
    RSGroupInfo rsGroupInfo = MasterProcedureUtil.checkGroupExists(
      env.getMasterServices().getRSGroupInfoManager()::getRSGroup,
      tableDescriptor.getRegionServerGroup(), forWhom);
    if (rsGroupInfo == null) {
      // we do not set rs group info on table, check if we have one on namespace
      String namespace = tableName.getNamespaceAsString();
      NamespaceDescriptor nd = env.getMasterServices().getClusterSchema().getNamespace(namespace);
      forWhom = () -> "table " + tableName + "(inherit from namespace)";
      rsGroupInfo = MasterProcedureUtil.checkGroupExists(
        env.getMasterServices().getRSGroupInfoManager()::getRSGroup,
        MasterProcedureUtil.getNamespaceGroup(nd), forWhom);
    }
    MasterProcedureUtil.checkGroupNotEmpty(rsGroupInfo, forWhom);
  }

  return true;
}
 
Example 6
Source File: MasterProcedureUtil.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Return the priority for the given table. Now meta table is 3, other system tables are 2, and
 * user tables are 1.
 */
public static int getTablePriority(TableName tableName) {
  if (TableName.isMetaTableName(tableName)) {
    return 3;
  } else if (tableName.isSystemTable()) {
    return 2;
  } else {
    return 1;
  }
}
 
Example 7
Source File: IndexRpcController.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
  public void setPriority(final TableName tn) {
if (!tn.isSystemTable() && !tn.getNameAsString().equals(tracingTableName)) {
	setPriority(this.priority);
}  
      else {
          super.setPriority(tn);
      }
  }
 
Example 8
Source File: ClientSnapshotDescriptionUtils.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Check to make sure that the description of the snapshot requested is valid
 * @param snapshot description of the snapshot
 * @throws IllegalArgumentException if the name of the snapshot or the name of the table to
 *           snapshot are not valid names
 */
public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescription snapshot)
    throws IllegalArgumentException {
  // make sure the snapshot name is valid
  TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true);
  if (snapshot.hasTable()) {
    // make sure the table name is valid, this will implicitly check validity
    TableName tableName = TableName.valueOf(snapshot.getTable());

    if (tableName.isSystemTable()) {
      throw new IllegalArgumentException("System table snapshots are not allowed");
    }
  }
}
 
Example 9
Source File: SimpleRegionNormalizer.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public List<NormalizationPlan> computePlansForTable(final TableName table) {
  if (table == null) {
    return Collections.emptyList();
  }
  if (table.isSystemTable()) {
    LOG.debug("Normalization of system table {} isn't allowed", table);
    return Collections.emptyList();
  }

  final boolean proceedWithSplitPlanning = proceedWithSplitPlanning();
  final boolean proceedWithMergePlanning = proceedWithMergePlanning();
  if (!proceedWithMergePlanning && !proceedWithSplitPlanning) {
    LOG.debug("Both split and merge are disabled. Skipping normalization of table: {}", table);
    return Collections.emptyList();
  }

  final NormalizeContext ctx = new NormalizeContext(table);
  if (CollectionUtils.isEmpty(ctx.getTableRegions())) {
    return Collections.emptyList();
  }

  LOG.debug("Computing normalization plan for table:  {}, number of regions: {}", table,
    ctx.getTableRegions().size());

  final List<NormalizationPlan> plans = new ArrayList<>();
  if (proceedWithSplitPlanning) {
    plans.addAll(computeSplitNormalizationPlans(ctx));
  }
  if (proceedWithMergePlanning) {
    plans.addAll(computeMergeNormalizationPlans(ctx));
  }

  LOG.debug("Computed {} normalization plans for table {}", plans.size(), table);
  return plans;
}
 
Example 10
Source File: RegionServerRpcQuotaManager.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the quota for an operation.
 *
 * @param ugi the user that is executing the operation
 * @param table the table where the operation will be executed
 * @return the OperationQuota
 */
public OperationQuota getQuota(final UserGroupInformation ugi, final TableName table) {
  if (isQuotaEnabled() && !table.isSystemTable() && isRpcThrottleEnabled()) {
    UserQuotaState userQuotaState = quotaCache.getUserQuotaState(ugi);
    QuotaLimiter userLimiter = userQuotaState.getTableLimiter(table);
    boolean useNoop = userLimiter.isBypass();
    if (userQuotaState.hasBypassGlobals()) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("get quota for ugi=" + ugi + " table=" + table + " userLimiter=" + userLimiter);
      }
      if (!useNoop) {
        return new DefaultOperationQuota(this.rsServices.getConfiguration(), userLimiter);
      }
    } else {
      QuotaLimiter nsLimiter = quotaCache.getNamespaceLimiter(table.getNamespaceAsString());
      QuotaLimiter tableLimiter = quotaCache.getTableLimiter(table);
      QuotaLimiter rsLimiter = quotaCache
          .getRegionServerQuotaLimiter(QuotaTableUtil.QUOTA_REGION_SERVER_ROW_KEY);
      useNoop &= tableLimiter.isBypass() && nsLimiter.isBypass() && rsLimiter.isBypass();
      boolean exceedThrottleQuotaEnabled = quotaCache.isExceedThrottleQuotaEnabled();
      if (LOG.isTraceEnabled()) {
        LOG.trace("get quota for ugi=" + ugi + " table=" + table + " userLimiter=" + userLimiter
            + " tableLimiter=" + tableLimiter + " nsLimiter=" + nsLimiter + " rsLimiter="
            + rsLimiter + " exceedThrottleQuotaEnabled=" + exceedThrottleQuotaEnabled);
      }
      if (!useNoop) {
        if (exceedThrottleQuotaEnabled) {
          return new ExceedOperationQuota(this.rsServices.getConfiguration(), rsLimiter,
              userLimiter, tableLimiter, nsLimiter);
        } else {
          return new DefaultOperationQuota(this.rsServices.getConfiguration(), userLimiter,
              tableLimiter, nsLimiter, rsLimiter);
        }
      }
    }
  }
  return NoopOperationQuota.get();
}
 
Example 11
Source File: InterRegionServerRpcController.java    From phoenix-omid with Apache License 2.0 5 votes vote down vote up
@Override
public void setPriority(final TableName tn) {
    if (tn.isSystemTable()) {
        super.setPriority(tn);
    } else {
        setPriority(this.priority);
    }
}
 
Example 12
Source File: SnapshotScannerHDFSAclController.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void postCompletedDeleteTableAction(ObserverContext<MasterCoprocessorEnvironment> ctx,
    TableName tableName) throws IOException {
  if (!tableName.isSystemTable() && checkInitialized("deleteTable " + tableName)) {
    /*
     * Remove table user access HDFS acl from namespace directory if the user has no permissions
     * of global, ns of the table or other tables of the ns, eg: Bob has 'ns1:t1' read permission,
     * when delete 'ns1:t1', if Bob has global read permission, '@ns1' read permission or
     * 'ns1:other_tables' read permission, then skip remove Bob access acl in ns1Dirs, otherwise,
     * remove Bob access acl.
     */
    try (Table aclTable =
        ctx.getEnvironment().getConnection().getTable(PermissionStorage.ACL_TABLE_NAME)) {
      Set<String> users = SnapshotScannerHDFSAclStorage.getTableUsers(aclTable, tableName);
      if (users.size() > 0) {
        // 1. Remove table archive directory default ACLs
        hdfsAclHelper.removeTableDefaultAcl(tableName, users);
        // 2. Delete table owner permission is synced to HDFS in acl table
        SnapshotScannerHDFSAclStorage.deleteTableHdfsAcl(aclTable, tableName);
        // 3. Remove namespace access acls
        Set<String> removeUsers = filterUsersToRemoveNsAccessAcl(aclTable, tableName, users);
        if (removeUsers.size() > 0) {
          hdfsAclHelper.removeNamespaceAccessAcl(tableName, removeUsers, "delete");
        }
      }
    }
  }
}
 
Example 13
Source File: TestBlockEvictionFromClient.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @throws java.lang.Exception
 */
@After
public void tearDown() throws Exception {
  if (latch != null) {
    while (latch.getCount() > 0) {
      latch.countDown();
    }
  }
  if (getLatch != null) {
    getLatch.countDown();
  }
  if (compactionLatch != null) {
    compactionLatch.countDown();
  }
  if (exceptionLatch != null) {
    exceptionLatch.countDown();
  }
  latch = null;
  getLatch = null;
  compactionLatch = null;
  exceptionLatch = null;
  CustomInnerRegionObserver.throwException.set(false);
  // Clean up the tables for every test case
  TableName[] listTableNames = TEST_UTIL.getAdmin().listTableNames();
  for (TableName tableName : listTableNames) {
    if (!tableName.isSystemTable()) {
      TEST_UTIL.getAdmin().disableTable(tableName);
      TEST_UTIL.getAdmin().deleteTable(tableName);
    }
  }
}
 
Example 14
Source File: VisibilityController.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get,
    List<Cell> results) throws IOException {
  if (!initialized) {
    throw new VisibilityControllerNotReadyException("VisibilityController not yet initialized");
  }
  // Nothing useful to do if authorization is not enabled
  if (!authorizationEnabled) {
    return;
  }
  Region region = e.getEnvironment().getRegion();
  Authorizations authorizations = null;
  try {
    authorizations = get.getAuthorizations();
  } catch (DeserializationException de) {
    throw new IOException(de);
  }
  if (authorizations == null) {
    // No Authorizations present for this scan/Get!
    // In case of system tables other than "labels" just scan with out visibility check and
    // filtering. Checking visibility labels for META and NAMESPACE table is not needed.
    TableName table = region.getRegionInfo().getTable();
    if (table.isSystemTable() && !table.equals(LABELS_TABLE_NAME)) {
      return;
    }
  }
  Filter visibilityLabelFilter = VisibilityUtils.createVisibilityLabelFilter(e.getEnvironment()
      .getRegion(), authorizations);
  if (visibilityLabelFilter != null) {
    Filter filter = get.getFilter();
    if (filter != null) {
      get.setFilter(new FilterList(filter, visibilityLabelFilter));
    } else {
      get.setFilter(visibilityLabelFilter);
    }
  }
}
 
Example 15
Source File: VisibilityController.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void preScannerOpen(ObserverContext<RegionCoprocessorEnvironment> e, Scan scan)
    throws IOException {
  if (!initialized) {
    throw new VisibilityControllerNotReadyException("VisibilityController not yet initialized!");
  }
  // Nothing to do if authorization is not enabled
  if (!authorizationEnabled) {
    return;
  }
  Region region = e.getEnvironment().getRegion();
  Authorizations authorizations = null;
  try {
    authorizations = scan.getAuthorizations();
  } catch (DeserializationException de) {
    throw new IOException(de);
  }
  if (authorizations == null) {
    // No Authorizations present for this scan/Get!
    // In case of system tables other than "labels" just scan with out visibility check and
    // filtering. Checking visibility labels for META and NAMESPACE table is not needed.
    TableName table = region.getRegionInfo().getTable();
    if (table.isSystemTable() && !table.equals(LABELS_TABLE_NAME)) {
      return;
    }
  }

  Filter visibilityLabelFilter = VisibilityUtils.createVisibilityLabelFilter(region,
      authorizations);
  if (visibilityLabelFilter != null) {
    Filter filter = scan.getFilter();
    if (filter != null) {
      scan.setFilter(new FilterList(filter, visibilityLabelFilter));
    } else {
      scan.setFilter(visibilityLabelFilter);
    }
  }
}
 
Example 16
Source File: InterRegionServerRpcController.java    From phoenix-omid with Apache License 2.0 5 votes vote down vote up
@Override
public void setPriority(final TableName tn) {
    if (tn.isSystemTable()) {
        super.setPriority(tn);
    } else {
        setPriority(this.priority);
    }
}
 
Example 17
Source File: SnapshotScannerHDFSAclController.java    From hbase with Apache License 2.0 4 votes vote down vote up
private boolean needHandleTableHdfsAcl(TableDescriptor tableDescriptor, String operation) {
  TableName tableName = tableDescriptor.getTableName();
  return !tableName.isSystemTable() && checkInitialized(operation)
      && hdfsAclHelper.isAclSyncToHdfsEnabled(tableDescriptor);
}
 
Example 18
Source File: SnapshotScannerHDFSAclController.java    From hbase with Apache License 2.0 4 votes vote down vote up
private boolean needHandleTableHdfsAcl(TableName tableName, String operation) throws IOException {
  return !tableName.isSystemTable() && checkInitialized(operation) && hdfsAclHelper
      .isAclSyncToHdfsEnabled(masterServices.getTableDescriptors().get(tableName));
}
 
Example 19
Source File: DeleteTableProcedure.java    From hbase with Apache License 2.0 4 votes vote down vote up
protected static void deleteTableStates(final MasterProcedureEnv env, final TableName tableName)
    throws IOException {
  if (!tableName.isSystemTable()) {
    ProcedureSyncWait.getMasterQuotaManager(env).removeTableFromNamespaceQuota(tableName);
  }
}
 
Example 20
Source File: QuotaCache.java    From hbase with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the limiter associated to the specified user/table.
 *
 * @param ugi the user to limit
 * @param table the table to limit
 * @return the limiter associated to the specified user/table
 */
public QuotaLimiter getUserLimiter(final UserGroupInformation ugi, final TableName table) {
  if (table.isSystemTable()) {
    return NoopQuotaLimiter.get();
  }
  return getUserQuotaState(ugi).getTableLimiter(table);
}