HBASE-25173 Remove owner related methods in TableDescriptor/TableDescriptorBuilder (#2541)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
WenFeiYi 2020-10-27 22:01:57 +08:00 committed by GitHub
parent 164cc5a3dc
commit 4bbc772ffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 123 additions and 152 deletions

View File

@ -177,13 +177,6 @@ public interface TableDescriptor {
*/ */
TableName getTableName(); TableName getTableName();
/**
* @deprecated since 2.0.0 and will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15583">HBASE-15583</a>
*/
@Deprecated
String getOwnerString();
/** /**
* Get the region server group this table belongs to. The regions of this table will be placed * Get the region server group this table belongs to. The regions of this table will be placed
* only on the region servers within this group. If not present, will be placed on * only on the region servers within this group. If not present, will be placed on

View File

@ -42,7 +42,6 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.exceptions.DeserializationException; import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.rsgroup.RSGroupInfo; import org.apache.hadoop.hbase.rsgroup.RSGroupInfo;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -71,12 +70,6 @@ public class TableDescriptorBuilder {
private static final Bytes MAX_FILESIZE_KEY private static final Bytes MAX_FILESIZE_KEY
= new Bytes(Bytes.toBytes(MAX_FILESIZE)); = new Bytes(Bytes.toBytes(MAX_FILESIZE));
@InterfaceAudience.Private
public static final String OWNER = "OWNER";
@InterfaceAudience.Private
public static final Bytes OWNER_KEY
= new Bytes(Bytes.toBytes(OWNER));
/** /**
* Used by rest interface to access this metadata attribute * Used by rest interface to access this metadata attribute
* which denotes if the table is Read Only. * which denotes if the table is Read Only.
@ -485,26 +478,6 @@ public class TableDescriptorBuilder {
return this; return this;
} }
/**
* @deprecated since 2.0.0 and will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15583">HBASE-15583</a>
*/
@Deprecated
public TableDescriptorBuilder setOwner(User owner) {
desc.setOwner(owner);
return this;
}
/**
* @deprecated since 2.0.0 and will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15583">HBASE-15583</a>
*/
@Deprecated
public TableDescriptorBuilder setOwnerString(String ownerString) {
desc.setOwnerString(ownerString);
return this;
}
public TableDescriptorBuilder setPriority(int priority) { public TableDescriptorBuilder setPriority(int priority) {
desc.setPriority(priority); desc.setPriority(priority);
return this; return this;
@ -1550,38 +1523,6 @@ public class TableDescriptorBuilder {
} }
} }
/**
* @deprecated since 2.0.0 and will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15583">HBASE-15583</a>
*/
@Deprecated
public ModifyableTableDescriptor setOwner(User owner) {
return setOwnerString(owner != null ? owner.getShortName() : null);
}
/**
* @deprecated since 2.0.0 and will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15583">HBASE-15583</a>
*/
// used by admin.rb:alter(table_name,*args) to update owner.
@Deprecated
public ModifyableTableDescriptor setOwnerString(String ownerString) {
return setValue(OWNER_KEY, ownerString);
}
/**
* @deprecated since 2.0.0 and will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15583">HBASE-15583</a>
*/
@Override
@Deprecated
public String getOwnerString() {
// Note that every table should have an owner (i.e. should have OWNER_KEY set).
// hbase:meta should return system user as owner, not null (see
// MasterFileSystem.java:bootstrap()).
return getOrDefault(OWNER_KEY, Function.identity(), null);
}
/** /**
* @return the bytes in pb format * @return the bytes in pb format
*/ */

View File

@ -216,6 +216,7 @@ public class TestSecureExport {
Permission.Action.EXEC, Permission.Action.EXEC,
Permission.Action.READ, Permission.Action.READ,
Permission.Action.WRITE); Permission.Action.WRITE);
SecureTestUtil.grantGlobal(UTIL, USER_OWNER, Permission.Action.CREATE);
addLabels(UTIL.getConfiguration(), Arrays.asList(USER_OWNER), addLabels(UTIL.getConfiguration(), Arrays.asList(USER_OWNER),
Arrays.asList(PRIVATE, CONFIDENTIAL, SECRET, TOPSECRET)); Arrays.asList(PRIVATE, CONFIDENTIAL, SECRET, TOPSECRET));
} }
@ -236,11 +237,11 @@ public class TestSecureExport {
public void testAccessCase() throws Throwable { public void testAccessCase() throws Throwable {
final String exportTable = name.getMethodName(); final String exportTable = name.getMethodName();
TableDescriptor exportHtd = TableDescriptorBuilder TableDescriptor exportHtd = TableDescriptorBuilder
.newBuilder(TableName.valueOf(name.getMethodName())) .newBuilder(TableName.valueOf(exportTable))
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILYA)) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILYA))
.setOwnerString(USER_OWNER)
.build(); .build();
SecureTestUtil.createTable(UTIL, exportHtd, new byte[][]{Bytes.toBytes("s")}); User owner = User.createUserForTesting(UTIL.getConfiguration(), USER_OWNER, new String[0]);
SecureTestUtil.createTable(UTIL, owner, exportHtd, new byte[][]{Bytes.toBytes("s")});
SecureTestUtil.grantOnTable(UTIL, USER_RO, SecureTestUtil.grantOnTable(UTIL, USER_RO,
TableName.valueOf(exportTable), null, null, TableName.valueOf(exportTable), null, null,
Permission.Action.READ); Permission.Action.READ);
@ -340,9 +341,9 @@ public class TestSecureExport {
final TableDescriptor exportHtd = TableDescriptorBuilder final TableDescriptor exportHtd = TableDescriptorBuilder
.newBuilder(TableName.valueOf(exportTable)) .newBuilder(TableName.valueOf(exportTable))
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILYA)) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILYA))
.setOwnerString(USER_OWNER)
.build(); .build();
SecureTestUtil.createTable(UTIL, exportHtd, new byte[][]{Bytes.toBytes("s")}); User owner = User.createUserForTesting(UTIL.getConfiguration(), USER_OWNER, new String[0]);
SecureTestUtil.createTable(UTIL, owner, exportHtd, new byte[][]{Bytes.toBytes("s")});
AccessTestAction putAction = () -> { AccessTestAction putAction = () -> {
Put p1 = new Put(ROW1); Put p1 = new Put(ROW1);
p1.addColumn(FAMILYA, QUAL, NOW, QUAL); p1.addColumn(FAMILYA, QUAL, NOW, QUAL);
@ -398,9 +399,8 @@ public class TestSecureExport {
final TableDescriptor importHtd = TableDescriptorBuilder final TableDescriptor importHtd = TableDescriptorBuilder
.newBuilder(TableName.valueOf(importTable)) .newBuilder(TableName.valueOf(importTable))
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILYB)) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILYB))
.setOwnerString(USER_OWNER)
.build(); .build();
SecureTestUtil.createTable(UTIL, importHtd, new byte[][]{Bytes.toBytes("s")}); SecureTestUtil.createTable(UTIL, owner, importHtd, new byte[][]{Bytes.toBytes("s")});
AccessTestAction importAction = () -> { AccessTestAction importAction = () -> {
String[] args = new String[]{ String[] args = new String[]{
"-D" + Import.CF_RENAME_PROP + "=" + FAMILYA_STRING + ":" + FAMILYB_STRING, "-D" + Import.CF_RENAME_PROP + "=" + FAMILYA_STRING + ":" + FAMILYB_STRING,

View File

@ -804,10 +804,7 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
+ PermissionStorage.ACL_TABLE_NAME + " is not yet created. " + PermissionStorage.ACL_TABLE_NAME + " is not yet created. "
+ getClass().getSimpleName() + " should be configured as the first Coprocessor"); + getClass().getSimpleName() + " should be configured as the first Coprocessor");
} else { } else {
String owner = desc.getOwnerString(); String owner = getActiveUser(c).getShortName();
// default the table owner to current user, if not specified.
if (owner == null)
owner = getActiveUser(c).getShortName();
final UserPermission userPermission = new UserPermission(owner, final UserPermission userPermission = new UserPermission(owner,
Permission.newBuilder(desc.getTableName()).withActions(Action.values()).build()); Permission.newBuilder(desc.getTableName()).withActions(Action.values()).build());
// switch to the real hbase master user for doing the RPC on the ACL table // switch to the real hbase master user for doing the RPC on the ACL table
@ -906,8 +903,7 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
TableDescriptor oldDesc, TableDescriptor currentDesc) throws IOException { TableDescriptor oldDesc, TableDescriptor currentDesc) throws IOException {
final Configuration conf = c.getEnvironment().getConfiguration(); final Configuration conf = c.getEnvironment().getConfiguration();
// default the table owner to current user, if not specified. // default the table owner to current user, if not specified.
final String owner = (currentDesc.getOwnerString() != null) ? currentDesc.getOwnerString() : final String owner = getActiveUser(c).getShortName();
getActiveUser(c).getShortName();
User.runAsLoginUser(new PrivilegedExceptionAction<Void>() { User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
@Override @Override
public Void run() throws Exception { public Void run() throws Exception {

View File

@ -179,8 +179,7 @@ public class SnapshotScannerHDFSAclController implements MasterCoprocessor, Mast
// 1. Create table directories to make HDFS acls can be inherited // 1. Create table directories to make HDFS acls can be inherited
hdfsAclHelper.createTableDirectories(tableName); hdfsAclHelper.createTableDirectories(tableName);
// 2. Add table owner HDFS acls // 2. Add table owner HDFS acls
String owner = String owner = getActiveUser(c).getShortName();
desc.getOwnerString() == null ? getActiveUser(c).getShortName() : desc.getOwnerString();
hdfsAclHelper.addTableAcl(tableName, Sets.newHashSet(owner), "create"); hdfsAclHelper.addTableAcl(tableName, Sets.newHashSet(owner), "create");
// 3. Record table owner permission is synced to HDFS in acl table // 3. Record table owner permission is synced to HDFS in acl table
SnapshotScannerHDFSAclStorage.addUserTableHdfsAcl(c.getEnvironment().getConnection(), owner, SnapshotScannerHDFSAclStorage.addUserTableHdfsAcl(c.getEnvironment().getConnection(), owner,

View File

@ -2985,16 +2985,26 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
/** /**
* Get a shared Connection to the cluster. * Get a shared Connection to the cluster.
* this method is threadsafe. * this method is thread safe.
* @return A Connection that can be shared. Don't close. Will be closed on shutdown of cluster. * @return A Connection that can be shared. Don't close. Will be closed on shutdown of cluster.
*/ */
public Connection getConnection() throws IOException { public Connection getConnection() throws IOException {
return getAsyncConnection().toConnection(); return getAsyncConnection().toConnection();
} }
/**
* Get a assigned Connection to the cluster.
* this method is thread safe.
* @param user assigned user
* @return A Connection with assigned user.
*/
public Connection getConnection(User user) throws IOException {
return getAsyncConnection(user).toConnection();
}
/** /**
* Get a shared AsyncClusterConnection to the cluster. * Get a shared AsyncClusterConnection to the cluster.
* this method is threadsafe. * this method is thread safe.
* @return An AsyncClusterConnection that can be shared. Don't close. Will be closed on shutdown of cluster. * @return An AsyncClusterConnection that can be shared. Don't close. Will be closed on shutdown of cluster.
*/ */
public AsyncClusterConnection getAsyncConnection() throws IOException { public AsyncClusterConnection getAsyncConnection() throws IOException {
@ -3003,7 +3013,7 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
if (connection == null) { if (connection == null) {
try { try {
User user = UserProvider.instantiate(conf).getCurrent(); User user = UserProvider.instantiate(conf).getCurrent();
connection = ClusterConnectionFactory.createAsyncClusterConnection(conf, null, user); connection = getAsyncConnection(user);
} catch(IOException ioe) { } catch(IOException ioe) {
throw new UncheckedIOException("Failed to create connection", ioe); throw new UncheckedIOException("Failed to create connection", ioe);
} }
@ -3015,6 +3025,16 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
} }
} }
/**
* Get a assigned AsyncClusterConnection to the cluster.
* this method is thread safe.
* @param user assigned user
* @return An AsyncClusterConnection with assigned user.
*/
public AsyncClusterConnection getAsyncConnection(User user) throws IOException {
return ClusterConnectionFactory.createAsyncClusterConnection(conf, null, user);
}
public void closeConnection() throws IOException { public void closeConnection() throws IOException {
if (hbaseAdmin != null) { if (hbaseAdmin != null) {
Closeables.close(hbaseAdmin, true); Closeables.close(hbaseAdmin, true);

View File

@ -120,14 +120,17 @@ public abstract class SnapshotWithAclTestBase extends SecureTestUtil {
USER_RW = User.createUserForTesting(conf, "rwuser", new String[0]); USER_RW = User.createUserForTesting(conf, "rwuser", new String[0]);
USER_RO = User.createUserForTesting(conf, "rouser", new String[0]); USER_RO = User.createUserForTesting(conf, "rouser", new String[0]);
USER_NONE = User.createUserForTesting(conf, "usernone", new String[0]); USER_NONE = User.createUserForTesting(conf, "usernone", new String[0]);
// Grant table creation permission to USER_OWNER
grantGlobal(TEST_UTIL, USER_OWNER.getShortName(), Permission.Action.CREATE);
} }
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
TEST_UTIL.createTable(TableDescriptorBuilder.newBuilder(TEST_TABLE) TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TEST_TABLE)
.setColumnFamily( .setColumnFamily(
ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(100).build()) ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(100).build()).build();
.setOwner(USER_OWNER).build(), new byte[][] { Bytes.toBytes("s") }); createTable(TEST_UTIL, USER_OWNER, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
TEST_UTIL.waitTableEnabled(TEST_TABLE); TEST_UTIL.waitTableEnabled(TEST_TABLE);
grantOnTable(TEST_UTIL, USER_RW.getShortName(), TEST_TABLE, TEST_FAMILY, null, grantOnTable(TEST_UTIL, USER_RW.getShortName(), TEST_TABLE, TEST_FAMILY, null,
@ -200,9 +203,9 @@ public abstract class SnapshotWithAclTestBase extends SecureTestUtil {
TableName tableName2 = TableName.valueOf(TEST_UTIL.getRandomUUID().toString()); TableName tableName2 = TableName.valueOf(TEST_UTIL.getRandomUUID().toString());
cloneSnapshot(snapshotName1, tableName2, false); cloneSnapshot(snapshotName1, tableName2, false);
verifyRows(tableName2); verifyRows(tableName2);
verifyAllowed(new AccessReadAction(tableName2), USER_OWNER); verifyDenied(new AccessReadAction(tableName2), USER_OWNER);
verifyDenied(new AccessReadAction(tableName2), USER_NONE, USER_RO, USER_RW); verifyDenied(new AccessReadAction(tableName2), USER_NONE, USER_RO, USER_RW);
verifyAllowed(new AccessWriteAction(tableName2), USER_OWNER); verifyDenied(new AccessWriteAction(tableName2), USER_OWNER);
verifyDenied(new AccessWriteAction(tableName2), USER_RO, USER_RW, USER_NONE); verifyDenied(new AccessWriteAction(tableName2), USER_RO, USER_RW, USER_NONE);
// remove read permission for USER_RO. // remove read permission for USER_RO.

View File

@ -131,6 +131,9 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
USER_GROUP_WRITE = USER_GROUP_WRITE =
User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE }); User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE });
// Grant table creation permission to USER_OWNER
grantGlobal(TEST_UTIL, USER_OWNER.getShortName(), Permission.Action.CREATE);
systemUserConnection = TEST_UTIL.getConnection(); systemUserConnection = TEST_UTIL.getConnection();
setUpTableAndUserPermissions(); setUpTableAndUserPermissions();
master = TEST_UTIL.getHBaseCluster().getMaster(); master = TEST_UTIL.getHBaseCluster().getMaster();
@ -156,8 +159,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
ColumnFamilyDescriptorBuilder cfd = ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY); ColumnFamilyDescriptorBuilder cfd = ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY);
cfd.setMaxVersions(100); cfd.setMaxVersions(100);
tableBuilder.setColumnFamily(cfd.build()); tableBuilder.setColumnFamily(cfd.build());
tableBuilder.setValue(TableDescriptorBuilder.OWNER, USER_OWNER.getShortName()); createTable(TEST_UTIL, USER_OWNER, tableBuilder.build(), new byte[][] { Bytes.toBytes("s") });
createTable(TEST_UTIL, tableBuilder.build(), new byte[][] { Bytes.toBytes("s") });
// Set up initial grants // Set up initial grants
grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(), Permission.Action.ADMIN, grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(), Permission.Action.ADMIN,

View File

@ -775,6 +775,18 @@ public class SecureTestUtil {
testUtil.waitUntilAllRegionsAssigned(htd.getTableName()); testUtil.waitUntilAllRegionsAssigned(htd.getTableName());
} }
public static void createTable(HBaseTestingUtility testUtil, User user, TableDescriptor htd)
throws Exception {
createTable(testUtil, user, htd, null);
}
public static void createTable(HBaseTestingUtility testUtil, User user, TableDescriptor htd,
byte[][] splitKeys) throws Exception {
try (Connection con = testUtil.getConnection(user); Admin admin = con.getAdmin()) {
createTable(testUtil, admin, htd, splitKeys);
}
}
public static void deleteTable(HBaseTestingUtility testUtil, TableName tableName) public static void deleteTable(HBaseTestingUtility testUtil, TableName tableName)
throws Exception { throws Exception {
deleteTable(testUtil, testUtil.getAdmin(), tableName); deleteTable(testUtil, testUtil.getAdmin(), tableName);

View File

@ -270,6 +270,9 @@ public class TestAccessController extends SecureTestUtil {
USER_GROUP_WRITE = USER_GROUP_WRITE =
User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE }); User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE });
// Grant table creation permission to USER_OWNER
grantGlobal(TEST_UTIL, USER_OWNER.getShortName(), Action.CREATE);
systemUserConnection = TEST_UTIL.getConnection(); systemUserConnection = TEST_UTIL.getConnection();
setUpTableAndUserPermissions(); setUpTableAndUserPermissions();
} }
@ -283,9 +286,8 @@ public class TestAccessController extends SecureTestUtil {
private static void setUpTableAndUserPermissions() throws Exception { private static void setUpTableAndUserPermissions() throws Exception {
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TEST_TABLE) TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TEST_TABLE)
.setColumnFamily( .setColumnFamily(
ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(100).build()) ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(100).build()).build();
.setOwner(USER_OWNER).build(); createTable(TEST_UTIL, USER_OWNER, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
createTable(TEST_UTIL, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0); HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
RegionCoprocessorHost rcpHost = region.getCoprocessorHost(); RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
@ -1670,8 +1672,8 @@ public class TestAccessController extends SecureTestUtil {
} }
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName) TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(family1)) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(family1))
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(family2)).setOwner(USER_OWNER).build(); .setColumnFamily(ColumnFamilyDescriptorBuilder.of(family2)).build();
createTable(TEST_UTIL, tableDescriptor); createTable(TEST_UTIL, USER_OWNER, tableDescriptor);
try { try {
List<UserPermission> perms = List<UserPermission> perms =
admin.getUserPermissions(GetUserPermissionsRequest.newBuilder(tableName).build()); admin.getUserPermissions(GetUserPermissionsRequest.newBuilder(tableName).build());
@ -1724,13 +1726,9 @@ public class TestAccessController extends SecureTestUtil {
assertFalse("User should not be granted permission: " + upToVerify.toString(), assertFalse("User should not be granted permission: " + upToVerify.toString(),
hasFoundUserPermission(upToVerify, perms)); hasFoundUserPermission(upToVerify, perms));
// disable table before modification
admin.disableTable(tableName);
User newOwner = User.createUserForTesting(conf, "new_owner", new String[] {}); User newOwner = User.createUserForTesting(conf, "new_owner", new String[] {});
tableDescriptor = grantOnTable(TEST_UTIL, newOwner.getShortName(), tableName,
TableDescriptorBuilder.newBuilder(tableDescriptor).setOwner(newOwner).build(); null, null, Permission.Action.values());
admin.modifyTable(tableDescriptor);
perms = admin.getUserPermissions(GetUserPermissionsRequest.newBuilder(tableName).build()); perms = admin.getUserPermissions(GetUserPermissionsRequest.newBuilder(tableName).build());
UserPermission newOwnerperm = new UserPermission(newOwner.getName(), UserPermission newOwnerperm = new UserPermission(newOwner.getName(),
@ -1758,7 +1756,7 @@ public class TestAccessController extends SecureTestUtil {
new UserPermission(user, Permission.newBuilder().withActions(Action.values()).build())); new UserPermission(user, Permission.newBuilder().withActions(Action.values()).build()));
} }
assertTrue("Only super users, global users and user admin has permission on table hbase:acl " + assertTrue("Only super users, global users and user admin has permission on table hbase:acl " +
"per setup", perms.size() == 5 + superUsers.size() && "per setup", perms.size() == 6 + superUsers.size() &&
hasFoundUserPermission(adminPerms, perms)); hasFoundUserPermission(adminPerms, perms));
} }
@ -2278,8 +2276,8 @@ public class TestAccessController extends SecureTestUtil {
private void createTestTable(TableName tname, byte[] cf) throws Exception { private void createTestTable(TableName tname, byte[] cf) throws Exception {
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tname) TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tname)
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(cf).setMaxVersions(100).build()) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(cf).setMaxVersions(100).build())
.setOwner(USER_OWNER).build(); .build();
createTable(TEST_UTIL, tableDescriptor, new byte[][] { Bytes.toBytes("s") }); createTable(TEST_UTIL, USER_OWNER, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
} }
@Test @Test
@ -2858,7 +2856,7 @@ public class TestAccessController extends SecureTestUtil {
// Verify that we can read sys-tables // Verify that we can read sys-tables
String aclTableName = PermissionStorage.ACL_TABLE_NAME.getNameAsString(); String aclTableName = PermissionStorage.ACL_TABLE_NAME.getNameAsString();
assertEquals(5, SUPERUSER.runAs(getPrivilegedAction(aclTableName)).size()); assertEquals(6, SUPERUSER.runAs(getPrivilegedAction(aclTableName)).size());
assertEquals(0, testRegexHandler.runAs(getPrivilegedAction(aclTableName)).size()); assertEquals(0, testRegexHandler.runAs(getPrivilegedAction(aclTableName)).size());
// Grant TABLE ADMIN privs to testUserPerms // Grant TABLE ADMIN privs to testUserPerms
@ -3517,10 +3515,10 @@ public class TestAccessController extends SecureTestUtil {
// Validate global user permission // Validate global user permission
List<UserPermission> userPermissions; List<UserPermission> userPermissions;
assertEquals(5 + superUserCount, AccessControlClient.getUserPermissions(conn, null).size()); assertEquals(6 + superUserCount, AccessControlClient.getUserPermissions(conn, null).size());
assertEquals(5 + superUserCount, assertEquals(6 + superUserCount,
AccessControlClient.getUserPermissions(conn, HConstants.EMPTY_STRING).size()); AccessControlClient.getUserPermissions(conn, HConstants.EMPTY_STRING).size());
assertEquals(5 + superUserCount, assertEquals(6 + superUserCount,
AccessControlClient.getUserPermissions(conn, null, HConstants.EMPTY_STRING).size()); AccessControlClient.getUserPermissions(conn, null, HConstants.EMPTY_STRING).size());
userPermissions = AccessControlClient.getUserPermissions(conn, null, USER_ADMIN.getName()); userPermissions = AccessControlClient.getUserPermissions(conn, null, USER_ADMIN.getName());
verifyGetUserPermissionResult(userPermissions, 1, null, null, USER_ADMIN.getName(), superUsers); verifyGetUserPermissionResult(userPermissions, 1, null, null, USER_ADMIN.getName(), superUsers);

View File

@ -189,6 +189,9 @@ public class TestAccessController3 extends SecureTestUtil {
USER_GROUP_WRITE = USER_GROUP_WRITE =
User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE }); User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE });
// Grant table creation permission to USER_OWNER
grantGlobal(TEST_UTIL, USER_OWNER.getShortName(), Permission.Action.CREATE);
systemUserConnection = TEST_UTIL.getConnection(); systemUserConnection = TEST_UTIL.getConnection();
setUpTableAndUserPermissions(); setUpTableAndUserPermissions();
} }
@ -207,9 +210,8 @@ public class TestAccessController3 extends SecureTestUtil {
private static void setUpTableAndUserPermissions() throws Exception { private static void setUpTableAndUserPermissions() throws Exception {
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TEST_TABLE) TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TEST_TABLE)
.setColumnFamily( .setColumnFamily(
ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(100).build()) ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(100).build()).build();
.setOwner(USER_OWNER).build(); createTable(TEST_UTIL, USER_OWNER, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
createTable(TEST_UTIL, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0); HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
RegionCoprocessorHost rcpHost = region.getCoprocessorHost(); RegionCoprocessorHost rcpHost = region.getCoprocessorHost();

View File

@ -31,7 +31,6 @@ import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.ConnectionFactory;
@ -125,6 +124,9 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
GROUP_USER = User.createUserForTesting(conf, "group_user", new String[] { GROUP }); GROUP_USER = User.createUserForTesting(conf, "group_user", new String[] { GROUP });
usersAndGroups = new String[] { USER_OTHER.getShortName(), AuthUtil.toGroupEntry(GROUP) }; usersAndGroups = new String[] { USER_OTHER.getShortName(), AuthUtil.toGroupEntry(GROUP) };
// Grant table creation permission to USER_OWNER
grantGlobal(TEST_UTIL, USER_OWNER.getShortName(), Action.CREATE);
} }
@AfterClass @AfterClass
@ -138,14 +140,9 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
.setColumnFamily( .setColumnFamily(
ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY1).setMaxVersions(4).build()) ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY1).setMaxVersions(4).build())
.setColumnFamily( .setColumnFamily(
ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY2).setMaxVersions(4).build()) ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY2).setMaxVersions(4).build()).build();
.setOwner(USER_OWNER).build();
// Create the test table (owner added to the _acl_ table) // Create the test table (owner added to the _acl_ table)
try (Connection connection = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration())) { createTable(TEST_UTIL, USER_OWNER, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
try (Admin admin = connection.getAdmin()) {
admin.createTable(tableDescriptor, new byte[][] { Bytes.toBytes("s") });
}
}
TEST_UTIL.waitTableEnabled(testTable.getTableName()); TEST_UTIL.waitTableEnabled(testTable.getTableName());
LOG.info("Sleeping a second because of HBASE-12581"); LOG.info("Sleeping a second because of HBASE-12581");
Threads.sleep(1000); Threads.sleep(1000);

View File

@ -31,7 +31,6 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.ConnectionFactory;
@ -127,6 +126,9 @@ public class TestCellACLs extends SecureTestUtil {
GROUP_USER = User.createUserForTesting(conf, "group_user", new String[] { GROUP }); GROUP_USER = User.createUserForTesting(conf, "group_user", new String[] { GROUP });
usersAndGroups = new String[] { USER_OTHER.getShortName(), AuthUtil.toGroupEntry(GROUP) }; usersAndGroups = new String[] { USER_OTHER.getShortName(), AuthUtil.toGroupEntry(GROUP) };
// Grant table creation permission to USER_OWNER
grantGlobal(TEST_UTIL, USER_OWNER.getShortName(), Action.CREATE);
} }
@AfterClass @AfterClass
@ -137,12 +139,10 @@ public class TestCellACLs extends SecureTestUtil {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
// Create the test table (owner added to the _acl_ table) // Create the test table (owner added to the _acl_ table)
Admin admin = TEST_UTIL.getAdmin();
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(testTable.getTableName()) TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(testTable.getTableName())
.setColumnFamily( .setColumnFamily(
ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(4).build()) ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(4).build()).build();
.setOwner(USER_OWNER).build(); createTable(TEST_UTIL, USER_OWNER, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
admin.createTable(tableDescriptor, new byte[][] { Bytes.toBytes("s") });
TEST_UTIL.waitTableEnabled(testTable.getTableName()); TEST_UTIL.waitTableEnabled(testTable.getTableName());
LOG.info("Sleeping a second because of HBASE-12581"); LOG.info("Sleeping a second because of HBASE-12581");
Threads.sleep(1000); Threads.sleep(1000);

View File

@ -39,6 +39,8 @@ import static org.junit.Assert.assertEquals;
final class TestHDFSAclHelper { final class TestHDFSAclHelper {
private static final Logger LOG = LoggerFactory.getLogger(TestHDFSAclHelper.class); private static final Logger LOG = LoggerFactory.getLogger(TestHDFSAclHelper.class);
private static final String USER_OWNER = "owner";
private TestHDFSAclHelper() { private TestHDFSAclHelper() {
} }
@ -55,33 +57,41 @@ final class TestHDFSAclHelper {
} }
} }
static Table createTable(HBaseTestingUtility util, TableName tableName) throws IOException { static Table createTable(HBaseTestingUtility util, TableName tableName) throws Exception {
createNamespace(util, tableName.getNamespaceAsString()); createNamespace(util, tableName.getNamespaceAsString());
TableDescriptor td = getTableDescriptorBuilder(util, tableName) TableDescriptor td = getTableDescriptorBuilder(util, tableName)
.setValue(SnapshotScannerHDFSAclHelper.ACL_SYNC_TO_HDFS_ENABLE, "true").build(); .setValue(SnapshotScannerHDFSAclHelper.ACL_SYNC_TO_HDFS_ENABLE, "true").build();
byte[][] splits = new byte[][] { Bytes.toBytes("2"), Bytes.toBytes("4") }; byte[][] splits = new byte[][] { Bytes.toBytes("2"), Bytes.toBytes("4") };
return util.createTable(td, splits); User user = User.createUserForTesting(util.getConfiguration(), USER_OWNER, new String[] {});
SecureTestUtil.grantGlobal(util, user.getShortName(), Permission.Action.CREATE);
SecureTestUtil.createTable(util, user, td, splits);
return util.getConnection().getTable(tableName);
} }
static Table createMobTable(HBaseTestingUtility util, TableName tableName) throws IOException { static Table createMobTable(HBaseTestingUtility util, TableName tableName) throws Exception {
createNamespace(util, tableName.getNamespaceAsString()); createNamespace(util, tableName.getNamespaceAsString());
TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName) TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName)
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(COLUMN1).setMobEnabled(true) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(COLUMN1).setMobEnabled(true)
.setMobThreshold(0).build()) .setMobThreshold(0).build())
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(COLUMN2).setMobEnabled(true) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(COLUMN2).setMobEnabled(true)
.setMobThreshold(0).build()) .setMobThreshold(0).build())
.setOwner(User.createUserForTesting(util.getConfiguration(), "owner", new String[] {}))
.setValue(SnapshotScannerHDFSAclHelper.ACL_SYNC_TO_HDFS_ENABLE, "true").build(); .setValue(SnapshotScannerHDFSAclHelper.ACL_SYNC_TO_HDFS_ENABLE, "true").build();
byte[][] splits = new byte[][] { Bytes.toBytes("2"), Bytes.toBytes("4") }; byte[][] splits = new byte[][] { Bytes.toBytes("2"), Bytes.toBytes("4") };
return util.createTable(td, splits); User user = User.createUserForTesting(util.getConfiguration(), USER_OWNER, new String[] {});
SecureTestUtil.grantGlobal(util, user.getShortName(), Permission.Action.CREATE);
SecureTestUtil.createTable(util, user, td, splits);
return util.getConnection().getTable(tableName);
} }
static TableDescriptor createUserScanSnapshotDisabledTable(HBaseTestingUtility util, static TableDescriptor createUserScanSnapshotDisabledTable(HBaseTestingUtility util,
TableName tableName) throws IOException { TableName tableName) throws Exception {
createNamespace(util, tableName.getNamespaceAsString()); createNamespace(util, tableName.getNamespaceAsString());
TableDescriptor td = getTableDescriptorBuilder(util, tableName).build(); TableDescriptor td = getTableDescriptorBuilder(util, tableName).build();
byte[][] splits = new byte[][] { Bytes.toBytes("2"), Bytes.toBytes("4") }; byte[][] splits = new byte[][] { Bytes.toBytes("2"), Bytes.toBytes("4") };
try (Table t = util.createTable(td, splits)) { User user = User.createUserForTesting(util.getConfiguration(), USER_OWNER, new String[] {});
SecureTestUtil.grantGlobal(util, user.getShortName(), Permission.Action.CREATE);
SecureTestUtil.createTable(util, user, td, splits);
try (Table t = util.getConnection().getTable(tableName)) {
put(t); put(t);
} }
return td; return td;
@ -91,11 +101,10 @@ final class TestHDFSAclHelper {
TableName tableName) { TableName tableName) {
return TableDescriptorBuilder.newBuilder(tableName) return TableDescriptorBuilder.newBuilder(tableName)
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(COLUMN1).build()) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(COLUMN1).build())
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(COLUMN2).build()) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(COLUMN2).build());
.setOwner(User.createUserForTesting(util.getConfiguration(), "owner", new String[] {}));
} }
static void createTableAndPut(HBaseTestingUtility util, TableName tableNam) throws IOException { static void createTableAndPut(HBaseTestingUtility util, TableName tableNam) throws Exception {
try (Table t = createTable(util, tableNam)) { try (Table t = createTable(util, tableNam)) {
put(t); put(t);
} }

View File

@ -28,7 +28,6 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.ConnectionFactory;
@ -107,6 +106,9 @@ public class TestScanEarlyTermination extends SecureTestUtil {
// create a set of test users // create a set of test users
USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
USER_OTHER = User.createUserForTesting(conf, "other", new String[0]); USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
// Grant table creation permission to USER_OWNER
grantGlobal(TEST_UTIL, USER_OWNER.getShortName(), Action.CREATE);
} }
@AfterClass @AfterClass
@ -116,9 +118,8 @@ public class TestScanEarlyTermination extends SecureTestUtil {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
Admin admin = TEST_UTIL.getAdmin();
TableDescriptor tableDescriptor = TableDescriptor tableDescriptor =
TableDescriptorBuilder.newBuilder(testTable.getTableName()).setOwner(USER_OWNER) TableDescriptorBuilder.newBuilder(testTable.getTableName())
.setColumnFamily( .setColumnFamily(
ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY1).setMaxVersions(10).build()) ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY1).setMaxVersions(10).build())
.setColumnFamily( .setColumnFamily(
@ -127,7 +128,7 @@ public class TestScanEarlyTermination extends SecureTestUtil {
// want to confirm that the per-table configuration is properly picked up. // want to confirm that the per-table configuration is properly picked up.
.setValue(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, "true").build(); .setValue(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, "true").build();
admin.createTable(tableDescriptor); createTable(TEST_UTIL, USER_OWNER, tableDescriptor);
TEST_UTIL.waitUntilAllRegionsAssigned(testTable.getTableName()); TEST_UTIL.waitUntilAllRegionsAssigned(testTable.getTableName());
} }

View File

@ -32,7 +32,6 @@ import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Append; import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
@ -167,6 +166,9 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
USER_RO = User.createUserForTesting(conf, "rouser", new String[0]); USER_RO = User.createUserForTesting(conf, "rouser", new String[0]);
USER_QUAL = User.createUserForTesting(conf, "rwpartial", new String[0]); USER_QUAL = User.createUserForTesting(conf, "rwpartial", new String[0]);
USER_NONE = User.createUserForTesting(conf, "nouser", new String[0]); USER_NONE = User.createUserForTesting(conf, "nouser", new String[0]);
// Grant table creation permission to USER_OWNER
grantGlobal(TEST_UTIL, USER_OWNER.getShortName(), Action.CREATE);
} }
@AfterClass @AfterClass
@ -177,12 +179,10 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
// Create the test table (owner added to the _acl_ table) // Create the test table (owner added to the _acl_ table)
Admin admin = TEST_UTIL.getAdmin();
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(testTable.getTableName()) TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(testTable.getTableName())
.setColumnFamily( .setColumnFamily(
ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(100).build()) ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).setMaxVersions(100).build()).build();
.setOwner(USER_OWNER).build(); createTable(TEST_UTIL, USER_OWNER, tableDescriptor, new byte[][] { Bytes.toBytes("s") });
admin.createTable(tableDescriptor, new byte[][] { Bytes.toBytes("s") });
TEST_UTIL.waitUntilAllRegionsAssigned(testTable.getTableName()); TEST_UTIL.waitUntilAllRegionsAssigned(testTable.getTableName());
HRegion region = TEST_UTIL.getHBaseCluster().getRegions(testTable.getTableName()).get(0); HRegion region = TEST_UTIL.getHBaseCluster().getRegions(testTable.getTableName()).get(0);

