org.apache.hadoop.hbase.TableName#isMetaTableName ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.TableName#isMetaTableName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: RegionsRecoveryChore.java
private void prepareTableToReopenRegionsMap(
    final Map<TableName, List<byte[]>> tableToReopenRegionsMap,
    final byte[] regionName, final int regionStoreRefCount) {

  final RegionInfo regionInfo = hMaster.getAssignmentManager().getRegionInfo(regionName);
  final TableName tableName = regionInfo.getTable();
  if (TableName.isMetaTableName(tableName)) {
    // Do not reopen regions of meta table even if it has
    // high store file reference count
    return;
  }
  LOG.warn("Region {} for Table {} has high storeFileRefCount {}, considering it for reopen..",
    regionInfo.getRegionNameAsString(), tableName, regionStoreRefCount);
  tableToReopenRegionsMap
      .computeIfAbsent(tableName, (key) -> new ArrayList<>()).add(regionName);
}
 
源代码2 项目: hbase   文件: RegionRemoteProcedureBase.java
@Override
protected boolean waitInitialized(MasterProcedureEnv env) {
  if (TableName.isMetaTableName(getTableName())) {
    return false;
  }
  // First we need meta to be loaded, and second, if meta is not online then we will likely to
  // fail when updating meta so we wait until it is assigned.
  AssignmentManager am = env.getAssignmentManager();
  return am.waitMetaLoaded(this) || am.waitMetaAssigned(this, region);
}
 
源代码3 项目: hbase   文件: TransitRegionStateProcedure.java
@Override
protected boolean waitInitialized(MasterProcedureEnv env) {
  if (TableName.isMetaTableName(getTableName())) {
    return false;
  }
  // First we need meta to be loaded, and second, if meta is not online then we will likely to
  // fail when updating meta so we wait until it is assigned.
  AssignmentManager am = env.getAssignmentManager();
  return am.waitMetaLoaded(this) || am.waitMetaAssigned(this, getRegion());
}
 
源代码4 项目: hbase   文件: MasterProcedureUtil.java
/**
 * 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;
  }
}
 
源代码5 项目: hbase   文件: TableStateManager.java
private void fixTableStates(TableDescriptors tableDescriptors, Connection connection)
    throws IOException {
  Map<String, TableState> states = new HashMap<>();
  // NOTE: Full hbase:meta table scan!
  MetaTableAccessor.fullScanTables(connection, new ClientMetaTableAccessor.Visitor() {
    @Override
    public boolean visit(Result r) throws IOException {
      TableState state = CatalogFamilyFormat.getTableState(r);
      states.put(state.getTableName().getNameAsString(), state);
      return true;
    }
  });
  for (TableDescriptor tableDesc : tableDescriptors.getAll().values()) {
    TableName tableName = tableDesc.getTableName();
    if (TableName.isMetaTableName(tableName)) {
      // This table is always enabled. No fixup needed. No entry in hbase:meta needed.
      // Call through to fixTableState though in case a super class wants to do something.
      fixTableState(new TableState(tableName, TableState.State.ENABLED));
      continue;
    }
    TableState tableState = states.get(tableName.getNameAsString());
    if (tableState == null) {
      LOG.warn(tableName + " has no table state in hbase:meta, assuming ENABLED");
      MetaTableAccessor.updateTableState(connection, tableName, TableState.State.ENABLED);
      fixTableState(new TableState(tableName, TableState.State.ENABLED));
      tableName2State.put(tableName, TableState.State.ENABLED);
    } else {
      fixTableState(tableState);
      tableName2State.put(tableName, tableState.getState());
    }
  }
}
 
源代码6 项目: hbase   文件: TestAsyncTableUseMetaReplicas.java
@Override
public void preScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Scan scan)
    throws IOException {
  RegionInfo region = c.getEnvironment().getRegionInfo();
  if (FAIL_PRIMARY_SCAN && TableName.isMetaTableName(region.getTable()) &&
    region.getReplicaId() == RegionReplicaUtil.DEFAULT_REPLICA_ID) {
    throw new IOException("Inject error");
  }
}
 
源代码7 项目: hbase   文件: AsyncTableRegionLocatorImpl.java
@Override
public CompletableFuture<List<HRegionLocation>> getAllRegionLocations() {
  if (TableName.isMetaTableName(tableName)) {
    return conn.registry.getMetaRegionLocations()
      .thenApply(locs -> Arrays.asList(locs.getRegionLocations()));
  }
  return ClientMetaTableAccessor
    .getTableHRegionLocations(conn.getTable(TableName.META_TABLE_NAME), tableName);
}
 
源代码8 项目: hbase   文件: RawAsyncHBaseAdmin.java
@Override
public CompletableFuture<Boolean> tableExists(TableName tableName) {
  if (TableName.isMetaTableName(tableName)) {
    return CompletableFuture.completedFuture(true);
  }
  return ClientMetaTableAccessor.tableExists(metaTable, tableName);
}
 
源代码9 项目: hbase   文件: RawAsyncHBaseAdmin.java
@Override
public CompletableFuture<Boolean> isTableEnabled(TableName tableName) {
  if (TableName.isMetaTableName(tableName)) {
    return CompletableFuture.completedFuture(true);
  }
  CompletableFuture<Boolean> future = new CompletableFuture<>();
  addListener(ClientMetaTableAccessor.getTableState(metaTable, tableName),
    (tableState, error) -> {
      completeCheckTableState(future, tableState.isPresent() ? tableState.get() : null, error,
        TableState.State.ENABLED, tableName);
    });
  return future;
}
 
源代码10 项目: hbase   文件: RawAsyncHBaseAdmin.java
@Override
public CompletableFuture<Boolean> isTableDisabled(TableName tableName) {
  if (TableName.isMetaTableName(tableName)) {
    return CompletableFuture.completedFuture(false);
  }
  CompletableFuture<Boolean> future = new CompletableFuture<>();
  addListener(ClientMetaTableAccessor.getTableState(metaTable, tableName),
    (tableState, error) -> {
      completeCheckTableState(future, tableState.isPresent() ? tableState.get() : null, error,
        TableState.State.DISABLED, tableName);
    });
  return future;
}
 
源代码11 项目: hbase   文件: AsyncRegionLocator.java
@VisibleForTesting
RegionLocations getRegionLocationInCache(TableName tableName, byte[] row) {
  if (TableName.isMetaTableName(tableName)) {
    return metaRegionLocator.getRegionLocationInCache();
  } else {
    return nonMetaRegionLocator.getRegionLocationInCache(tableName, row);
  }
}
 
源代码12 项目: hbase   文件: AsyncRegionLocator.java
@VisibleForTesting
int getNumberOfCachedRegionLocations(TableName tableName) {
  if (TableName.isMetaTableName(tableName)) {
    return metaRegionLocator.getNumberOfCachedRegionLocations();
  } else {
    return nonMetaRegionLocator.getNumberOfCachedRegionLocations(tableName);
  }
}
 
源代码13 项目: hbase   文件: RegionTransitionProcedure.java
public boolean isMeta() {
  return TableName.isMetaTableName(getTableName());
}
 
源代码14 项目: hbase   文件: RSGroupUtil.java
/**
 * Will try to get the rsgroup from {@link TableDescriptor} first, and then try to get the rsgroup
 * from the {@link NamespaceDescriptor}. If still not present, return empty.
 */
