Java 类org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost 实例源码

项目:hbase    文件:ReplicationSource.java   
private ReplicationEndpoint createReplicationEndpoint()
    throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
  RegionServerCoprocessorHost rsServerHost = null;
  if (server instanceof HRegionServer) {
    rsServerHost = ((HRegionServer) server).getRegionServerCoprocessorHost();
  }
  String replicationEndpointImpl = replicationPeer.getPeerConfig().getReplicationEndpointImpl();
  if (replicationEndpointImpl == null) {
    // Default to HBase inter-cluster replication endpoint
    replicationEndpointImpl = HBaseInterClusterReplicationEndpoint.class.getName();
  }
  ReplicationEndpoint replicationEndpoint =
    Class.forName(replicationEndpointImpl).asSubclass(ReplicationEndpoint.class).newInstance();
  if (rsServerHost != null) {
    ReplicationEndpoint newReplicationEndPoint =
      rsServerHost.postCreateReplicationEndPoint(replicationEndpoint);
    if (newReplicationEndPoint != null) {
      // Override the newly created endpoint from the hook with configured end point
      replicationEndpoint = newReplicationEndPoint;
    }
  }
  return replicationEndpoint;
}
项目:ditb    文件:TestScanEarlyTermination.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
}
项目:ditb    文件:TestAccessController2.java   
@Test (timeout=180000)
public void testCoprocessorLoading() throws Exception {
  MasterCoprocessorHost cpHost =
      TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
  cpHost.load(MyAccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ACCESS_CONTROLLER = (AccessController) cpHost.findCoprocessor(
    MyAccessController.class.getName());
  MasterCoprocessorEnvironment CP_ENV = cpHost.createEnvironment(
    MyAccessController.class, ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  RegionServerCoprocessorEnvironment RSCP_ENV = rsHost.createEnvironment(
    MyAccessController.class, ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
}
项目:ditb    文件:TestCellACLs.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
  GROUP_USER = User.createUserForTesting(conf, "group_user", new String[] { GROUP });

  usersAndGroups = new String[] { USER_OTHER.getShortName(), AuthUtil.toGroupEntry(GROUP) };
}
项目:ditb    文件:TestCellACLWithMultipleVersions.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
  USER_OTHER2 = User.createUserForTesting(conf, "other2", new String[0]);
  GROUP_USER = User.createUserForTesting(conf, "group_user", new String[] { GROUP });

  usersAndGroups = new String[] { USER_OTHER.getShortName(), AuthUtil.toGroupEntry(GROUP) };
}
项目:ditb    文件:TestCoprocessorConfiguration.java   
@Test
public void testRegionServerCoprocessorHostDefaults() throws Exception {
  Configuration conf = new Configuration(CONF);
  RegionServerServices rsServices = mock(RegionServerServices.class);
  systemCoprocessorLoaded.set(false);
  new RegionServerCoprocessorHost(rsServices, conf);
  assertEquals("System coprocessors loading default was not honored",
    systemCoprocessorLoaded.get(),
    CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED);
}
项目:pbase    文件:TestScanEarlyTermination.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
}
项目:pbase    文件:TestCellACLs.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
}
项目:pbase    文件:TestCellACLWithMultipleVersions.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
  USER_OTHER2 = User.createUserForTesting(conf, "other2", new String[0]);
}
项目:HIndex    文件:TestScanEarlyTermination.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

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

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
}
项目:HIndex    文件:TestCellACLs.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

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

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
}
项目:HIndex    文件:TestCellACLWithMultipleVersions.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

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

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
  USER_OTHER2 = User.createUserForTesting(conf, "other2", new String[0]);
}
项目:HIndex    文件:TestAccessController.java   
@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");
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // Enable EXEC permission checking
  conf.setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);

  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.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // 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]);
}
项目:hbase    文件:TestScanEarlyTermination.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
}
项目:hbase    文件:TestAccessController2.java   
@Test (timeout=180000)
public void testCoprocessorLoading() throws Exception {
  MasterCoprocessorHost cpHost =
      TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
  cpHost.load(MyAccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ACCESS_CONTROLLER = cpHost.findCoprocessor(MyAccessController.class);
  MasterCoprocessorEnvironment CP_ENV = cpHost.createEnvironment(
    ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  RegionServerCoprocessorEnvironment RSCP_ENV = rsHost.createEnvironment(
    ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
}
项目:hbase    文件:TestCellACLs.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = cpHost.findCoprocessor(AccessController.class);
  cpHost.createEnvironment(ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
  GROUP_USER = User.createUserForTesting(conf, "group_user", new String[] { GROUP });

  usersAndGroups = new String[] { USER_OTHER.getShortName(), AuthUtil.toGroupEntry(GROUP) };
}
项目:hbase    文件:TestCellACLWithMultipleVersions.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = cpHost.findCoprocessor(AccessController.class);
  cpHost.createEnvironment(ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
  USER_OTHER2 = User.createUserForTesting(conf, "other2", new String[0]);
  GROUP_USER = User.createUserForTesting(conf, "group_user", new String[] { GROUP });

  usersAndGroups = new String[] { USER_OTHER.getShortName(), AuthUtil.toGroupEntry(GROUP) };
}
项目:hbase    文件:TestCoprocessorConfiguration.java   
@Test
public void testRegionServerCoprocessorHostDefaults() throws Exception {
  Configuration conf = new Configuration(CONF);
  RegionServerServices rsServices = mock(RegionServerServices.class);
  systemCoprocessorLoaded.set(false);
  new RegionServerCoprocessorHost(rsServices, conf);
  assertEquals("System coprocessors loading default was not honored",
      CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED, systemCoprocessorLoaded.get());
}
项目:PyroDB    文件:TestScanEarlyTermination.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
}
项目:PyroDB    文件:TestCellACLs.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
}
项目:PyroDB    文件:TestCellACLWithMultipleVersions.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster()
      .getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  AccessController ac = (AccessController)
    cpHost.findCoprocessor(AccessController.class.getName());
  cpHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
      .getRegionServerCoprocessorHost();
  rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // create a set of test users
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_OTHER = User.createUserForTesting(conf, "other", new String[0]);
  USER_OTHER2 = User.createUserForTesting(conf, "other2", new String[0]);
}
项目:c5    文件:TestAccessController.java   
@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.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // 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]);
}
项目:ditb    文件:TestWithDisabledAuthorization.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  Configuration conf = TEST_UTIL.getConfiguration();
  // Up the handlers; this test needs more than usual.
  TEST_UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
  // Enable security
  enableSecurity(conf);
  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);
  // Enable EXEC permission checking
  conf.setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // Now, DISABLE only active authorization
  conf.setBoolean(User.HBASE_SECURITY_AUTHORIZATION_CONF_KEY, false);

  // Start the minicluster
  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost =
      TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
  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)
    .getRegionServerCoprocessorHost();
  RSCP_ENV = rsHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // create a set of test users
  SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
  USER_ADMIN = User.createUserForTesting(conf, "admin2", new String[0]);
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_CREATE = User.createUserForTesting(conf, "tbl_create", new String[0]);
  USER_RW = User.createUserForTesting(conf, "rwuser", new String[0]);
  USER_RO = User.createUserForTesting(conf, "rouser", new String[0]);
  USER_QUAL = User.createUserForTesting(conf, "rwpartial", new String[0]);
  USER_NONE = User.createUserForTesting(conf, "nouser", new String[0]);
}
项目:ditb    文件:TestAccessController.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Up the handlers; this test needs more than usual.
  conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
  // Enable security
  enableSecurity(conf);
  // In this particular test case, we can't use SecureBulkLoadEndpoint because its doAs will fail
  // to move a file for a random user
  conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, AccessController.class.getName());
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // Enable EXEC permission checking
  conf.setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost =
    TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
  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)
    .getRegionServerCoprocessorHost();
  RSCP_ENV = rsHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // 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]);
  USER_ADMIN_CF = User.createUserForTesting(conf, "col_family_admin", new String[0]);

  USER_GROUP_ADMIN =
      User.createUserForTesting(conf, "user_group_admin", new String[] { GROUP_ADMIN });
  USER_GROUP_CREATE =
      User.createUserForTesting(conf, "user_group_create", new String[] { GROUP_CREATE });
  USER_GROUP_READ =
      User.createUserForTesting(conf, "user_group_read", new String[] { GROUP_READ });
  USER_GROUP_WRITE =
      User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE });

  systemUserConnection = TEST_UTIL.getConnection();
  setUpTableAndUserPermissions();
}
项目:pbase    文件:TestAccessController.java   
@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");
  // Enable security
  enableSecurity(conf);
  // In this particular test case, we can't use SecureBulkLoadEndpoint because its doAs will fail
  // to move a file for a random user
  conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, AccessController.class.getName());
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // Enable EXEC permission checking
  conf.setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost =
    TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
  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)
    .getRegionServerCoprocessorHost();
  RSCP_ENV = rsHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // 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]);
  USER_ADMIN_CF = User.createUserForTesting(conf, "col_family_admin", new String[0]);
}
项目:pbase    文件:TestRegionServerObserver.java   
/**
 * Test verifies the hooks in regions merge.
 * @throws Exception
 */