View File

@ -1470,8 +1470,8 @@ module Hbase
end end
# Parse arguments and update TableDescriptorBuilder accordingly # Parse arguments and update TableDescriptorBuilder accordingly
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def update_tdb_from_arg(tdb, arg) def update_tdb_from_arg(tdb, arg)
tdb.setOwnerString(arg.delete(TableDescriptorBuilder::OWNER)) if arg.include?(TableDescriptorBuilder::OWNER)
tdb.setMaxFileSize(JLong.valueOf(arg.delete(TableDescriptorBuilder::MAX_FILESIZE))) if arg.include?(TableDescriptorBuilder::MAX_FILESIZE) tdb.setMaxFileSize(JLong.valueOf(arg.delete(TableDescriptorBuilder::MAX_FILESIZE))) if arg.include?(TableDescriptorBuilder::MAX_FILESIZE)
tdb.setReadOnly(JBoolean.valueOf(arg.delete(TableDescriptorBuilder::READONLY))) if arg.include?(TableDescriptorBuilder::READONLY) tdb.setReadOnly(JBoolean.valueOf(arg.delete(TableDescriptorBuilder::READONLY))) if arg.include?(TableDescriptorBuilder::READONLY)
tdb.setCompactionEnabled(JBoolean.valueOf(arg.delete(TableDescriptorBuilder::COMPACTION_ENABLED))) if arg.include?(TableDescriptorBuilder::COMPACTION_ENABLED) tdb.setCompactionEnabled(JBoolean.valueOf(arg.delete(TableDescriptorBuilder::COMPACTION_ENABLED))) if arg.include?(TableDescriptorBuilder::COMPACTION_ENABLED)
@ -1490,6 +1490,7 @@ module Hbase
set_user_metadata(tdb, arg.delete(METADATA)) if arg[METADATA] set_user_metadata(tdb, arg.delete(METADATA)) if arg[METADATA]
set_descriptor_config(tdb, arg.delete(CONFIGURATION)) if arg[CONFIGURATION] set_descriptor_config(tdb, arg.delete(CONFIGURATION)) if arg[CONFIGURATION]
end end
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------
# clear compaction queues # clear compaction queues

