当前位置: 首页>>代码示例>>Java>>正文


Java RegionCoprocessorHost.createEnvironment方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.createEnvironment方法的典型用法代码示例。如果您正苦于以下问题:Java RegionCoprocessorHost.createEnvironment方法的具体用法?Java RegionCoprocessorHost.createEnvironment怎么用?Java RegionCoprocessorHost.createEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost的用法示例。


在下文中一共展示了RegionCoprocessorHost.createEnvironment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  // Create the test table (owner added to the _acl_ table)
  Admin admin = TEST_UTIL.getHBaseAdmin();
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
  HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
  hcd.setMaxVersions(100);
  htd.addFamily(hcd);
  htd.setOwner(USER_OWNER);
  admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
  TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE.getTableName());

  Region region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, TEST_UTIL.getConfiguration());

  // Set up initial grants

  grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(),
    Permission.Action.ADMIN,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RW.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, null,
    Permission.Action.READ,
    Permission.Action.WRITE);

  // USER_CREATE is USER_RW plus CREATE permissions
  grantOnTable(TEST_UTIL, USER_CREATE.getShortName(),
    TEST_TABLE.getTableName(), null, null,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RO.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, null,
    Permission.Action.READ);

  grantOnTable(TEST_UTIL, USER_QUAL.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, TEST_Q1,
    Permission.Action.READ,
    Permission.Action.WRITE);

  assertEquals(5, AccessControlLists.getTablePermissions(TEST_UTIL.getConfiguration(),
    TEST_TABLE.getTableName()).size());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:50,代码来源:TestWithDisabledAuthorization.java

示例2: setUpTableAndUserPermissions

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
private static void setUpTableAndUserPermissions() throws Exception {
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
  HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
  hcd.setMaxVersions(100);
  htd.addFamily(hcd);
  htd.setOwner(USER_OWNER);
  createTable(TEST_UTIL, htd, new byte[][] { Bytes.toBytes("s") });

  Region region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Set up initial grants

  grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(),
    Permission.Action.ADMIN,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RW.getShortName(),
    TEST_TABLE, TEST_FAMILY, null,
    Permission.Action.READ,
    Permission.Action.WRITE);

  // USER_CREATE is USER_RW plus CREATE permissions
  grantOnTable(TEST_UTIL, USER_CREATE.getShortName(),
    TEST_TABLE, null, null,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RO.getShortName(),
    TEST_TABLE, TEST_FAMILY, null,
    Permission.Action.READ);

  grantOnTable(TEST_UTIL, USER_ADMIN_CF.getShortName(),
    TEST_TABLE, TEST_FAMILY,
    null, Permission.Action.ADMIN, Permission.Action.CREATE);

  grantGlobal(TEST_UTIL, toGroupEntry(GROUP_ADMIN), Permission.Action.ADMIN);
  grantGlobal(TEST_UTIL, toGroupEntry(GROUP_CREATE), Permission.Action.CREATE);
  grantGlobal(TEST_UTIL, toGroupEntry(GROUP_READ), Permission.Action.READ);
  grantGlobal(TEST_UTIL, toGroupEntry(GROUP_WRITE), Permission.Action.WRITE);

  assertEquals(5, AccessControlLists.getTablePermissions(conf, TEST_TABLE).size());
  try {
    assertEquals(5, AccessControlClient.getUserPermissions(systemUserConnection,
        TEST_TABLE.toString()).size());
  } catch (Throwable e) {
    LOG.error("error during call of AccessControlClient.getUserPermissions. ", e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:55,代码来源:TestAccessController.java

示例3: setUp

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  // Create the test table (owner added to the _acl_ table)
  Admin admin = TEST_UTIL.getHBaseAdmin();
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
  HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
  hcd.setMaxVersions(100);
  htd.addFamily(hcd);
  htd.setOwner(USER_OWNER);
  admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
  TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName());

  HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Set up initial grants

  grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(),
    Permission.Action.ADMIN,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RW.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, null,
    Permission.Action.READ,
    Permission.Action.WRITE);

  // USER_CREATE is USER_RW plus CREATE permissions
  grantOnTable(TEST_UTIL, USER_CREATE.getShortName(),
    TEST_TABLE.getTableName(), null, null,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RO.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, null,
    Permission.Action.READ);

  grantOnTable(TEST_UTIL, USER_ADMIN_CF.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY,
    null, Permission.Action.ADMIN, Permission.Action.CREATE);

  assertEquals(5, AccessControlLists.getTablePermissions(conf, TEST_TABLE.getTableName()).size());
  try {
    assertEquals(5, AccessControlClient.getUserPermissions(conf, TEST_TABLE.toString()).size());
  } catch (Throwable e) {
    LOG.error("error during call of AccessControlClient.getUserPermissions. ", e);
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:53,代码来源:TestAccessController.java

示例4: setUp

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  // Create the test table (owner added to the _acl_ table)
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
  HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
  hcd.setMaxVersions(100);
  htd.addFamily(hcd);
  htd.setOwner(USER_OWNER);
  admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
  TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName());

  HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Set up initial grants

  grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(),
    Permission.Action.ADMIN,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RW.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, null,
    Permission.Action.READ,
    Permission.Action.WRITE);

  // USER_CREATE is USER_RW plus CREATE permissions
  grantOnTable(TEST_UTIL, USER_CREATE.getShortName(),
    TEST_TABLE.getTableName(), null, null,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RO.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, null,
    Permission.Action.READ);

  assertEquals(4, AccessControlLists.getTablePermissions(conf, TEST_TABLE.getTableName()).size());
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:44,代码来源:TestAccessController.java