@Test
public void testCoprocessorHooksInRegionsMerge() throws Exception {
  final int NUM_MASTERS = 1;
  final int NUM_RS = 1;
  final String TABLENAME = "testRegionServerObserver";
  final String TABLENAME2 = "testRegionServerObserver_2";
  final byte[] FAM = Bytes.toBytes("fam");

  // Create config to use for this cluster
  Configuration conf = HBaseConfiguration.create();
  conf.setClass("hbase.coprocessor.regionserver.classes", CPRegionServerObserver.class,
    RegionServerObserver.class);

  // Start the cluster
  HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
  TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
  Admin admin = new HBaseAdmin(conf);
  try {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    HRegionServer regionServer = cluster.getRegionServer(0);
    RegionServerCoprocessorHost cpHost = regionServer.getRegionServerCoprocessorHost();
    Coprocessor coprocessor = cpHost.findCoprocessor(CPRegionServerObserver.class.getName());
    CPRegionServerObserver regionServerObserver = (CPRegionServerObserver) coprocessor;
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLENAME));
    desc.addFamily(new HColumnDescriptor(FAM));
    admin.createTable(desc, new byte[][] { Bytes.toBytes("row") });
    desc = new HTableDescriptor(TableName.valueOf(TABLENAME2));
    desc.addFamily(new HColumnDescriptor(FAM));
    admin.createTable(desc, new byte[][] { Bytes.toBytes("row") });
    assertFalse(regionServerObserver.wasRegionMergeCalled());
    List<HRegion> regions = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME));
    admin.mergeRegions(regions.get(0).getRegionInfo().getEncodedNameAsBytes(), regions.get(1)
        .getRegionInfo().getEncodedNameAsBytes(), true);
    int regionsCount = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME)).size();
    while (regionsCount != 1) {
      regionsCount = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME)).size();
      Thread.sleep(1000);
    }
    assertTrue(regionServerObserver.wasRegionMergeCalled());
    assertTrue(regionServerObserver.wasPreMergeCommit());
    assertTrue(regionServerObserver.wasPostMergeCommit());
    assertEquals(regionsCount, 1);
    assertEquals(regionServer.getOnlineRegions(TableName.valueOf(TABLENAME2)).size(), 1);
  } finally {
    if (admin != null) admin.close();
    TEST_UTIL.shutdownMiniCluster();
  }
}
项目:HIndex    文件:TestRegionServerObserver.java   
/**
 * Test verifies the hooks in regions merge.
 * @throws Exception
 */