View File

@ -95,7 +95,7 @@ There could be more than one alteration in one command:
hbase> alter 't1', { NAME => 'f1', VERSIONS => 3 }, hbase> alter 't1', { NAME => 'f1', VERSIONS => 3 },
{ MAX_FILESIZE => '134217728' }, { METHOD => 'delete', NAME => 'f2' }, { MAX_FILESIZE => '134217728' }, { METHOD => 'delete', NAME => 'f2' },
OWNER => 'johndoe', METADATA => { 'mykey' => 'myvalue' } METADATA => { 'mykey' => 'myvalue' }
EOF EOF
end end

View File

@ -45,7 +45,7 @@ Examples:
hbase> create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40'] hbase> create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40']
hbase> create 't1', 'f1', SPLITS => ['10', '20', '30', '40'] hbase> create 't1', 'f1', SPLITS => ['10', '20', '30', '40']
hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt', OWNER => 'johndoe' hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt'
hbase> create 't1', {NAME => 'f1', VERSIONS => 5}, METADATA => { 'mykey' => 'myvalue' } hbase> create 't1', {NAME => 'f1', VERSIONS => 5}, METADATA => { 'mykey' => 'myvalue' }
hbase> # Optionally pre-split the table into NUMREGIONS, using hbase> # Optionally pre-split the table into NUMREGIONS, using
hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname) hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname)

