/** * Gets the online tables in this RS. * This method looks at the in-memory onlineRegions. * @return all the online tables in this RS */ @Override public Set<TableName> getOnlineTables() { Set<TableName> tables = new HashSet<TableName>(); synchronized (this.onlineRegions) { for (Region region: this.onlineRegions.values()) { tables.add(region.getTableDesc().getTableName()); } } return tables; }
/** * 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.getTableDesc().getTableName()); }
@Override public void preMerge(ObserverContext<RegionServerCoprocessorEnvironment> ctx, Region regionA, Region regionB) throws IOException { requirePermission("mergeRegions", regionA.getTableDesc().getTableName(), null, null, Action.ADMIN); }
public static boolean OmidCompactionEnabled(ObserverContext<RegionCoprocessorEnvironment> env, Store store, String cfFlagValue) { HTableDescriptor desc = env.getEnvironment().getRegion().getTableDesc(); HColumnDescriptor famDesc = desc.getFamily(Bytes.toBytes(store.getColumnFamilyName())); return Boolean.valueOf(famDesc.getValue(cfFlagValue)); }
@Override public void start(CoprocessorEnvironment environment) { // make sure we are on a region server if (!(environment instanceof RegionCoprocessorEnvironment)) { throw new IllegalArgumentException( "Constraints only act on regions - started in an environment that was not a region"); } RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) environment; HTableDescriptor desc = env.getRegion().getTableDesc(); // load all the constraints from the HTD try { this.constraints = Constraints.getConstraints(desc, classloader); } catch (IOException e) { throw new IllegalArgumentException(e); } if (LOG.isInfoEnabled()) { LOG.info("Finished loading " + constraints.size() + " user Constraints on table: " + desc.getTableName()); } }
/** * Authorization security check for * SecureBulkLoadProtocol.cleanupBulkLoad() * @param ctx the context * @param request the request * @throws IOException */ @Override public void preCleanupBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx, CleanupBulkLoadRequest request) throws IOException { requireAccess("preCleanupBulkLoad", ctx.getEnvironment().getRegion().getTableDesc().getTableName(), Action.CREATE); }
/** * Authorization check for * SecureBulkLoadProtocol.prepareBulkLoad() * @param ctx the context * @param request the request * @throws IOException */ @Override public void prePrepareBulkLoad(ObserverContext<RegionCoprocessorEnvironment> ctx, PrepareBulkLoadRequest request) throws IOException { requireAccess("prePareBulkLoad", ctx.getEnvironment().getRegion().getTableDesc().getTableName(), Action.CREATE); }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; Supplier<TransactionStateCache> cacheSupplier = getTransactionStateCacheSupplier(env); this.cache = cacheSupplier.get(); HTableDescriptor tableDesc = env.getRegion().getTableDesc(); for (HColumnDescriptor columnDesc : tableDesc.getFamilies()) { String columnTTL = columnDesc.getValue(TxConstants.PROPERTY_TTL); long ttl = 0; if (columnTTL != null) { try { ttl = Long.parseLong(columnTTL); LOG.info("Family " + columnDesc.getNameAsString() + " has TTL of " + columnTTL); } catch (NumberFormatException nfe) { LOG.warn("Invalid TTL value configured for column family " + columnDesc.getNameAsString() + ", value = " + columnTTL); } } ttlByFamily.put(columnDesc.getName(), ttl); } this.allowEmptyValues = env.getConfiguration().getBoolean(TxConstants.ALLOW_EMPTY_VALUES_KEY, TxConstants.ALLOW_EMPTY_VALUES_DEFAULT); this.readNonTxnData = Boolean.valueOf(tableDesc.getValue(TxConstants.READ_NON_TX_DATA)); if (readNonTxnData) { LOG.info("Reading pre-existing data enabled for table " + tableDesc.getNameAsString()); } } }
public static Filter createVisibilityLabelFilter(Region region, Authorizations authorizations) throws IOException { Map<ByteRange, Integer> cfVsMaxVersions = new HashMap<ByteRange, Integer>(); for (HColumnDescriptor hcd : region.getTableDesc().getFamilies()) { cfVsMaxVersions.put(new SimpleMutableByteRange(hcd.getName()), hcd.getMaxVersions()); } VisibilityLabelService vls = VisibilityLabelServiceManager.getInstance() .getVisibilityLabelService(); Filter visibilityLabelFilter = new VisibilityLabelFilter( vls.getVisibilityExpEvaluator(authorizations), cfVsMaxVersions); return visibilityLabelFilter; }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; Supplier<TransactionStateCache> cacheSupplier = getTransactionStateCacheSupplier(env); this.cache = cacheSupplier.get(); HTableDescriptor tableDesc = env.getRegion().getTableDesc(); for (HColumnDescriptor columnDesc : tableDesc.getFamilies()) { String columnTTL = columnDesc.getValue(TxConstants.PROPERTY_TTL); long ttl = 0; if (columnTTL != null) { try { ttl = Long.parseLong(columnTTL); LOG.info("Family " + columnDesc.getNameAsString() + " has TTL of " + columnTTL); } catch (NumberFormatException nfe) { LOG.warn("Invalid TTL value configured for column family " + columnDesc.getNameAsString() + ", value = " + columnTTL); } } ttlByFamily.put(columnDesc.getName(), ttl); } this.allowEmptyValues = env.getConfiguration().getBoolean(TxConstants.ALLOW_EMPTY_VALUES_KEY, TxConstants.ALLOW_EMPTY_VALUES_DEFAULT); this.readNonTxnData = Boolean.valueOf(tableDesc.getValue(TxConstants.READ_NON_TX_DATA)); if (readNonTxnData) { LOG.info("Reading pre-existing data enabled for table " + tableDesc.getNameAsString()); } } }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; HTableDescriptor tableDesc = env.getRegion().getTableDesc(); this.tablePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX); this.cConfCacheSupplier = new CConfigurationCacheSupplier(env, tablePrefix, TxConstants.Manager.CFG_TX_MAX_LIFETIME, TxConstants.Manager.DEFAULT_TX_MAX_LIFETIME); this.cConfCache = cConfCacheSupplier.get(); } // Need to create the cConf cache before calling start on the parent, since it is required for // initializing some properties in the parent class. super.start(e); }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; HTableDescriptor tableDesc = env.getRegion().getTableDesc(); this.tablePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX); this.cConfCacheSupplier = new CConfigurationCacheSupplier(env, tablePrefix, TxConstants.Manager.CFG_TX_MAX_LIFETIME, TxConstants.Manager.DEFAULT_TX_MAX_LIFETIME); this.cConfCache = cConfCacheSupplier.get(); } // Need to create the cConf cache before calling start on the parent, since it is required for // initializing some properties in the parent class. super.start(e); }
/** * Verifies user has CREATE privileges on * the Column Families involved in the bulkLoadHFile * request. Specific Column Write privileges are presently * ignored. */ @Override public void preBulkLoadHFile(ObserverContext<RegionCoprocessorEnvironment> ctx, List<Pair<byte[], String>> familyPaths) throws IOException { for(Pair<byte[],String> el : familyPaths) { requirePermission("preBulkLoadHFile", ctx.getEnvironment().getRegion().getTableDesc().getTableName(), el.getFirst(), null, Action.CREATE); } }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; this.region = ((RegionCoprocessorEnvironment) e).getRegion(); HTableDescriptor tableDesc = region.getTableDesc(); this.state = new IncrementHandlerState(env, tableDesc); for (HColumnDescriptor columnDesc : tableDesc.getFamilies()) { state.initFamily(columnDesc.getName(), convertFamilyValues(columnDesc.getValues())); } } }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; this.region = ((RegionCoprocessorEnvironment) e).getRegion(); HTableDescriptor tableDesc = region.getTableDesc(); this.state = new IncrementHandlerState(env, tableDesc); for (HColumnDescriptor columnDesc : tableDesc.getFamilies()) { state.initFamily(columnDesc.getName(), convertFamilyValues(columnDesc.getValues())); } } }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; HTableDescriptor tableDesc = env.getRegion().getTableDesc(); String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE); String tablePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX); prefixLength = Integer.valueOf(tableDesc.getValue( Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES)); CConfigurationReader cConfReader = new CoprocessorCConfigurationReader(env, tablePrefix); topicMetadataCacheSupplier = new TopicMetadataCacheSupplier( env, cConfReader, tablePrefix, metadataTableNamespace, new HBase12CDH570ScanBuilder()); topicMetadataCache = topicMetadataCacheSupplier.get(); } }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; HTableDescriptor tableDesc = env.getRegion().getTableDesc(); String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE); String tablePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX); prefixLength = Integer.valueOf(tableDesc.getValue( Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES)); CConfigurationReader cConfReader = new CoprocessorCConfigurationReader(env, tablePrefix); topicMetadataCacheSupplier = new TopicMetadataCacheSupplier( env, cConfReader, tablePrefix, metadataTableNamespace, new HBase11ScanBuilder()); topicMetadataCache = topicMetadataCacheSupplier.get(); } }
@Override @QosPriority(priority=HConstants.ADMIN_QOS) public GetStoreFileResponse getStoreFile(final RpcController controller, final GetStoreFileRequest request) throws ServiceException { try { checkOpen(); Region region = getRegion(request.getRegion()); requestCount.increment(); Set<byte[]> columnFamilies; if (request.getFamilyCount() == 0) { columnFamilies = region.getTableDesc().getFamiliesKeys(); } else { columnFamilies = new TreeSet<byte[]>(Bytes.BYTES_RAWCOMPARATOR); for (ByteString cf: request.getFamilyList()) { columnFamilies.add(cf.toByteArray()); } } int nCF = columnFamilies.size(); List<String> fileList = region.getStoreFileList( columnFamilies.toArray(new byte[nCF][])); GetStoreFileResponse.Builder builder = GetStoreFileResponse.newBuilder(); builder.addAllStoreFile(fileList); return builder.build(); } catch (IOException ie) { throw new ServiceException(ie); } }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; HTableDescriptor tableDesc = env.getRegion().getTableDesc(); String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE); prefixLength = Integer.valueOf(tableDesc.getValue( Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES)); String tablePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX); CConfigurationReader cConfReader = new CoprocessorCConfigurationReader(env, tablePrefix); txStateCacheSupplier = new DefaultTransactionStateCacheSupplier(tablePrefix, env); txStateCache = txStateCacheSupplier.get(); topicMetadataCacheSupplier = new TopicMetadataCacheSupplier( env, cConfReader, tablePrefix, metadataTableNamespace, new HBase12CDH570ScanBuilder()); topicMetadataCache = topicMetadataCacheSupplier.get(); } }
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; HTableDescriptor tableDesc = env.getRegion().getTableDesc(); String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE); prefixLength = Integer.valueOf(tableDesc.getValue( Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES)); String tablePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX); CConfigurationReader cConfReader = new CoprocessorCConfigurationReader(env, tablePrefix); txStateCacheSupplier = new DefaultTransactionStateCacheSupplier(tablePrefix, env); txStateCache = txStateCacheSupplier.get(); topicMetadataCacheSupplier = new TopicMetadataCacheSupplier( env, cConfReader, tablePrefix, metadataTableNamespace, new HBase11ScanBuilder()); topicMetadataCache = topicMetadataCacheSupplier.get(); } }