示例5: setupBeforeClass

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  conf.set("hbase.master.hfilecleaner.plugins",
    "org.apache.hadoop.hbase.master.cleaner.HFileLinkCleaner," +
    "org.apache.hadoop.hbase.master.snapshot.SnapshotHFileCleaner");
  conf.set("hbase.master.logcleaner.plugins",
    "org.apache.hadoop.hbase.master.snapshot.SnapshotLogCleaner");
  SecureTestUtil.enableSecurity(conf);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster().getCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  ACCESS_CONTROLLER = (AccessController) cpHost.findCoprocessor(AccessController.class.getName());
  CP_ENV = cpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getCoprocessorHost();
  RSCP_ENV = rsHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER, 
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableAvailable(AccessControlLists.ACL_TABLE_NAME, 5000);

  // create a set of test users
  SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
  USER_ADMIN = User.createUserForTesting(conf, "admin2", new String[0]);
  USER_RW = User.createUserForTesting(conf, "rwuser", new String[0]);
  USER_RO = User.createUserForTesting(conf, "rouser", new String[0]);
  USER_RW_ON_TABLE = User.createUserForTesting(conf, "rwuser_1", new String[0]);
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_CREATE = User.createUserForTesting(conf, "tbl_create", new String[0]);
  USER_NONE = User.createUserForTesting(conf, "nouser", new String[0]);

  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
  htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
  htd.setOwner(USER_OWNER);
  admin.createTable(htd);
  TEST_UTIL.waitTableEnabled(TEST_TABLE, 5000);

  HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // initilize access control
  HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME);
  try {
    AccessControllerProtocol protocol = acl.coprocessorProxy(AccessControllerProtocol.class,
      TEST_TABLE);

   protocol.grant(new UserPermission(Bytes.toBytes(USER_ADMIN.getShortName()),
      Permission.Action.ADMIN, Permission.Action.CREATE, Permission.Action.READ,
      Permission.Action.WRITE));

    protocol.grant(new UserPermission(Bytes.toBytes(USER_RW.getShortName()), TEST_TABLE,
      TEST_FAMILY, Permission.Action.READ, Permission.Action.WRITE));

    protocol.grant(new UserPermission(Bytes.toBytes(USER_RO.getShortName()), TEST_TABLE,
      TEST_FAMILY, Permission.Action.READ));

    protocol.grant(new UserPermission(Bytes.toBytes(USER_CREATE.getShortName()), TEST_TABLE, null,
      Permission.Action.CREATE));
  
    protocol.grant(new UserPermission(Bytes.toBytes(USER_RW_ON_TABLE.getShortName()), TEST_TABLE,
      null, Permission.Action.READ, Permission.Action.WRITE));
  } finally {
    acl.close();
  }
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:73,代码来源:TestAccessController.java

