org.apache.hadoop.hbase.TableName.getNamespaceAsString()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(289)

本文整理了Java中org.apache.hadoop.hbase.TableName.getNamespaceAsString()方法的一些代码示例,展示了TableName.getNamespaceAsString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableName.getNamespaceAsString()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.TableName
类名称:TableName
方法名:getNamespaceAsString

TableName.getNamespaceAsString介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

  1. public Set<String> getNamespacesWithQuotas() {
  2. Set<String> namespaces = new HashSet<>();
  3. for (TableName tn : tablesWithNamespaceQuotas) {
  4. namespaces.add(tn.getNamespaceAsString());
  5. }
  6. return namespaces;
  7. }

代码示例来源:origin: apache/hbase

  1. private void addTable(TableName tableName, int regionCount) throws IOException {
  2. NamespaceTableAndRegionInfo info =
  3. nsStateCache.get(tableName.getNamespaceAsString());
  4. if(info != null) {
  5. info.addTable(tableName, regionCount);
  6. } else {
  7. throw new IOException("Bad state : Namespace quota information not found for namespace : "
  8. + tableName.getNamespaceAsString());
  9. }
  10. }

代码示例来源:origin: apache/hbase

  1. synchronized void addTable(TableName tableName, int regionCount) {
  2. if (!name.equalsIgnoreCase(tableName.getNamespaceAsString())) {
  3. throw new IllegalStateException("Table : " + tableName + " does not belong to namespace "
  4. + name);
  5. }
  6. if (!tableAndRegionInfo.containsKey(tableName)) {
  7. tableAndRegionInfo.put(tableName, new AtomicInteger(regionCount));
  8. } else {
  9. throw new IllegalStateException("Table already in the cache " + tableName);
  10. }
  11. }

代码示例来源:origin: apache/hbase

  1. synchronized void removeTable(TableName tableName) {
  2. NamespaceTableAndRegionInfo info =
  3. nsStateCache.get(tableName.getNamespaceAsString());
  4. if (info != null) {
  5. info.removeTable(tableName);
  6. }
  7. }

代码示例来源:origin: apache/hbase

  1. @Override
  2. public boolean apply(Entry<RegionInfo,Long> input) {
  3. return namespace.equals(input.getKey().getTable().getNamespaceAsString());
  4. }
  5. });

代码示例来源:origin: apache/hbase

  1. @VisibleForTesting
  2. public static String qualifyMetricsName(TableName tableName, String metric) {
  3. StringBuilder sb = new StringBuilder();
  4. sb.append("Namespace_").append(tableName.getNamespaceAsString());
  5. sb.append("_table_").append(tableName.getQualifierAsString());
  6. sb.append("_metric_").append(metric);
  7. return sb.toString();
  8. }

代码示例来源:origin: apache/hbase

  1. private String getHFilePath(TableName table, BulkLoadDescriptor bld, String storeFile,
  2. byte[] family) {
  3. return new StringBuilder(100).append(table.getNamespaceAsString()).append(Path.SEPARATOR)
  4. .append(table.getQualifierAsString()).append(Path.SEPARATOR)
  5. .append(Bytes.toString(bld.getEncodedRegionName().toByteArray())).append(Path.SEPARATOR)
  6. .append(Bytes.toString(family)).append(Path.SEPARATOR).append(storeFile).toString();
  7. }

代码示例来源:origin: apache/hbase

  1. /**
  2. * Returns the Table directory under the WALRootDir for the specified table name
  3. * @param conf configuration used to get the WALRootDir
  4. * @param tableName Table to get the directory for
  5. * @return a path to the WAL table directory for the specified table
  6. * @throws IOException if there is an exception determining the WALRootDir
  7. */
  8. public static Path getWALTableDir(final Configuration conf, final TableName tableName)
  9. throws IOException {
  10. return new Path(new Path(getWALRootDir(conf), tableName.getNamespaceAsString()),
  11. tableName.getQualifierAsString());
  12. }

代码示例来源:origin: apache/hbase

  1. protected Path getBulkOutputDirForTable(TableName table) {
  2. Path tablePath = getBulkOutputDir();
  3. tablePath = new Path(tablePath, table.getNamespaceAsString());
  4. tablePath = new Path(tablePath, table.getQualifierAsString());
  5. return new Path(tablePath, "data");
  6. }

代码示例来源:origin: apache/hbase

  1. /**
  2. * Ideally, getNameAsString should contain namespace within it,
  3. * but if the namespace is default, it just returns the name. This method
  4. * takes care of this corner case.
  5. */
  6. public String getNameWithNamespaceInclAsString() {
  7. if(getNamespaceAsString().equals(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR)) {
  8. return NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR +
  9. TableName.NAMESPACE_DELIM + getNameAsString();
  10. }
  11. return getNameAsString();
  12. }

代码示例来源:origin: apache/hbase

  1. /**
  2. * Returns the {@link org.apache.hadoop.fs.Path} object representing the table directory under
  3. * path rootdir
  4. *
  5. * @param rootdir qualified path of HBase root directory
  6. * @param tableName name of table
  7. * @return {@link org.apache.hadoop.fs.Path} for table
  8. */
  9. public static Path getTableDir(Path rootdir, final TableName tableName) {
  10. return new Path(getNamespaceDir(rootdir, tableName.getNamespaceAsString()),
  11. tableName.getQualifierAsString());
  12. }

