Java Code Examples for org.apache.hadoop.hbase.TableName#isMetaTableName()
The following examples show how to use
org.apache.hadoop.hbase.TableName#isMetaTableName() .
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: RegionsRecoveryChore.java From hbase with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: AsyncRegionLocator.java From hbase with Apache License 2.0 | 5 votes |
@VisibleForTesting int getNumberOfCachedRegionLocations(TableName tableName) { if (TableName.isMetaTableName(tableName)) { return metaRegionLocator.getNumberOfCachedRegionLocations(); } else { return nonMetaRegionLocator.getNumberOfCachedRegionLocations(tableName); } }
Example 3
Source File: RegionRemoteProcedureBase.java From hbase with Apache License 2.0 | 5 votes |
@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); }
Example 4
Source File: TransitRegionStateProcedure.java From hbase with Apache License 2.0 | 5 votes |
@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()); }
Example 5
Source File: MasterProcedureUtil.java From hbase with Apache License 2.0 | 5 votes |
/** * 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 6
Source File: TableStateManager.java From hbase with Apache License 2.0 | 5 votes |
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()); } } }
Example 7
Source File: AsyncRegionLocator.java From hbase with Apache License 2.0 | 5 votes |
@VisibleForTesting RegionLocations getRegionLocationInCache(TableName tableName, byte[] row) { if (TableName.isMetaTableName(tableName)) { return metaRegionLocator.getRegionLocationInCache(); } else { return nonMetaRegionLocator.getRegionLocationInCache(tableName, row); } }
Example 8
Source File: TestAsyncTableUseMetaReplicas.java From hbase with Apache License 2.0 | 5 votes |
@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"); } }
Example 9
Source File: AsyncTableRegionLocatorImpl.java From hbase with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: RawAsyncHBaseAdmin.java From hbase with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Boolean> tableExists(TableName tableName) { if (TableName.isMetaTableName(tableName)) { return CompletableFuture.completedFuture(true); } return ClientMetaTableAccessor.tableExists(metaTable, tableName); }
Example 11
Source File: RawAsyncHBaseAdmin.java From hbase with Apache License 2.0 | 5 votes |
@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; }
Example 12
Source File: RawAsyncHBaseAdmin.java From hbase with Apache License 2.0 | 5 votes |
@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; }
Example 13
Source File: AsyncClientScanner.java From hbase with Apache License 2.0 | 4 votes |
private long getPrimaryTimeoutNs() { return TableName.isMetaTableName(tableName) ? conn.connConf.getPrimaryMetaScanTimeoutNs() : conn.connConf.getPrimaryScanTimeoutNs(); }
Example 14
Source File: AsyncRegionLocator.java From hbase with Apache License 2.0 | 4 votes |
private boolean isMeta(TableName tableName) { return TableName.isMetaTableName(tableName); }
Example 15
Source File: RawAsyncHBaseAdmin.java From hbase with Apache License 2.0 | 4 votes |
@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; }
Example 16
Source File: RSGroupUtil.java From hbase with Apache License 2.0 | 4 votes |
/** * 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)); }
Example 17
Source File: RegionTransitionProcedure.java From hbase with Apache License 2.0 | 4 votes |
public boolean isMeta() { return TableName.isMetaTableName(getTableName()); }