public static Optional<RSGroupInfo> getRSGroupInfo(MasterServices master,
    RSGroupInfoManager manager, TableName tableName) throws IOException {
  TableDescriptor td = master.getTableDescriptors().get(tableName);
  if (td == null) {
    return Optional.empty();
  }
  // RSGroup information determined by client.
  Optional<String> optGroupNameOfTable = td.getRegionServerGroup();
  if (optGroupNameOfTable.isPresent()) {
    RSGroupInfo group = manager.getRSGroup(optGroupNameOfTable.get());
    if (group != null) {
      return Optional.of(group);
    }
  }
  // for backward compatible, where we may still have table configs in the RSGroupInfo after
  // upgrading when migrating is still on-going.
  RSGroupInfo groupFromOldRSGroupInfo = manager.getRSGroupForTable(tableName);
  if (groupFromOldRSGroupInfo != null) {
    return Optional.of(groupFromOldRSGroupInfo);
  }
  // RSGroup information determined by administrator.
  String groupDeterminedByAdmin = manager.determineRSGroupInfoForTable(tableName);
  RSGroupInfo groupInfo = null;
  if (groupDeterminedByAdmin != null) {
    groupInfo = manager.getRSGroup(groupDeterminedByAdmin);
  }
  if (groupInfo != null) {
    return Optional.of(groupInfo);
  }
  // Finally, we will try to fall back to namespace as rsgroup if exists
  ClusterSchema clusterSchema = master.getClusterSchema();
  if (clusterSchema == null) {
    if (TableName.isMetaTableName(tableName)) {
      LOG.info("Can not get the namespace rs group config for meta table, since the" +
          " meta table is not online yet, will use default group to assign meta first");
    } else {
      LOG.warn("ClusterSchema is null, can only use default rsgroup, should not happen?");
    }
    return Optional.empty();
  }
  NamespaceDescriptor nd = clusterSchema.getNamespace(tableName.getNamespaceAsString());
  String groupNameOfNs = nd.getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP);
  if (groupNameOfNs == null) {
    return Optional.empty();
  }
  return Optional.ofNullable(manager.getRSGroup(groupNameOfNs));
}
 
源代码15 项目: hbase   文件: AsyncClientScanner.java
private long getPrimaryTimeoutNs() {
  return TableName.isMetaTableName(tableName) ? conn.connConf.getPrimaryMetaScanTimeoutNs()
    : conn.connConf.getPrimaryScanTimeoutNs();
}
 
源代码16 项目: hbase   文件: RawAsyncHBaseAdmin.java
@Override
public CompletableFuture<Boolean> isTableAvailable(TableName tableName) {
  if (TableName.isMetaTableName(tableName)) {
    return connection.registry.getMetaRegionLocations().thenApply(locs -> Stream
      .of(locs.getRegionLocations()).allMatch(loc -> loc != null && loc.getServerName() != null));
  }
  CompletableFuture<Boolean> future = new CompletableFuture<>();
  addListener(isTableEnabled(tableName), (enabled, error) -> {
    if (error != null) {
      if (error instanceof TableNotFoundException) {
        future.complete(false);
      } else {
        future.completeExceptionally(error);
      }
      return;
    }
    if (!enabled) {
      future.complete(false);
    } else {
      addListener(
        ClientMetaTableAccessor.getTableHRegionLocations(metaTable, tableName),
        (locations, error1) -> {
          if (error1 != null) {
            future.completeExceptionally(error1);
            return;
          }
          List<HRegionLocation> notDeployedRegions = locations.stream()
            .filter(loc -> loc.getServerName() == null).collect(Collectors.toList());
          if (notDeployedRegions.size() > 0) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Table " + tableName + " has " + notDeployedRegions.size() + " regions");
            }
            future.complete(false);
            return;
          }
          future.complete(true);
        });
    }
  });
  return future;
}
 
源代码17 项目: hbase   文件: AsyncRegionLocator.java
private boolean isMeta(TableName tableName) {
  return TableName.isMetaTableName(tableName);
}