use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestHDFSAclHelper method createNamespace.
static void createNamespace(HBaseTestingUtil util, String namespace) throws IOException {
if (Arrays.stream(util.getAdmin().listNamespaceDescriptors()).noneMatch(ns -> ns.getName().equals(namespace))) {
NamespaceDescriptor namespaceDescriptor = NamespaceDescriptor.create(namespace).build();
util.getAdmin().createNamespace(namespaceDescriptor);
}
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class RSGroupInfoManagerImpl method removeRSGroup.
@Override
public synchronized void removeRSGroup(String groupName) throws IOException {
RSGroupInfo rsGroupInfo = getRSGroupInfo(groupName);
int serverCount = rsGroupInfo.getServers().size();
if (serverCount > 0) {
throw new ConstraintException("RSGroup " + groupName + " has " + serverCount + " servers; you must remove these servers from the RSGroup before" + " the RSGroup can be removed.");
}
for (TableDescriptor td : masterServices.getTableDescriptors().getAll().values()) {
if (td.getRegionServerGroup().map(groupName::equals).orElse(false)) {
throw new ConstraintException("RSGroup " + groupName + " is already referenced by " + td.getTableName() + "; you must remove all the tables from the RSGroup before " + "the RSGroup can be removed.");
}
}
for (NamespaceDescriptor ns : masterServices.getClusterSchema().getNamespaces()) {
String nsGroup = ns.getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP);
if (nsGroup != null && nsGroup.equals(groupName)) {
throw new ConstraintException("RSGroup " + groupName + " is referenced by namespace: " + ns.getName());
}
}
Map<String, RSGroupInfo> rsGroupMap = holder.groupName2Group;
if (!rsGroupMap.containsKey(groupName) || groupName.equals(RSGroupInfo.DEFAULT_GROUP)) {
throw new ConstraintException("Group " + groupName + " does not exist or is a reserved " + "group");
}
Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap);
newGroupMap.remove(groupName);
flushConfig(newGroupMap);
LOG.info("Remove group {} done", groupName);
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestSnapshotQuotaObserverChore method testSnapshotsFromNamespaces.
@Test
public void testSnapshotsFromNamespaces() throws Exception {
NamespaceDescriptor ns = NamespaceDescriptor.create("snapshots_from_namespaces").build();
admin.createNamespace(ns);
TableName tn1 = helper.createTableWithRegions(ns.getName(), 1);
TableName tn2 = helper.createTableWithRegions(ns.getName(), 1);
TableName tn3 = helper.createTableWithRegions(1);
// Set a throttle quota on 'default' namespace
admin.setQuota(QuotaSettingsFactory.throttleNamespace(tn3.getNamespaceAsString(), ThrottleType.WRITE_NUMBER, 100, TimeUnit.SECONDS));
// Set a user throttle quota
admin.setQuota(QuotaSettingsFactory.throttleUser("user", ThrottleType.WRITE_NUMBER, 100, TimeUnit.MINUTES));
// Set a space quota on the namespace
admin.setQuota(QuotaSettingsFactory.limitNamespaceSpace(ns.getName(), SpaceQuotaHelperForTests.ONE_GIGABYTE, SpaceViolationPolicy.NO_INSERTS));
// Create snapshots on each table (we didn't write any data, so just skipflush)
admin.snapshot(new SnapshotDescription(tn1.getQualifierAsString() + "snapshot", tn1, SnapshotType.SKIPFLUSH));
admin.snapshot(new SnapshotDescription(tn2.getQualifierAsString() + "snapshot", tn2, SnapshotType.SKIPFLUSH));
admin.snapshot(new SnapshotDescription(tn3.getQualifierAsString() + "snapshot", tn3, SnapshotType.SKIPFLUSH));
Multimap<TableName, String> mapping = testChore.getSnapshotsToComputeSize();
assertEquals(2, mapping.size());
assertEquals(1, mapping.get(tn1).size());
assertEquals(tn1.getQualifierAsString() + "snapshot", mapping.get(tn1).iterator().next());
assertEquals(1, mapping.get(tn2).size());
assertEquals(tn2.getQualifierAsString() + "snapshot", mapping.get(tn2).iterator().next());
admin.snapshot(new SnapshotDescription(tn2.getQualifierAsString() + "snapshot1", tn2, SnapshotType.SKIPFLUSH));
admin.snapshot(new SnapshotDescription(tn3.getQualifierAsString() + "snapshot2", tn3, SnapshotType.SKIPFLUSH));
mapping = testChore.getSnapshotsToComputeSize();
assertEquals(3, mapping.size());
assertEquals(1, mapping.get(tn1).size());
assertEquals(tn1.getQualifierAsString() + "snapshot", mapping.get(tn1).iterator().next());
assertEquals(2, mapping.get(tn2).size());
assertEquals(new HashSet<String>(Arrays.asList(tn2.getQualifierAsString() + "snapshot", tn2.getQualifierAsString() + "snapshot1")), mapping.get(tn2));
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestMasterQuotasObserver method testNamespaceRPCQuotaRemoved.
@Test
public void testNamespaceRPCQuotaRemoved() throws Exception {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = conn.getAdmin();
final String ns = testName.getMethodName();
// Drop the ns if it somehow exists
if (namespaceExists(ns)) {
admin.deleteNamespace(ns);
}
// Create the ns
NamespaceDescriptor desc = NamespaceDescriptor.create(ns).build();
admin.createNamespace(desc);
assertEquals(0, getThrottleQuotas());
// Set a quota
QuotaSettings settings = QuotaSettingsFactory.throttleNamespace(ns, ThrottleType.REQUEST_SIZE, 2L, TimeUnit.HOURS);
admin.setQuota(settings);
assertEquals(1, getThrottleQuotas());
// Delete the namespace and observe the quota being automatically deleted as well
admin.deleteNamespace(ns);
assertEquals(0, getThrottleQuotas());
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project hbase by apache.
the class TestMasterQuotasObserver method testNamespaceSpaceQuotaRemoved.
@Test
public void testNamespaceSpaceQuotaRemoved() throws Exception {
final Connection conn = TEST_UTIL.getConnection();
final Admin admin = conn.getAdmin();
final String ns = testName.getMethodName();
// Drop the ns if it somehow exists
if (namespaceExists(ns)) {
admin.deleteNamespace(ns);
}
// Create the ns
NamespaceDescriptor desc = NamespaceDescriptor.create(ns).build();
admin.createNamespace(desc);
assertEquals(0, getNumSpaceQuotas());
// Set a quota
QuotaSettings settings = QuotaSettingsFactory.limitNamespaceSpace(ns, 1024L, SpaceViolationPolicy.NO_INSERTS);
admin.setQuota(settings);
assertEquals(1, getNumSpaceQuotas());
// Delete the namespace and observe the quota being automatically deleted as well
admin.deleteNamespace(ns);
assertEquals(0, getNumSpaceQuotas());
}
Aggregations