/** * Drop this instance's tablename byte array and instead * hold a reference to the provided tablename. This is not * meant to be a general purpose setter - it's only used * to collapse references to conserve memory. */ void internTableName(TableName tablename) { // We should not use this as a setter - only to swap // in a new reference to the same table name. assert tablename.equals(this.tablename); this.tablename = tablename; }
@Override public boolean equals(Object o) { if (!(o instanceof CacheKey)) { return false; } CacheKey other = (CacheKey) o; // TableName should be the only thing differing.. return tn.equals(other.tn) && conn.equals(other.conn) && conf.equals(other.conf) && fs.equals(other.fs); }
@Override public boolean apply(Entry<RegionInfo,Long> input) { return table.equals(input.getKey().getTable()); } });
/** @return true if this region is a meta region */ @Override public boolean isMetaRegion() { return tableName.equals(FIRST_META_REGIONINFO.getTable()); }
@Override public boolean equals(Object o) { if (o == null || !(o instanceof TableSplit)) { return false; } return tableName.equals(((TableSplit)o).tableName) && Bytes.equals(startRow, ((TableSplit)o).startRow) && Bytes.equals(endRow, ((TableSplit)o).endRow) && regionLocation.equals(((TableSplit)o).regionLocation); }
@Override public CompletableFuture<List<RegionInfo>> getRegions(TableName tableName) { if (tableName.equals(META_TABLE_NAME)) { return connection.getLocator().getRegionLocation(tableName, null, null, operationTimeoutNs) .thenApply(loc -> Collections.singletonList(loc.getRegion())); } else { return AsyncMetaTableAccessor.getTableHRegionLocations(metaTable, Optional.of(tableName)) .thenApply( locs -> locs.stream().map(loc -> loc.getRegion()).collect(Collectors.toList())); } }
/** * Returns {@code true} if the given region is part of the {@code _acl_} * metadata table. */ static boolean isAclRegion(Region region) { return ACL_TABLE_NAME.equals(region.getTableDescriptor().getTableName()); }
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; }
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; }
private int countRegionsForTable(TableName tn, Map<RegionInfo,Long> regionSizes) { int size = 0; for (RegionInfo regionInfo : regionSizes.keySet()) { if (tn.equals(regionInfo.getTable())) { size++; } } return size; }
@Override public Optional<Pair<String, String>> getPeerIdAndRemoteWALDir(TableName table) { if (table != null && table.equals(TABLE)) { return Optional.of(Pair.newPair(PEER_ID, REMOTE_WAL_DIR)); } else { return Optional.empty(); } }
private int getRegionReportsForTable(Map<RegionInfo,Long> reports, TableName tn) { int numReports = 0; for (Entry<RegionInfo,Long> entry : reports.entrySet()) { if (tn.equals(entry.getKey().getTable())) { numReports++; } } return numReports; } }
private List<HRegion> getRegionInfo(HRegionServer rs) { return rs.getRegions().stream() .filter(v -> v.getTableDescriptor().getTableName().equals(tableName)) .collect(Collectors.toList()); } }
@Override public boolean visit(Result r) throws IOException { if (MetaTableAccessor.getRegionInfo(r).getTable().equals(table)) count.incrementAndGet(); return true; } };
@Override public void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> env, TableDescriptor desc, RegionInfo[] regions) throws IOException { if (desc.getTableName().equals(TABLE)) { throw new AccessDeniedException("Don't allow creation of table"); } }
@Override public void preCreateTableAction( final ObserverContext<MasterCoprocessorEnvironment> ctx, final TableDescriptor desc, final RegionInfo[] regions) throws IOException { if (desc.getTableName().equals(TABLE)) { throw new AccessDeniedException("Don't allow creation of table"); } }
@Override public void postWALWrite(ObserverContext<? extends WALCoprocessorEnvironment> ctx, RegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException { // only keep primary region's edits if (logKey.getTableName().equals(tableName) && info.getReplicaId() == 0) { // Presume type is a WALKeyImpl entries.add(new Entry((WALKeyImpl)logKey, logEdit)); } } }
protected boolean isTestTable(FakeRSRpcServices rpcServices, HBaseProtos.RegionSpecifier regionSpec) throws ServiceException { try { return TABLE_NAME.equals( rpcServices.getRegion(regionSpec).getTableDescriptor().getTableName()); } catch (IOException ioe) { throw new ServiceException(ioe); } }
@Override public void init(RegionCoprocessorEnvironment e) throws IOException { this.scanLabelGenerators = VisibilityUtils.getScanLabelGenerators(this.conf); if (e.getRegion().getRegionInfo().getTable().equals(LABELS_TABLE_NAME)) { this.labelsRegion = e.getRegion(); } }
@Test public void testGetTableDescriptor() throws Exception { ThriftHBaseServiceHandler handler = createHandler(); TTableDescriptor tableDescriptor = handler .getTableDescriptor(ThriftUtilities.tableNameFromHBase(TableName.valueOf(tableAname))); TableDescriptor table = ThriftUtilities.tableDescriptorFromThrift(tableDescriptor); assertTrue(table.getTableName().equals(TableName.valueOf(tableAname))); assertTrue(table.getColumnFamilies().length == 2); assertTrue(table.getColumnFamily(familyAname).getMaxVersions() == 3); assertTrue(table.getColumnFamily(familyBname).getMaxVersions() == 2); }