@Test
public void testCoprocessorHooksInRegionsMerge() throws Exception {
  final int NUM_MASTERS = 1;
  final int NUM_RS = 1;
  final String TABLENAME = "testRegionServerObserver";
  final String TABLENAME2 = "testRegionServerObserver_2";
  final byte[] FAM = Bytes.toBytes("fam");

  // Create config to use for this cluster
  Configuration conf = HBaseConfiguration.create();
  conf.setClass("hbase.coprocessor.regionserver.classes", CPRegionServerObserver.class,
    RegionServerObserver.class);

  // Start the cluster
  HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
  TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
  HBaseAdmin admin = new HBaseAdmin(conf);
  try {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    HRegionServer regionServer = cluster.getRegionServer(0);
    RegionServerCoprocessorHost cpHost = regionServer.getCoprocessorHost();
    Coprocessor coprocessor = cpHost.findCoprocessor(CPRegionServerObserver.class.getName());
    CPRegionServerObserver regionServerObserver = (CPRegionServerObserver) coprocessor;
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLENAME));
    desc.addFamily(new HColumnDescriptor(FAM));
    admin.createTable(desc, new byte[][] { Bytes.toBytes("row") });
    desc = new HTableDescriptor(TableName.valueOf(TABLENAME2));
    desc.addFamily(new HColumnDescriptor(FAM));
    admin.createTable(desc, new byte[][] { Bytes.toBytes("row") });
    assertFalse(regionServerObserver.wasRegionMergeCalled());
    List<HRegion> regions = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME));
    admin.mergeRegions(regions.get(0).getRegionInfo().getEncodedNameAsBytes(), regions.get(1)
        .getRegionInfo().getEncodedNameAsBytes(), true);
    int regionsCount = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME)).size();
    while (regionsCount != 1) {
      regionsCount = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME)).size();
      Thread.sleep(1000);
    }
    assertTrue(regionServerObserver.wasRegionMergeCalled());
    assertTrue(regionServerObserver.wasPreMergeCommit());
    assertTrue(regionServerObserver.wasPostMergeCommit());
    assertEquals(regionsCount, 1);
    assertEquals(regionServer.getOnlineRegions(TableName.valueOf(TABLENAME2)).size(), 1);
  } finally {
    if (admin != null) admin.close();
    TEST_UTIL.shutdownMiniCluster();
  }
}
项目:IRIndex    文件:TestAccessController.java   
@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();
  }
}
项目:hbase    文件:TestWithDisabledAuthorization.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  Configuration conf = TEST_UTIL.getConfiguration();
  // Up the handlers; this test needs more than usual.
  TEST_UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
  // Enable security
  enableSecurity(conf);
  // We expect 0.98 cell ACL semantics
  conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);
  // Enable EXEC permission checking
  conf.setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // Now, DISABLE only active authorization
  conf.setBoolean(User.HBASE_SECURITY_AUTHORIZATION_CONF_KEY, false);

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

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

  // create a set of test users
  SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
  USER_ADMIN = User.createUserForTesting(conf, "admin2", new String[0]);
  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_CREATE = User.createUserForTesting(conf, "tbl_create", new String[0]);
  USER_RW = User.createUserForTesting(conf, "rwuser", new String[0]);
  USER_RO = User.createUserForTesting(conf, "rouser", new String[0]);
  USER_QUAL = User.createUserForTesting(conf, "rwpartial", new String[0]);
  USER_NONE = User.createUserForTesting(conf, "nouser", new String[0]);
}
项目:hbase    文件:TestAccessController3.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  String accessControllerClassName = FaultyAccessController.class.getName();
  // In this particular test case, we can't use SecureBulkLoadEndpoint because its doAs will fail
  // to move a file for a random user
  conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, accessControllerClassName);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // Enable EXEC permission checking
  conf.setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost =
    TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
  cpHost.load(FaultyAccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
  ACCESS_CONTROLLER = (AccessController) cpHost.findCoprocessor(accessControllerClassName);
  CP_ENV = cpHost.createEnvironment(ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
  RegionServerCoprocessorHost rsHost;
  do {
    rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0)
        .getRegionServerCoprocessorHost();
  } while (rsHost == null);
  RSCP_ENV = rsHost.createEnvironment(ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);

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

  // 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]);
  USER_ADMIN_CF = User.createUserForTesting(conf, "col_family_admin", new String[0]);

  USER_GROUP_ADMIN =
      User.createUserForTesting(conf, "user_group_admin", new String[] { GROUP_ADMIN });
  USER_GROUP_CREATE =
      User.createUserForTesting(conf, "user_group_create", new String[] { GROUP_CREATE });
  USER_GROUP_READ =
      User.createUserForTesting(conf, "user_group_read", new String[] { GROUP_READ });
  USER_GROUP_WRITE =
      User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE });

  systemUserConnection = TEST_UTIL.getConnection();
  setUpTableAndUserPermissions();
}
项目:hbase    文件:TestAccessController.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // setup configuration
  conf = TEST_UTIL.getConfiguration();
  // Up the handlers; this test needs more than usual.
  conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
  // Enable security
  enableSecurity(conf);
  // In this particular test case, we can't use SecureBulkLoadEndpoint because its doAs will fail
  // to move a file for a random user
  conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, AccessController.class.getName());
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // Enable EXEC permission checking
  conf.setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);

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

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

  // 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]);
  USER_ADMIN_CF = User.createUserForTesting(conf, "col_family_admin", new String[0]);

  USER_GROUP_ADMIN =
      User.createUserForTesting(conf, "user_group_admin", new String[] { GROUP_ADMIN });
  USER_GROUP_CREATE =
      User.createUserForTesting(conf, "user_group_create", new String[] { GROUP_CREATE });
  USER_GROUP_READ =
      User.createUserForTesting(conf, "user_group_read", new String[] { GROUP_READ });
  USER_GROUP_WRITE =
      User.createUserForTesting(conf, "user_group_write", new String[] { GROUP_WRITE });

  systemUserConnection = TEST_UTIL.getConnection();
  setUpTableAndUserPermissions();
}
项目:hbase    文件:TestCoreRegionServerCoprocessor.java   
@Before
public void before() throws IOException {
  String methodName = this.name.getMethodName();
  this.rss = new MockRegionServerServices(HTU.getConfiguration());
  this.rsch = new RegionServerCoprocessorHost(this.rss, HTU.getConfiguration());
}
项目:PyroDB    文件:TestAccessController.java   
@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");
  // Enable security
  enableSecurity(conf);
  // Verify enableSecurity sets up what we require
  verifyConfiguration(conf);

  // Enable EXEC permission checking
  conf.setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);

  TEST_UTIL.startMiniCluster();
  MasterCoprocessorHost cpHost =
    TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
  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)
    .getRegionServerCoprocessorHost();
  RSCP_ENV = rsHost.createEnvironment(AccessController.class, ACCESS_CONTROLLER,
    Coprocessor.PRIORITY_HIGHEST, 1, conf);

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName());

  // 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]);
}
项目:PyroDB    文件:TestRegionServerObserver.java   
/**
 * Test verifies the hooks in regions merge.
 * @throws Exception
 */