代码示例来源:origin: apache/hbase

  1. public MetricsTableSourceImpl(String tblName,
  2. MetricsTableAggregateSourceImpl aggregate, MetricsTableWrapperAggregate tblWrapperAgg) {
  3. LOG.debug("Creating new MetricsTableSourceImpl for table '{}'", tblName);
  4. this.tableName = TableName.valueOf(tblName);
  5. this.agg = aggregate;
  6. this.tableWrapperAgg = tblWrapperAgg;
  7. this.registry = agg.getMetricsRegistry();
  8. this.tableNamePrefix = "Namespace_" + this.tableName.getNamespaceAsString() +
  9. "_table_" + this.tableName.getQualifierAsString() + "_metric_";
  10. this.hashCode = this.tableName.hashCode();
  11. }

代码示例来源:origin: apache/hbase

  1. public synchronized void removeRegionFromTable(RegionInfo hri) throws IOException {
  2. String namespace = hri.getTable().getNamespaceAsString();
  3. NamespaceTableAndRegionInfo nsInfo = nsStateCache.get(namespace);
  4. if (nsInfo != null) {
  5. nsInfo.decrementRegionCountForTable(hri.getTable(), 1);
  6. } else {
  7. throw new IOException("Namespace state found null for namespace : " + namespace);
  8. }
  9. }
  10. }

代码示例来源:origin: apache/hbase

  1. /**
  2. * Returns a view of all tables that reside in a namespace with a namespace
  3. * quota, grouped by the namespace itself.
  4. */
  5. public Multimap<String,TableName> getTablesByNamespace() {
  6. Multimap<String,TableName> tablesByNS = HashMultimap.create();
  7. for (TableName tn : tablesWithNamespaceQuotas) {
  8. tablesByNS.put(tn.getNamespaceAsString(), tn);
  9. }
  10. return tablesByNS;
  11. }

代码示例来源:origin: apache/hbase

  1. @Override
  2. public String getNamespace() {
  3. TableDescriptor tableDesc = this.region.getTableDescriptor();
  4. if (tableDesc == null) {
  5. return UNKNOWN;
  6. }
  7. return tableDesc.getTableName().getNamespaceAsString();
  8. }

代码示例来源:origin: apache/hbase

  1. /*********************************** Observer implementations ***********************************/
  2. @Override
  3. public void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> c,
  4. TableDescriptor desc, RegionInfo[] regions) throws IOException {
  5. Set<byte[]> families = desc.getColumnFamilyNames();
  6. Map<byte[], Set<byte[]>> familyMap = new TreeMap<>(Bytes.BYTES_COMPARATOR);
  7. for (byte[] family: families) {
  8. familyMap.put(family, null);
  9. }
  10. requireNamespacePermission(c, "createTable",
  11. desc.getTableName().getNamespaceAsString(), desc.getTableName(), familyMap, Action.CREATE);
  12. }

代码示例来源:origin: apache/hbase

  1. private TableQueue getTableQueue(TableName tableName) {
  2. TableQueue node = AvlTree.get(tableMap, tableName, TABLE_QUEUE_KEY_COMPARATOR);
  3. if (node != null) return node;
  4. node = new TableQueue(tableName, MasterProcedureUtil.getTablePriority(tableName),
  5. locking.getTableLock(tableName), locking.getNamespaceLock(tableName.getNamespaceAsString()));
  6. tableMap = AvlTree.insert(tableMap, node);
  7. return node;
  8. }

代码示例来源:origin: apache/hbase

  1. @Override
  2. public boolean evaluate() throws Exception {
  3. SpaceQuotaSnapshot snapshot = (SpaceQuotaSnapshot) conn.getAdmin()
  4. .getCurrentSpaceQuotaSnapshot(tn.getNamespaceAsString());
  5. LOG.debug("Namespace snapshot after initial ingest: " + snapshot);
  6. if (snapshot == null) {
  7. return false;
  8. }
  9. nsUsage.set(snapshot.getUsage());
  10. return snapshot.getLimit() == nsLimit && snapshot.getUsage() > 0;
  11. }
  12. });

代码示例来源:origin: apache/hbase

  1. @Override
  2. public boolean evaluate() throws Exception {
  3. SpaceQuotaSnapshot snapshot = (SpaceQuotaSnapshot) conn.getAdmin()
  4. .getCurrentSpaceQuotaSnapshot(tn.getNamespaceAsString());
  5. LOG.debug("Namespace snapshot after second ingest: " + snapshot);
  6. if (snapshot == null) {
  7. return false;
  8. }
  9. return snapshot.getUsage() > nsUsage.get() && !snapshot.getQuotaStatus().isInViolation();
  10. }
  11. });

代码示例来源:origin: apache/hbase

  1. private TableName validateNames(TableName expected, Names names) {
  2. assertEquals(expected.getNameAsString(), names.nn);
  3. assertArrayEquals(expected.getName(), names.nnb);
  4. assertEquals(expected.getQualifierAsString(), names.tn);
  5. assertArrayEquals(expected.getQualifier(), names.tnb);
  6. assertEquals(expected.getNamespaceAsString(), names.ns);
  7. assertArrayEquals(expected.getNamespace(), names.nsb);
  8. return expected;
  9. }

相关文章