View File

@ -426,7 +426,7 @@ module Hbase
define_test "create should fail without columns when called with options" do define_test "create should fail without columns when called with options" do
drop_test_table(@create_test_name) drop_test_table(@create_test_name)
assert_raise(ArgumentError) do assert_raise(ArgumentError) do
command(:create, @create_test_name, { OWNER => 'a' }) command(:create, @create_test_name, { VERSIONS => '1' })
end end
end end
@ -460,7 +460,6 @@ module Hbase
define_test "create should be able to set table options" do define_test "create should be able to set table options" do
drop_test_table(@create_test_name) drop_test_table(@create_test_name)
command(:create, @create_test_name, 'a', 'b', 'MAX_FILESIZE' => 12345678, command(:create, @create_test_name, 'a', 'b', 'MAX_FILESIZE' => 12345678,
OWNER => '987654321',
PRIORITY => '77', PRIORITY => '77',
FLUSH_POLICY => 'org.apache.hadoop.hbase.regionserver.FlushAllLargeStoresPolicy', FLUSH_POLICY => 'org.apache.hadoop.hbase.regionserver.FlushAllLargeStoresPolicy',
REGION_MEMSTORE_REPLICATION => 'TRUE', REGION_MEMSTORE_REPLICATION => 'TRUE',
@ -470,7 +469,6 @@ module Hbase
MERGE_ENABLED => 'false') MERGE_ENABLED => 'false')
assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort) assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort)
assert_match(/12345678/, admin.describe(@create_test_name)) assert_match(/12345678/, admin.describe(@create_test_name))
assert_match(/987654321/, admin.describe(@create_test_name))
assert_match(/77/, admin.describe(@create_test_name)) assert_match(/77/, admin.describe(@create_test_name))
assert_match(/'COMPACTION_ENABLED' => 'false'/, admin.describe(@create_test_name)) assert_match(/'COMPACTION_ENABLED' => 'false'/, admin.describe(@create_test_name))
assert_match(/'SPLIT_ENABLED' => 'false'/, admin.describe(@create_test_name)) assert_match(/'SPLIT_ENABLED' => 'false'/, admin.describe(@create_test_name))
@ -484,9 +482,8 @@ module Hbase
define_test "create should ignore table_att" do define_test "create should ignore table_att" do
drop_test_table(@create_test_name) drop_test_table(@create_test_name)
command(:create, @create_test_name, 'a', 'b', METHOD => 'table_att', OWNER => '987654321') command(:create, @create_test_name, 'a', 'b', METHOD => 'table_att')
assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort) assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort)
assert_match(/987654321/, admin.describe(@create_test_name))
end end
define_test "create should work with SPLITALGO" do define_test "create should work with SPLITALGO" do