@Test
public void testCoprocessorHooksInRegionsMerge() throws Exception {
  final int NUM_MASTERS = 1;
  final int NUM_RS = 1;
  final String TABLENAME = "testRegionServerObserver";
  final String TABLENAME2 = "testRegionServerObserver_2";
  final byte[] FAM = Bytes.toBytes("fam");

  // Create config to use for this cluster
  Configuration conf = HBaseConfiguration.create();
  conf.setClass("hbase.coprocessor.regionserver.classes", CPRegionServerObserver.class,
    RegionServerObserver.class);

  // Start the cluster
  HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
  TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
  HBaseAdmin admin = new HBaseAdmin(conf);
  try {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    HRegionServer regionServer = cluster.getRegionServer(0);
    RegionServerCoprocessorHost cpHost = regionServer.getRegionServerCoprocessorHost();
    Coprocessor coprocessor = cpHost.findCoprocessor(CPRegionServerObserver.class.getName());
    CPRegionServerObserver regionServerObserver = (CPRegionServerObserver) coprocessor;
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLENAME));
    desc.addFamily(new HColumnDescriptor(FAM));
    admin.createTable(desc, new byte[][] { Bytes.toBytes("row") });
    desc = new HTableDescriptor(TableName.valueOf(TABLENAME2));
    desc.addFamily(new HColumnDescriptor(FAM));
    admin.createTable(desc, new byte[][] { Bytes.toBytes("row") });
    assertFalse(regionServerObserver.wasRegionMergeCalled());
    List<HRegion> regions = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME));
    admin.mergeRegions(regions.get(0).getRegionInfo().getEncodedNameAsBytes(), regions.get(1)
        .getRegionInfo().getEncodedNameAsBytes(), true);
    int regionsCount = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME)).size();
    while (regionsCount != 1) {
      regionsCount = regionServer.getOnlineRegions(TableName.valueOf(TABLENAME)).size();
      Thread.sleep(1000);
    }
    assertTrue(regionServerObserver.wasRegionMergeCalled());
    assertTrue(regionServerObserver.wasPreMergeCommit());
    assertTrue(regionServerObserver.wasPostMergeCommit());
    assertEquals(regionsCount, 1);
    assertEquals(regionServer.getOnlineRegions(TableName.valueOf(TABLENAME2)).size(), 1);
  } finally {
    if (admin != null) admin.close();
    TEST_UTIL.shutdownMiniCluster();
  }
}
项目:HBase-Research    文件:TestAccessController.java   
@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();
  }
}
项目:hbase-0.94.8-qod    文件:TestAccessController.java   
@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();
  }
}
项目:hbase-0.94.8-qod    文件:TestAccessController.java   
@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();
  }
}
项目:DominoHBase    文件:TestAccessController.java   
@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));
}
项目:hindex    文件:TestAccessController.java   
@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();
  }
}