示例6: setUp

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  // Create the test table (owner added to the _acl_ table)
  Admin admin = TEST_UTIL.getAdmin();
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
  HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
  hcd.setMaxVersions(100);
  htd.addFamily(hcd);
  htd.setOwner(USER_OWNER);
  admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
  TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE.getTableName());

  HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, TEST_UTIL.getConfiguration());

  // Set up initial grants

  grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(),
    Permission.Action.ADMIN,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RW.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, null,
    Permission.Action.READ,
    Permission.Action.WRITE);

  // USER_CREATE is USER_RW plus CREATE permissions
  grantOnTable(TEST_UTIL, USER_CREATE.getShortName(),
    TEST_TABLE.getTableName(), null, null,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RO.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, null,
    Permission.Action.READ);

  grantOnTable(TEST_UTIL, USER_QUAL.getShortName(),
    TEST_TABLE.getTableName(), TEST_FAMILY, TEST_Q1,
    Permission.Action.READ,
    Permission.Action.WRITE);

  assertEquals(5, AccessControlLists.getTablePermissions(TEST_UTIL.getConfiguration(),
    TEST_TABLE.getTableName()).size());
}
 
开发者ID:apache,项目名称:hbase,代码行数:50,代码来源:TestWithDisabledAuthorization.java

