/** * Returns the table name converted to a byte array. * @see #getTable() * @return The table name. */ public byte [] getTableName() { return tableName.getName(); }
private TableName validateNames(TableName expected, Names names) { assertEquals(expected.getNameAsString(), names.nn); assertArrayEquals(expected.getName(), names.nnb); assertEquals(expected.getQualifierAsString(), names.tn); assertArrayEquals(expected.getQualifier(), names.tnb); assertEquals(expected.getNamespaceAsString(), names.ns); assertArrayEquals(expected.getNamespace(), names.nsb); return expected; }
private void setHashCode() { int result = Arrays.hashCode(this.regionName); result = (int) (result ^ this.regionId); result ^= Arrays.hashCode(this.startKey); result ^= Arrays.hashCode(this.endKey); result ^= Boolean.valueOf(this.offLine).hashCode(); result ^= Arrays.hashCode(this.tableName.getName()); result ^= this.replicaId; this.hashCode = result; }
/** * Gets the table name used in the table lock. * The table lock name is a dummy one, it's not a table name. It's tableName + ".mobLock". * @param tn The table name. * @return The table name used in table lock. */ public static TableName getTableLockName(TableName tn) { byte[] tableName = tn.getName(); return TableName.valueOf(Bytes.add(tableName, MobConstants.MOB_TABLE_LOCK_SUFFIX)); }
/** * Returns the currently granted permissions for a given table as the specified user plus * associated permissions. */ static List<UserPermission> getUserTablePermissions(Configuration conf, TableName tableName, byte[] cf, byte[] cq, String userName, boolean hasFilterUser) throws IOException { return getUserPermissions(conf, tableName == null ? null : tableName.getName(), cf, cq, userName, hasFilterUser); }
/** * @return Name of this table and then a map of all of the column family * descriptors (with only the non-default column family attributes) */ @Override public String toStringCustomizedValues() { StringBuilder s = new StringBuilder(); s.append('\'').append(Bytes.toString(name.getName())).append('\''); s.append(getValues(false)); families.values().forEach(hcd -> s.append(", ").append(hcd.toStringCustomizedValues())); return s.toString(); }
private static int generateHashCode(final TableName tableName, final byte[] startKey, final byte[] endKey, final long regionId, final int replicaId, boolean offLine, byte[] regionName) { int result = Arrays.hashCode(regionName); result = (int) (result ^ regionId); result ^= Arrays.hashCode(checkStartKey(startKey)); result ^= Arrays.hashCode(checkEndKey(endKey)); result ^= Boolean.valueOf(offLine).hashCode(); result ^= Arrays.hashCode(tableName.getName()); result ^= replicaId; return result; }
ArrayList<RegionStateNode> getTableRegionStateNodes(final TableName tableName) { final ArrayList<RegionStateNode> regions = new ArrayList<RegionStateNode>(); for (RegionStateNode node: regionsMap.tailMap(tableName.getName()).values()) { if (!node.getTable().equals(tableName)) break; regions.add(node); } return regions; }
static Put createPutForBulkLoadedFile(TableName tn, byte[] fam, String p, String backupId, long ts, int idx) { Put put = new Put(rowkey(BULK_LOAD_PREFIX, backupId + BLK_LD_DELIM + ts + BLK_LD_DELIM + idx)); put.addColumn(BackupSystemTable.META_FAMILY, TBL_COL, tn.getName()); put.addColumn(BackupSystemTable.META_FAMILY, FAM_COL, fam); put.addColumn(BackupSystemTable.META_FAMILY, PATH_COL, p.getBytes()); return put; }
ArrayList<RegionInfo> getTableRegionsInfo(final TableName tableName) { final ArrayList<RegionInfo> regions = new ArrayList<RegionInfo>(); for (RegionStateNode node: regionsMap.tailMap(tableName.getName()).values()) { if (!node.getTable().equals(tableName)) break; regions.add(node.getRegionInfo()); } return regions; }
/** * Wait until all regions in a table have been assigned. Waits default timeout before giving up * (30 seconds). * @param table Table to wait on. * @throws InterruptedException * @throws IOException */ public void waitTableAvailable(TableName table) throws InterruptedException, IOException { waitTableAvailable(table.getName(), 30000); }
ArrayList<RegionState> getTableRegionStates(final TableName tableName) { final ArrayList<RegionState> regions = new ArrayList<RegionState>(); for (RegionStateNode node: regionsMap.tailMap(tableName.getName()).values()) { if (!node.getTable().equals(tableName)) break; regions.add(node.toRegionState()); } return regions; }
@Override public boolean visit(Result r) throws IOException { if (!Arrays.equals(r.getRow(), table.getName())) return false; TableState state = MetaTableAccessor.getTableState(r); if (state != null) lastTableState.set(state); return true; } };
public void write(DataOutput out) throws IOException { Bytes.writeByteArray(out, this.m_tableName.getName()); Bytes.writeByteArray(out, this.m_startRow); Bytes.writeByteArray(out, this.m_endRow); Bytes.writeByteArray(out, Bytes.toBytes(this.m_regionLocation)); }
/** * Construct PUT for given state * @param state new state */ public static Put makePutFromTableState(TableState state, long ts) { Put put = new Put(state.getTableName().getName(), ts); put.addColumn(getTableFamily(), getTableStateColumn(), state.convert().toByteArray()); return put; }
private Table createTable() throws IOException, InterruptedException { final TableName tableName = TableName.valueOf(name.getMethodName()); Table table = TEST_UTIL.createTable(tableName, FAMILY); TEST_UTIL.waitTableAvailable(tableName.getName(), 5000); return table; }
private void loadData(TableName table, int numRows) throws IOException { Connection conn = util.getConnection(); // #0- insert some data to a table Table t1 = conn.getTable(table); util.loadRandomRows(t1, new byte[]{'f'}, 100, numRows); // flush table conn.getAdmin().flush(TableName.valueOf(table.getName())); }
@Override public Object run() throws Exception { try (Connection conn = ConnectionFactory.createConnection(conf); Table acl = conn.getTable(AccessControlLists.ACL_TABLE_NAME)) { BlockingRpcChannel service = acl.coprocessorService(TEST_TABLE.getName()); AccessControlService.BlockingInterface protocol = AccessControlService.newBlockingStub(service); AccessControlUtil.getUserPermissions(null, protocol, Bytes.toBytes(namespace1), "dummy"); } return null; } };
@Override public Object run() throws Exception { try(Connection conn = ConnectionFactory.createConnection(conf); Table acl = conn.getTable(AccessControlLists.ACL_TABLE_NAME)){ BlockingRpcChannel service = acl.coprocessorService(TEST_TABLE.getName()); AccessControlService.BlockingInterface protocol = AccessControlService.newBlockingStub(service); AccessControlUtil.getUserPermissions(null, protocol, TEST_TABLE); } return null; } };
@Override public Object run() throws Exception { try (Connection conn = ConnectionFactory.createConnection(conf); Table acl = conn.getTable(AccessControlLists.ACL_TABLE_NAME)) { BlockingRpcChannel service = acl.coprocessorService(TEST_TABLE.getName()); AccessControlService.BlockingInterface protocol = AccessControlService.newBlockingStub(service); AccessControlUtil.getUserPermissions(null, protocol, "dummy"); } return null; } };