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

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

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

TableName.getName介绍

[英]Ideally, getNameAsString should contain namespace within it, but if the namespace is default, it just returns the name. This method takes care of this corner case.
[中]理想情况下,getNameAsString应该包含名称空间,但如果名称空间是默认名称空间,则只返回名称。这种方法可以解决这个问题。

代码示例

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

  1. /**
  2. * Returns the table name converted to a byte array.
  3. * @see #getTable()
  4. * @return The table name.
  5. */
  6. public byte [] getTableName() {
  7. return tableName.getName();
  8. }

代码示例来源: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. }

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

  1. private void setHashCode() {
  2. int result = Arrays.hashCode(this.regionName);
  3. result = (int) (result ^ this.regionId);
  4. result ^= Arrays.hashCode(this.startKey);
  5. result ^= Arrays.hashCode(this.endKey);
  6. result ^= Boolean.valueOf(this.offLine).hashCode();
  7. result ^= Arrays.hashCode(this.tableName.getName());
  8. result ^= this.replicaId;
  9. this.hashCode = result;
  10. }

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

  1. /**
  2. * Gets the table name used in the table lock.
  3. * The table lock name is a dummy one, it's not a table name. It's tableName + ".mobLock".
  4. * @param tn The table name.
  5. * @return The table name used in table lock.
  6. */
  7. public static TableName getTableLockName(TableName tn) {
  8. byte[] tableName = tn.getName();
  9. return TableName.valueOf(Bytes.add(tableName, MobConstants.MOB_TABLE_LOCK_SUFFIX));
  10. }

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

  1. /**
  2. * Returns the currently granted permissions for a given table as the specified user plus
  3. * associated permissions.
  4. */
  5. static List<UserPermission> getUserTablePermissions(Configuration conf, TableName tableName,
  6. byte[] cf, byte[] cq, String userName, boolean hasFilterUser) throws IOException {
  7. return getUserPermissions(conf, tableName == null ? null : tableName.getName(), cf, cq,
  8. userName, hasFilterUser);
  9. }

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

  1. /**
  2. * @return Name of this table and then a map of all of the column family
  3. * descriptors (with only the non-default column family attributes)
  4. */
  5. @Override
  6. public String toStringCustomizedValues() {
  7. StringBuilder s = new StringBuilder();
  8. s.append('\'').append(Bytes.toString(name.getName())).append('\'');
  9. s.append(getValues(false));
  10. families.values().forEach(hcd -> s.append(", ").append(hcd.toStringCustomizedValues()));
  11. return s.toString();
  12. }

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

  1. private static int generateHashCode(final TableName tableName, final byte[] startKey,
  2. final byte[] endKey, final long regionId,
  3. final int replicaId, boolean offLine, byte[] regionName) {
  4. int result = Arrays.hashCode(regionName);
  5. result = (int) (result ^ regionId);
  6. result ^= Arrays.hashCode(checkStartKey(startKey));
  7. result ^= Arrays.hashCode(checkEndKey(endKey));
  8. result ^= Boolean.valueOf(offLine).hashCode();
  9. result ^= Arrays.hashCode(tableName.getName());
  10. result ^= replicaId;
  11. return result;
  12. }

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

  1. ArrayList<RegionStateNode> getTableRegionStateNodes(final TableName tableName) {
  2. final ArrayList<RegionStateNode> regions = new ArrayList<RegionStateNode>();
  3. for (RegionStateNode node: regionsMap.tailMap(tableName.getName()).values()) {
  4. if (!node.getTable().equals(tableName)) break;
  5. regions.add(node);
  6. }
  7. return regions;
  8. }

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

  1. static Put createPutForBulkLoadedFile(TableName tn, byte[] fam, String p, String backupId,
  2. long ts, int idx) {
  3. Put put = new Put(rowkey(BULK_LOAD_PREFIX, backupId + BLK_LD_DELIM + ts + BLK_LD_DELIM + idx));
  4. put.addColumn(BackupSystemTable.META_FAMILY, TBL_COL, tn.getName());
  5. put.addColumn(BackupSystemTable.META_FAMILY, FAM_COL, fam);
  6. put.addColumn(BackupSystemTable.META_FAMILY, PATH_COL, p.getBytes());
  7. return put;
  8. }

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

  1. ArrayList<RegionInfo> getTableRegionsInfo(final TableName tableName) {
  2. final ArrayList<RegionInfo> regions = new ArrayList<RegionInfo>();
  3. for (RegionStateNode node: regionsMap.tailMap(tableName.getName()).values()) {
  4. if (!node.getTable().equals(tableName)) break;
  5. regions.add(node.getRegionInfo());
  6. }
  7. return regions;
  8. }

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

  1. /**
  2. * Wait until all regions in a table have been assigned. Waits default timeout before giving up
  3. * (30 seconds).
  4. * @param table Table to wait on.
  5. * @throws InterruptedException
  6. * @throws IOException
  7. */
  8. public void waitTableAvailable(TableName table)
  9. throws InterruptedException, IOException {
  10. waitTableAvailable(table.getName(), 30000);
  11. }

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

  1. ArrayList<RegionState> getTableRegionStates(final TableName tableName) {
  2. final ArrayList<RegionState> regions = new ArrayList<RegionState>();
  3. for (RegionStateNode node: regionsMap.tailMap(tableName.getName()).values()) {
  4. if (!node.getTable().equals(tableName)) break;
  5. regions.add(node.toRegionState());
  6. }
  7. return regions;
  8. }

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

  1. @Override
  2. public boolean visit(Result r) throws IOException {
  3. if (!Arrays.equals(r.getRow(), table.getName()))
  4. return false;
  5. TableState state = MetaTableAccessor.getTableState(r);
  6. if (state != null)
  7. lastTableState.set(state);
  8. return true;
  9. }
  10. };

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

  1. public void write(DataOutput out) throws IOException {
  2. Bytes.writeByteArray(out, this.m_tableName.getName());
  3. Bytes.writeByteArray(out, this.m_startRow);
  4. Bytes.writeByteArray(out, this.m_endRow);
  5. Bytes.writeByteArray(out, Bytes.toBytes(this.m_regionLocation));
  6. }

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

  1. /**
  2. * Construct PUT for given state
  3. * @param state new state
  4. */
  5. public static Put makePutFromTableState(TableState state, long ts) {
  6. Put put = new Put(state.getTableName().getName(), ts);
  7. put.addColumn(getTableFamily(), getTableStateColumn(), state.convert().toByteArray());
  8. return put;
  9. }

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

  1. private Table createTable()
  2. throws IOException, InterruptedException {
  3. final TableName tableName = TableName.valueOf(name.getMethodName());
  4. Table table = TEST_UTIL.createTable(tableName, FAMILY);
  5. TEST_UTIL.waitTableAvailable(tableName.getName(), 5000);
  6. return table;
  7. }

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

  1. private void loadData(TableName table, int numRows) throws IOException {
  2. Connection conn = util.getConnection();
  3. // #0- insert some data to a table
  4. Table t1 = conn.getTable(table);
  5. util.loadRandomRows(t1, new byte[]{'f'}, 100, numRows);
  6. // flush table
  7. conn.getAdmin().flush(TableName.valueOf(table.getName()));
  8. }

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

  1. @Override
  2. public Object run() throws Exception {
  3. try (Connection conn = ConnectionFactory.createConnection(conf);
  4. Table acl = conn.getTable(AccessControlLists.ACL_TABLE_NAME)) {
  5. BlockingRpcChannel service = acl.coprocessorService(TEST_TABLE.getName());
  6. AccessControlService.BlockingInterface protocol =
  7. AccessControlService.newBlockingStub(service);
  8. AccessControlUtil.getUserPermissions(null, protocol, Bytes.toBytes(namespace1), "dummy");
  9. }
  10. return null;
  11. }
  12. };

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

  1. @Override
  2. public Object run() throws Exception {
  3. try(Connection conn = ConnectionFactory.createConnection(conf);
  4. Table acl = conn.getTable(AccessControlLists.ACL_TABLE_NAME)){
  5. BlockingRpcChannel service = acl.coprocessorService(TEST_TABLE.getName());
  6. AccessControlService.BlockingInterface protocol =
  7. AccessControlService.newBlockingStub(service);
  8. AccessControlUtil.getUserPermissions(null, protocol, TEST_TABLE);
  9. }
  10. return null;
  11. }
  12. };

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

  1. @Override
  2. public Object run() throws Exception {
  3. try (Connection conn = ConnectionFactory.createConnection(conf);
  4. Table acl = conn.getTable(AccessControlLists.ACL_TABLE_NAME)) {
  5. BlockingRpcChannel service = acl.coprocessorService(TEST_TABLE.getName());
  6. AccessControlService.BlockingInterface protocol =
  7. AccessControlService.newBlockingStub(service);
  8. AccessControlUtil.getUserPermissions(null, protocol, "dummy");
  9. }
  10. return null;
  11. }
  12. };

相关文章