示例7: setUpTableAndUserPermissions

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
private static void setUpTableAndUserPermissions() throws Exception {
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
  HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
  hcd.setMaxVersions(100);
  htd.addFamily(hcd);
  htd.setOwner(USER_OWNER);
  createTable(TEST_UTIL, htd, new byte[][] { Bytes.toBytes("s") });

  HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Set up initial grants

  grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(),
    Permission.Action.ADMIN,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RW.getShortName(),
    TEST_TABLE, TEST_FAMILY, null,
    Permission.Action.READ,
    Permission.Action.WRITE);

  // USER_CREATE is USER_RW plus CREATE permissions
  grantOnTable(TEST_UTIL, USER_CREATE.getShortName(),
    TEST_TABLE, null, null,
    Permission.Action.CREATE,
    Permission.Action.READ,
    Permission.Action.WRITE);

  grantOnTable(TEST_UTIL, USER_RO.getShortName(),
    TEST_TABLE, TEST_FAMILY, null,
    Permission.Action.READ);

  grantOnTable(TEST_UTIL, USER_ADMIN_CF.getShortName(),
    TEST_TABLE, TEST_FAMILY,
    null, Permission.Action.ADMIN, Permission.Action.CREATE);

  grantGlobal(TEST_UTIL, toGroupEntry(GROUP_ADMIN), Permission.Action.ADMIN);
  grantGlobal(TEST_UTIL, toGroupEntry(GROUP_CREATE), Permission.Action.CREATE);
  grantGlobal(TEST_UTIL, toGroupEntry(GROUP_READ), Permission.Action.READ);
  grantGlobal(TEST_UTIL, toGroupEntry(GROUP_WRITE), Permission.Action.WRITE);

  assertEquals(5, AccessControlLists.getTablePermissions(conf, TEST_TABLE).size());
  try {
    assertEquals(5, AccessControlClient.getUserPermissions(systemUserConnection,
        TEST_TABLE.toString()).size());
  } catch (Throwable e) {
    LOG.error("error during call of AccessControlClient.getUserPermissions. ", e);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:54,代码来源:TestAccessController3.java

示例8: setUp

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  // Create the test table (owner added to the _acl_ table)
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
  htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
  htd.setOwner(USER_OWNER);
  admin.createTable(htd);
  TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName());

  HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // initilize access control
  HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME);
  try {
    BlockingRpcChannel service = acl.coprocessorService(TEST_TABLE.getTableName().getName());
    AccessControlService.BlockingInterface protocol =
      AccessControlService.newBlockingStub(service);

    protocol.grant(null, RequestConverter.buildGrantRequest(USER_ADMIN.getShortName(),
      AccessControlProtos.Permission.Action.ADMIN,
      AccessControlProtos.Permission.Action.CREATE,
      AccessControlProtos.Permission.Action.READ,
      AccessControlProtos.Permission.Action.WRITE));

    protocol.grant(null, RequestConverter.buildGrantRequest(USER_RW.getShortName(),
      TEST_TABLE.getTableName(), TEST_FAMILY, null,
      AccessControlProtos.Permission.Action.READ,
      AccessControlProtos.Permission.Action.WRITE));

    // USER_CREATE is USER_RW plus CREATE permissions
    protocol.grant(null, RequestConverter.buildGrantRequest(USER_CREATE.getShortName(),
      TEST_TABLE.getTableName(), null, null,
      AccessControlProtos.Permission.Action.CREATE,
      AccessControlProtos.Permission.Action.READ,
      AccessControlProtos.Permission.Action.WRITE));

    protocol.grant(null, RequestConverter.buildGrantRequest(USER_RO.getShortName(), TEST_TABLE.getTableName(),
      TEST_FAMILY, null, AccessControlProtos.Permission.Action.READ));

    assertEquals(4, AccessControlLists.getTablePermissions(conf, TEST_TABLE.getTableName()).size());
  } finally {
    acl.close();
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:49,代码来源:TestAccessController.java

示例9: setupBeforeClass

import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; //导入方法依赖的package包/类
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  SecureTestUtil.enableSecurity(conf);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster().getCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  ACCESS_CONTROLLER = (AccessController) cpHost.findCoprocessor(AccessController.class.getName());
  CP_ENV = cpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getCoprocessorHost();
  RSCP_ENV = rsHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER, 
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableAvailable(AccessControlLists.ACL_TABLE_NAME, 5000);

  // create a set of test users
  SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
  USER_ADMIN = User.createUserForTesting(conf, "admin2", new String[0]);
  USER_RW = User.createUserForTesting(conf, "rwuser", new String[0]);
  USER_RO = User.createUserForTesting(conf, "rouser", new String[0]);
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_CREATE = User.createUserForTesting(conf, "tbl_create", new String[0]);
  USER_NONE = User.createUserForTesting(conf, "nouser", new String[0]);

  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
  htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
  htd.setOwner(USER_OWNER);
  admin.createTable(htd);

  // initilize access control
  HTable meta = new HTable(conf, AccessControlLists.ACL_TABLE_NAME);
  BlockingRpcChannel service = meta.coprocessorService(TEST_TABLE);
  AccessControlService.BlockingInterface protocol =
      AccessControlService.newBlockingStub(service);

  HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE).get(0);
  RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
  RCP_ENV = rcpHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  protocol.grant(null, RequestConverter.buildGrantRequest(USER_ADMIN.getShortName(),
      null, null, null,
      AccessControlProtos.Permission.Action.ADMIN,
      AccessControlProtos.Permission.Action.CREATE,
      AccessControlProtos.Permission.Action.READ,
      AccessControlProtos.Permission.Action.WRITE));

  protocol.grant(null, RequestConverter.buildGrantRequest(USER_RW.getShortName(),
      TEST_TABLE, TEST_FAMILY, null,
      AccessControlProtos.Permission.Action.READ,
      AccessControlProtos.Permission.Action.WRITE));

  protocol.grant(null, RequestConverter.buildGrantRequest(USER_RO.getShortName(), TEST_TABLE,
      TEST_FAMILY, null, AccessControlProtos.Permission.Action.READ));

  protocol.grant(null, RequestConverter.buildGrantRequest(USER_CREATE.getShortName(),
      TEST_TABLE, null, null, AccessControlProtos.Permission.Action.CREATE));
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:65,代码来源:TestAccessController.java


注:本文中的org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.createEnvironment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。