Java 类org.apache.hadoop.hbase.coprocessor.CoprocessorHost 实例源码

项目:ditb    文件:VisibilityController.java   
/****************************** Region related hooks ******************************/

  @Override
  public void postOpen(ObserverContext<RegionCoprocessorEnvironment> e) {
    // Read the entire labels table and populate the zk
    if (e.getEnvironment().getRegion().getRegionInfo().getTable().equals(LABELS_TABLE_NAME)) {
      this.labelsRegion = true;
      synchronized (this) {
        this.accessControllerAvailable = CoprocessorHost.getLoadedCoprocessors()
          .contains(AccessController.class.getName());
      }
      // Defer the init of VisibilityLabelService on labels region until it is in recovering state.
      if (!e.getEnvironment().getRegion().isRecovering()) {
        initVisibilityLabelService(e.getEnvironment());
      }
    } else {
      checkAuths = e.getEnvironment().getConfiguration()
          .getBoolean(VisibilityConstants.CHECK_AUTHS_FOR_MUTATION, false);
      initVisibilityLabelService(e.getEnvironment());
    }
  }
项目:ditb    文件:TestGenerateDelegationToken.java   
@BeforeClass
public static void setUp() throws Exception {
  Properties conf = MiniKdc.createConf();
  conf.put(MiniKdc.DEBUG, true);
  KDC = new MiniKdc(conf, new File(TEST_UTIL.getDataTestDir("kdc").toUri().getPath()));
  KDC.start();
  USERNAME = UserGroupInformation.getLoginUser().getShortUserName();
  PRINCIPAL = USERNAME + "/" + HOST;
  HTTP_PRINCIPAL = "HTTP/" + HOST;
  KDC.createPrincipal(KEYTAB_FILE, PRINCIPAL, HTTP_PRINCIPAL);
  TEST_UTIL.startMiniZKCluster();

  HBaseKerberosUtils.setKeytabFileForTesting(KEYTAB_FILE.getAbsolutePath());
  HBaseKerberosUtils.setPrincipalForTesting(PRINCIPAL + "@" + KDC.getRealm());
  HBaseKerberosUtils.setSecuredConfiguration(TEST_UTIL.getConfiguration());
  setHdfsSecuredConfiguration(TEST_UTIL.getConfiguration());
  UserGroupInformation.setConfiguration(TEST_UTIL.getConfiguration());
  TEST_UTIL.getConfiguration().setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
    TokenProvider.class.getName());
  TEST_UTIL.startMiniDFSCluster(1);
  Path rootdir = TEST_UTIL.getDataTestDirOnTestFS("TestGenerateDelegationToken");
  FSUtils.setRootDir(TEST_UTIL.getConfiguration(), rootdir);
  CLUSTER = new LocalHBaseCluster(TEST_UTIL.getConfiguration(), 1);
  CLUSTER.startup();
}
项目:ditb    文件:TestClientOperationInterrupt.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = HBaseConfiguration.create();
  conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      TestCoprocessor.class.getName());
  util = new HBaseTestingUtility(conf);
  util.startMiniCluster();

  Admin admin = util.getHBaseAdmin();
  if (admin.tableExists(tableName)) {
    if (admin.isTableEnabled(tableName)) {
      admin.disableTable(tableName);
    }
    admin.deleteTable(tableName);
  }
  util.createTable(tableName, new byte[][]{dummy, test});

  Table ht = new HTable(conf, tableName);
  Put p = new Put(row1);
  p.add(dummy, dummy, dummy);
  ht.put(p);
}
项目:ditb    文件:TestAssignmentManagerOnCluster.java   
static void setupOnce() throws Exception {
  // Using the our load balancer to control region plans
  conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
    MyLoadBalancer.class, LoadBalancer.class);
  conf.setClass(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
    MyRegionObserver.class, RegionObserver.class);
  // Reduce the maximum attempts to speed up the test
  conf.setInt("hbase.assignment.maximum.attempts", 3);
  // Put meta on master to avoid meta server shutdown handling
  conf.set("hbase.balancer.tablesOnMaster", "hbase:meta");
  conf.setInt("hbase.master.maximum.ping.server.attempts", 3);
  conf.setInt("hbase.master.ping.server.retry.sleep.interval", 1);

  TEST_UTIL.startMiniCluster(1, 4, null, MyMaster.class, MyRegionServer.class);
  admin = TEST_UTIL.getHBaseAdmin();
}
项目:ditb    文件:TestFSHLog.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Make block sizes small.
  TEST_UTIL.getConfiguration().setInt("dfs.blocksize", 1024 * 1024);
  // quicker heartbeat interval for faster DN death notification
  TEST_UTIL.getConfiguration().setInt("dfs.namenode.heartbeat.recheck-interval", 5000);
  TEST_UTIL.getConfiguration().setInt("dfs.heartbeat.interval", 1);
  TEST_UTIL.getConfiguration().setInt("dfs.client.socket-timeout", 5000);

  // faster failover with cluster.shutdown();fs.close() idiom
  TEST_UTIL.getConfiguration()
      .setInt("hbase.ipc.client.connect.max.retries", 1);
  TEST_UTIL.getConfiguration().setInt(
      "dfs.client.block.recovery.retries", 1);
  TEST_UTIL.getConfiguration().setInt(
    "hbase.ipc.client.connection.maxidletime", 500);
  TEST_UTIL.getConfiguration().set(CoprocessorHost.WAL_COPROCESSOR_CONF_KEY,
      SampleRegionWALObserver.class.getName());
  TEST_UTIL.startMiniDFSCluster(3);

  conf = TEST_UTIL.getConfiguration();
  fs = TEST_UTIL.getDFSCluster().getFileSystem();
}
项目:ditb    文件:TestProtobufLog.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Make block sizes small.
  TEST_UTIL.getConfiguration().setInt("dfs.blocksize", 1024 * 1024);
  // needed for testAppendClose()
  TEST_UTIL.getConfiguration().setBoolean("dfs.support.broken.append", true);
  TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
  // quicker heartbeat interval for faster DN death notification
  TEST_UTIL.getConfiguration().setInt("dfs.namenode.heartbeat.recheck-interval", 5000);
  TEST_UTIL.getConfiguration().setInt("dfs.heartbeat.interval", 1);
  TEST_UTIL.getConfiguration().setInt("dfs.client.socket-timeout", 5000);

  // faster failover with cluster.shutdown();fs.close() idiom
  TEST_UTIL.getConfiguration()
      .setInt("hbase.ipc.client.connect.max.retries", 1);
  TEST_UTIL.getConfiguration().setInt(
      "dfs.client.block.recovery.retries", 1);
  TEST_UTIL.getConfiguration().setInt(
    "hbase.ipc.client.connection.maxidletime", 500);
  TEST_UTIL.getConfiguration().set(CoprocessorHost.WAL_COPROCESSOR_CONF_KEY,
      SampleRegionWALObserver.class.getName());
  TEST_UTIL.startMiniDFSCluster(3);
}
项目:LCIndex-HBase-0.94.16    文件:TestMasterReplication.java   
@Before
public void setUp() throws Exception {
  baseConfiguration = HBaseConfiguration.create();
  // smaller block size and capacity to trigger more operations
  // and test them
  baseConfiguration.setInt("hbase.regionserver.hlog.blocksize", 1024 * 20);
  baseConfiguration.setInt("replication.source.size.capacity", 1024);
  baseConfiguration.setLong("replication.source.sleepforretries", 100);
  baseConfiguration.setInt("hbase.regionserver.maxlogs", 10);
  baseConfiguration.setLong("hbase.master.logcleaner.ttl", 10);
  baseConfiguration.setBoolean(HConstants.REPLICATION_ENABLE_KEY, true);
  baseConfiguration.setBoolean("dfs.support.append", true);
  baseConfiguration.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  baseConfiguration.setStrings(
      CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      CoprocessorCounter.class.getName());

  table = new HTableDescriptor(tableName);
  HColumnDescriptor fam = new HColumnDescriptor(famName);
  fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  table.addFamily(fam);
  fam = new HColumnDescriptor(noRepfamName);
  table.addFamily(fam);
}
项目:LCIndex-HBase-0.94.16    文件:TestServerCustomProtocol.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  util.getConfiguration().set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
      PingHandler.class.getName());
  util.startMiniCluster(1);
  cluster = util.getMiniHBaseCluster();

  HTable table = util.createTable(TEST_TABLE, TEST_FAMILY);
  util.createMultiRegions(util.getConfiguration(), table, TEST_FAMILY,
      new byte[][]{ HConstants.EMPTY_BYTE_ARRAY,
          ROW_B, ROW_C});

  Put puta = new Put( ROW_A );
  puta.add(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  table.put(puta);

  Put putb = new Put( ROW_B );
  putb.add(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  table.put(putb);

  Put putc = new Put( ROW_C );
  putc.add(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  table.put(putc);
}
项目:pbase    文件:VisibilityController.java   
/****************************** Region related hooks ******************************/

  @Override
  public void postOpen(ObserverContext<RegionCoprocessorEnvironment> e) {
    // Read the entire labels table and populate the zk
    if (e.getEnvironment().getRegion().getRegionInfo().getTable().equals(LABELS_TABLE_NAME)) {
      this.labelsRegion = true;
      this.acOn = CoprocessorHost.getLoadedCoprocessors().contains(AccessController.class.getName());
      // Defer the init of VisibilityLabelService on labels region until it is in recovering state.
      if (!e.getEnvironment().getRegion().isRecovering()) {
        initVisibilityLabelService(e.getEnvironment());
      }
    } else {
      checkAuths = e.getEnvironment().getConfiguration()
          .getBoolean(VisibilityConstants.CHECK_AUTHS_FOR_MUTATION, false);
      initVisibilityLabelService(e.getEnvironment());
    }
  }
项目:pbase    文件:TestMasterReplication.java   
@Before
public void setUp() throws Exception {
  baseConfiguration = HBaseConfiguration.create();
  // smaller block size and capacity to trigger more operations
  // and test them
  baseConfiguration.setInt("hbase.regionserver.hlog.blocksize", 1024 * 20);
  baseConfiguration.setInt("replication.source.size.capacity", 1024);
  baseConfiguration.setLong("replication.source.sleepforretries", 100);
  baseConfiguration.setInt("hbase.regionserver.maxlogs", 10);
  baseConfiguration.setLong("hbase.master.logcleaner.ttl", 10);
  baseConfiguration.setBoolean(HConstants.REPLICATION_ENABLE_KEY,
      HConstants.REPLICATION_ENABLE_DEFAULT);
  baseConfiguration.setBoolean("dfs.support.append", true);
  baseConfiguration.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  baseConfiguration.setStrings(
      CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      CoprocessorCounter.class.getName());

  table = new HTableDescriptor(tableName);
  HColumnDescriptor fam = new HColumnDescriptor(famName);
  fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  table.addFamily(fam);
  fam = new HColumnDescriptor(noRepfamName);
  table.addFamily(fam);
}
项目:pbase    文件:SecureTestUtil.java   
public static void enableSecurity(Configuration conf) throws IOException {
  conf.set("hadoop.security.authorization", "false");
  conf.set("hadoop.security.authentication", "simple");
  conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, AccessController.class.getName());
  conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, AccessController.class.getName() +
    "," + SecureBulkLoadEndpoint.class.getName());
  conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, AccessController.class.getName());
  // The secure minicluster creates separate service principals based on the
  // current user's name, one for each slave. We need to add all of these to
  // the superuser list or security won't function properly. We expect the
  // HBase service account(s) to have superuser privilege.
  String currentUser = User.getCurrent().getName();
  StringBuffer sb = new StringBuffer();
  sb.append("admin,");
  sb.append(currentUser);
  // Assumes we won't ever have a minicluster with more than 5 slaves
  for (int i = 0; i < 5; i++) {
    sb.append(',');
    sb.append(currentUser); sb.append(".hfs."); sb.append(i);
  }
  conf.set("hbase.superuser", sb.toString());
  // Need HFile V3 for tags for security features
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
}
项目:pbase    文件:TestClientOperationInterrupt.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = HBaseConfiguration.create();
  conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      TestCoprocessor.class.getName());
  util = new HBaseTestingUtility(conf);
  util.startMiniCluster();

  Admin admin = util.getHBaseAdmin();
  if (admin.tableExists(tableName)) {
    if (admin.isTableEnabled(tableName)) {
      admin.disableTable(tableName);
    }
    admin.deleteTable(tableName);
  }
  util.createTable(tableName, new byte[][]{dummy, test});

  Table ht = new HTable(conf, tableName);
  Put p = new Put(row1);
  p.add(dummy, dummy, dummy);
  ht.put(p);
}
项目:pbase    文件:TestAssignmentManagerOnCluster.java   
static void setupOnce() throws Exception {
  // Using the our load balancer to control region plans
  conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
    MyLoadBalancer.class, LoadBalancer.class);
  conf.setClass(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
    MyRegionObserver.class, RegionObserver.class);
  // Reduce the maximum attempts to speed up the test
  conf.setInt("hbase.assignment.maximum.attempts", 3);
  // Put meta on master to avoid meta server shutdown handling
  conf.set("hbase.balancer.tablesOnMaster", "hbase:meta");
  conf.setInt("hbase.master.maximum.ping.server.attempts", 3);
  conf.setInt("hbase.master.ping.server.retry.sleep.interval", 1);

  TEST_UTIL.startMiniCluster(1, 4, null, MyMaster.class, MyRegionServer.class);
  admin = TEST_UTIL.getHBaseAdmin();
}
项目:pbase    文件:TestFSHLog.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Make block sizes small.
  TEST_UTIL.getConfiguration().setInt("dfs.blocksize", 1024 * 1024);
  // quicker heartbeat interval for faster DN death notification
  TEST_UTIL.getConfiguration().setInt("dfs.namenode.heartbeat.recheck-interval", 5000);
  TEST_UTIL.getConfiguration().setInt("dfs.heartbeat.interval", 1);
  TEST_UTIL.getConfiguration().setInt("dfs.client.socket-timeout", 5000);

  // faster failover with cluster.shutdown();fs.close() idiom
  TEST_UTIL.getConfiguration()
      .setInt("hbase.ipc.client.connect.max.retries", 1);
  TEST_UTIL.getConfiguration().setInt(
      "dfs.client.block.recovery.retries", 1);
  TEST_UTIL.getConfiguration().setInt(
    "hbase.ipc.client.connection.maxidletime", 500);
  TEST_UTIL.getConfiguration().set(CoprocessorHost.WAL_COPROCESSOR_CONF_KEY,
      SampleRegionWALObserver.class.getName());
  TEST_UTIL.startMiniDFSCluster(3);

  conf = TEST_UTIL.getConfiguration();
  fs = TEST_UTIL.getDFSCluster().getFileSystem();
}
项目:pbase    文件:TestProtobufLog.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Make block sizes small.
  TEST_UTIL.getConfiguration().setInt("dfs.blocksize", 1024 * 1024);
  // needed for testAppendClose()
  TEST_UTIL.getConfiguration().setBoolean("dfs.support.broken.append", true);
  TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
  // quicker heartbeat interval for faster DN death notification
  TEST_UTIL.getConfiguration().setInt("dfs.namenode.heartbeat.recheck-interval", 5000);
  TEST_UTIL.getConfiguration().setInt("dfs.heartbeat.interval", 1);
  TEST_UTIL.getConfiguration().setInt("dfs.client.socket-timeout", 5000);

  // faster failover with cluster.shutdown();fs.close() idiom
  TEST_UTIL.getConfiguration()
      .setInt("hbase.ipc.client.connect.max.retries", 1);
  TEST_UTIL.getConfiguration().setInt(
      "dfs.client.block.recovery.retries", 1);
  TEST_UTIL.getConfiguration().setInt(
    "hbase.ipc.client.connection.maxidletime", 500);
  TEST_UTIL.getConfiguration().set(CoprocessorHost.WAL_COPROCESSOR_CONF_KEY,
      SampleRegionWALObserver.class.getName());
  TEST_UTIL.startMiniDFSCluster(3);
}
项目:pbase    文件:TestShell.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start mini cluster
  TEST_UTIL.getConfiguration().setBoolean("hbase.online.schema.update.enable", true);
  TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
  TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
  TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
  TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);
  // Security setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
  VisibilityTestUtil.enableVisiblityLabels(TEST_UTIL.getConfiguration());

  TEST_UTIL.startMiniCluster();

  // Configure jruby runtime
  List<String> loadPaths = new ArrayList();
  loadPaths.add("src/main/ruby");
  loadPaths.add("src/test/ruby");
  jruby.getProvider().setLoadPaths(loadPaths);
  jruby.put("$TEST_CLUSTER", TEST_UTIL);
  System.setProperty("jruby.jit.logging.verbose", "true");
  System.setProperty("jruby.jit.logging", "true");
  System.setProperty("jruby.native.verbose", "true");
}
项目:HIndex    文件:TestMasterReplication.java   
@Before
public void setUp() throws Exception {
  baseConfiguration = HBaseConfiguration.create();
  // smaller block size and capacity to trigger more operations
  // and test them
  baseConfiguration.setInt("hbase.regionserver.hlog.blocksize", 1024 * 20);
  baseConfiguration.setInt("replication.source.size.capacity", 1024);
  baseConfiguration.setLong("replication.source.sleepforretries", 100);
  baseConfiguration.setInt("hbase.regionserver.maxlogs", 10);
  baseConfiguration.setLong("hbase.master.logcleaner.ttl", 10);
  baseConfiguration.setBoolean(HConstants.REPLICATION_ENABLE_KEY,
      HConstants.REPLICATION_ENABLE_DEFAULT);
  baseConfiguration.setBoolean("dfs.support.append", true);
  baseConfiguration.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  baseConfiguration.setStrings(
      CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      CoprocessorCounter.class.getName());

  table = new HTableDescriptor(TableName.valueOf(tableName));
  HColumnDescriptor fam = new HColumnDescriptor(famName);
  fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  table.addFamily(fam);
  fam = new HColumnDescriptor(noRepfamName);
  table.addFamily(fam);
}
项目:HIndex    文件:SecureTestUtil.java   
public static void enableSecurity(Configuration conf) throws IOException {
  conf.set("hadoop.security.authorization", "false");
  conf.set("hadoop.security.authentication", "simple");
  conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, AccessController.class.getName());
  conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, AccessController.class.getName() +
    "," + SecureBulkLoadEndpoint.class.getName());
  conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, AccessController.class.getName());
  // The secure minicluster creates separate service principals based on the
  // current user's name, one for each slave. We need to add all of these to
  // the superuser list or security won't function properly. We expect the
  // HBase service account(s) to have superuser privilege.
  String currentUser = User.getCurrent().getName();
  StringBuffer sb = new StringBuffer();
  sb.append("admin,");
  sb.append(currentUser);
  // Assumes we won't ever have a minicluster with more than 5 slaves
  for (int i = 0; i < 5; i++) {
    sb.append(',');
    sb.append(currentUser); sb.append(".hfs."); sb.append(i);
  }
  conf.set("hbase.superuser", sb.toString());
  // Need HFile V3 for tags for security features
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
}
项目:HIndex    文件:TestClientOperationInterrupt.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = HBaseConfiguration.create();
  conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      TestCoprocessor.class.getName());
  util = new HBaseTestingUtility(conf);
  util.startMiniCluster();

  HBaseAdmin admin = util.getHBaseAdmin();
  if (admin.tableExists(tableName)) {
    if (admin.isTableEnabled(tableName)) {
      admin.disableTable(tableName);
    }
    admin.deleteTable(tableName);
  }
  util.createTable(tableName, new byte[][]{dummy, test});

  HTable ht = new HTable(conf, tableName);
  Put p = new Put(row1);
  p.add(dummy, dummy, dummy);
  ht.put(p);
}
项目:HIndex    文件:TestShell.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start mini cluster
  TEST_UTIL.getConfiguration().setBoolean("hbase.online.schema.update.enable", true);
  TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
  TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
  TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
  TEST_UTIL.startMiniCluster();

  // Configure jruby runtime
  List<String> loadPaths = new ArrayList();
  loadPaths.add("src/main/ruby");
  loadPaths.add("src/test/ruby");
  jruby.getProvider().setLoadPaths(loadPaths);
  jruby.put("$TEST_CLUSTER", TEST_UTIL);
}
项目:HIndex    文件:TestScanWhenTTLExpired.java   
@BeforeClass
public static void before() throws Exception {
  Configuration conf = TESTING_UTIL.getConfiguration();
  conf.setInt("hbase.balancer.period", 60000);
  // Needed because some tests have splits happening on RS that are killed
  // We don't want to wait 3min for the master to figure it out
  conf.setInt("hbase.master.assignment.timeoutmonitor.timeout", 4000);
  conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, IndexMasterObserver.class.getName());
  conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, IndexRegionObserver.class.getName());
  conf.set(CoprocessorHost.WAL_COPROCESSOR_CONF_KEY, IndexWALObserver.class.getName());
  conf.setBoolean("hbase.use.secondary.index", true);
  conf.setInt("hbase.hstore.compactionThreshold",5);
  conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, SecIndexLoadBalancer.class,
    LoadBalancer.class);
  TESTING_UTIL.startMiniCluster(NB_SERVERS);

}
项目:IRIndex    文件:TestServerCustomProtocol.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  util.getConfiguration().set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
      PingHandler.class.getName());
  util.startMiniCluster(1);
  cluster = util.getMiniHBaseCluster();

  HTable table = util.createTable(TEST_TABLE, TEST_FAMILY);
  util.createMultiRegions(util.getConfiguration(), table, TEST_FAMILY,
      new byte[][]{ HConstants.EMPTY_BYTE_ARRAY,
          ROW_B, ROW_C});

  Put puta = new Put( ROW_A );
  puta.add(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  table.put(puta);

  Put putb = new Put( ROW_B );
  putb.add(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  table.put(putb);

  Put putc = new Put( ROW_C );
  putc.add(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  table.put(putc);
}
项目:PyroDB    文件:TestShell.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start mini cluster
  TEST_UTIL.getConfiguration().setBoolean("hbase.online.schema.update.enable", true);
  TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
  TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
  TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
  TEST_UTIL.startMiniCluster();

  // Configure jruby runtime
  List<String> loadPaths = new ArrayList();
  loadPaths.add("src/main/ruby");
  loadPaths.add("src/test/ruby");
  jruby.getProvider().setLoadPaths(loadPaths);
  jruby.put("$TEST_CLUSTER", TEST_UTIL);
}
项目:hbase    文件:BackupManager.java   
/**
 * This method modifies the Region Server configuration in order to inject backup-related features
 * TESTs only.
 * @param conf configuration
 */
@VisibleForTesting
public static void decorateRegionServerConfiguration(Configuration conf) {
  if (!isBackupEnabled(conf)) {
    return;
  }

  String classes = conf.get(ProcedureManagerHost.REGIONSERVER_PROCEDURE_CONF_KEY);
  String regionProcedureClass = LogRollRegionServerProcedureManager.class.getName();
  if (classes == null) {
    conf.set(ProcedureManagerHost.REGIONSERVER_PROCEDURE_CONF_KEY, regionProcedureClass);
  } else if (!classes.contains(regionProcedureClass)) {
    conf.set(ProcedureManagerHost.REGIONSERVER_PROCEDURE_CONF_KEY, classes + ","
        + regionProcedureClass);
  }
  String coproc = conf.get(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY);
  String regionObserverClass = BackupObserver.class.getName();
  conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, (coproc == null ? "" : coproc + ",") +
      regionObserverClass);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Added region procedure manager: " + regionProcedureClass +
      ". Added region observer: " + regionObserverClass);
  }
}
项目:hbase    文件:TestAsyncAggregationClient.java   
@BeforeClass
public static void setUp() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
    AggregateImplementation.class.getName());
  UTIL.startMiniCluster(3);
  byte[][] splitKeys = new byte[8][];
  for (int i = 111; i < 999; i += 111) {
    splitKeys[i / 111 - 1] = Bytes.toBytes(String.format("%03d", i));
  }
  UTIL.createTable(TABLE_NAME, CF, splitKeys);
  CONN = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get();
  TABLE = CONN.getTable(TABLE_NAME);
  TABLE.putAll(LongStream.range(0, COUNT)
      .mapToObj(l -> new Put(Bytes.toBytes(String.format("%03d", l)))
          .addColumn(CF, CQ, Bytes.toBytes(l)).addColumn(CF, CQ2, Bytes.toBytes(l * l)))
      .collect(Collectors.toList())).get();
}
项目:hbase    文件:VisibilityController.java   
/****************************** Region related hooks ******************************/

  @Override
  public void postOpen(ObserverContext<RegionCoprocessorEnvironment> e) {
    // Read the entire labels table and populate the zk
    if (e.getEnvironment().getRegion().getRegionInfo().getTable().equals(LABELS_TABLE_NAME)) {
      this.labelsRegion = true;
      synchronized (this) {
        this.accessControllerAvailable = CoprocessorHost.getLoadedCoprocessors()
          .contains(AccessController.class.getName());
      }
      initVisibilityLabelService(e.getEnvironment());
    } else {
      checkAuths = e.getEnvironment().getConfiguration()
          .getBoolean(VisibilityConstants.CHECK_AUTHS_FOR_MUTATION, false);
      initVisibilityLabelService(e.getEnvironment());
    }
  }
项目:hbase    文件:MasterCoprocessorHost.java   
@Override
public MasterCoprocessor checkAndGetInstance(Class<?> implClass)
    throws InstantiationException, IllegalAccessException {
  if (MasterCoprocessor.class.isAssignableFrom(implClass)) {
    return (MasterCoprocessor)implClass.newInstance();
  } else if (CoprocessorService.class.isAssignableFrom(implClass)) {
    // For backward compatibility with old CoprocessorService impl which don't extend
    // MasterCoprocessor.
    return new CoprocessorServiceBackwardCompatiblity.MasterCoprocessorService(
        (CoprocessorService)implClass.newInstance());
  } else {
    LOG.error(implClass.getName() + " is not of type MasterCoprocessor. Check the "
        + "configuration " + CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY);
    return null;
  }
}
项目:hbase    文件:HMaster.java   
/**
 * Adds the {@code MasterSpaceQuotaObserver} to the list of configured Master observers to
 * automatically remove space quotas for a table when that table is deleted.
 */
@VisibleForTesting
public void updateConfigurationForSpaceQuotaObserver(Configuration conf) {
  // We're configured to not delete quotas on table deletion, so we don't need to add the obs.
  if (!conf.getBoolean(
        MasterSpaceQuotaObserver.REMOVE_QUOTA_ON_TABLE_DELETE,
        MasterSpaceQuotaObserver.REMOVE_QUOTA_ON_TABLE_DELETE_DEFAULT)) {
    return;
  }
  String[] masterCoprocs = conf.getStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY);
  final int length = null == masterCoprocs ? 0 : masterCoprocs.length;
  String[] updatedCoprocs = new String[length + 1];
  if (length > 0) {
    System.arraycopy(masterCoprocs, 0, updatedCoprocs, 0, masterCoprocs.length);
  }
  updatedCoprocs[length] = MasterSpaceQuotaObserver.class.getName();
  conf.setStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, updatedCoprocs);
}
项目:hbase    文件:RegionServerCoprocessorHost.java   
@Override
public RegionServerCoprocessor checkAndGetInstance(Class<?> implClass)
    throws InstantiationException, IllegalAccessException {
  if (RegionServerCoprocessor.class.isAssignableFrom(implClass)) {
    return (RegionServerCoprocessor)implClass.newInstance();
  } else if (SingletonCoprocessorService.class.isAssignableFrom(implClass)) {
    // For backward compatibility with old CoprocessorService impl which don't extend
    // RegionCoprocessor.
    return new CoprocessorServiceBackwardCompatiblity.RegionServerCoprocessorService(
        (SingletonCoprocessorService)implClass.newInstance());
  } else {
    LOG.error(implClass.getName() + " is not of type RegionServerCoprocessor. Check the "
        + "configuration " + CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY);
    return null;
  }
}
项目:hbase    文件:TestMasterReplication.java   
@Before
public void setUp() throws Exception {
  baseConfiguration = HBaseConfiguration.create();
  // smaller block size and capacity to trigger more operations
  // and test them
  baseConfiguration.setInt("hbase.regionserver.hlog.blocksize", 1024 * 20);
  baseConfiguration.setInt("replication.source.size.capacity", 1024);
  baseConfiguration.setLong("replication.source.sleepforretries", 100);
  baseConfiguration.setInt("hbase.regionserver.maxlogs", 10);
  baseConfiguration.setLong("hbase.master.logcleaner.ttl", 10);
  baseConfiguration.setBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY, true);
  baseConfiguration.set("hbase.replication.source.fs.conf.provider",
    TestSourceFSConfigurationProvider.class.getCanonicalName());
  baseConfiguration.set(HConstants.REPLICATION_CLUSTER_ID, "12345");
  baseConfiguration.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  baseConfiguration.setStrings(
      CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      CoprocessorCounter.class.getName());
  table = TableDescriptorBuilder.newBuilder(tableName)
      .addColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(famName)
          .setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build())
      .addColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(famName1)
          .setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build())
      .addColumnFamily(ColumnFamilyDescriptorBuilder.of(noRepfamName)).build();
}
项目:hbase    文件:SecureTestCluster.java   
/**
 * Setup and start kerberos, hbase
 */
@BeforeClass
public static void setUp() throws Exception {
  KDC = TEST_UTIL.setupMiniKdc(KEYTAB_FILE);
  USERNAME = UserGroupInformation.getLoginUser().getShortUserName();
  PRINCIPAL = USERNAME + "/" + HOST;
  HTTP_PRINCIPAL = "HTTP/" + HOST;
  KDC.createPrincipal(KEYTAB_FILE, PRINCIPAL, HTTP_PRINCIPAL);
  TEST_UTIL.startMiniZKCluster();

  HBaseKerberosUtils.setPrincipalForTesting(PRINCIPAL + "@" + KDC.getRealm());
  HBaseKerberosUtils.setSecuredConfiguration(TEST_UTIL.getConfiguration());

  setHdfsSecuredConfiguration(TEST_UTIL.getConfiguration());
  UserGroupInformation.setConfiguration(TEST_UTIL.getConfiguration());
  TEST_UTIL.getConfiguration().setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
      TokenProvider.class.getName());
  TEST_UTIL.startMiniDFSCluster(1);
  Path rootdir = TEST_UTIL.getDataTestDirOnTestFS("TestGenerateDelegationToken");
  FSUtils.setRootDir(TEST_UTIL.getConfiguration(), rootdir);
  CLUSTER = new LocalHBaseCluster(TEST_UTIL.getConfiguration(), 1);
  CLUSTER.startup();
}
项目:hbase    文件:SecureTestUtil.java   
public static void verifyConfiguration(Configuration conf) {
  String coprocs = conf.get(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY);
  boolean accessControllerLoaded = false;
  for (String coproc : coprocs.split(",")) {
    try {
      accessControllerLoaded = AccessController.class.isAssignableFrom(Class.forName(coproc));
      if (accessControllerLoaded) break;
    } catch (ClassNotFoundException cnfe) {
    }
  }
  if (!(conf.get(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY).contains(
      AccessController.class.getName())
      && accessControllerLoaded && conf.get(
      CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY).contains(
      AccessController.class.getName()))) {
    throw new RuntimeException("AccessController is missing from a system coprocessor list");
  }
  if (conf.getInt(HFile.FORMAT_VERSION_KEY, 2) < HFile.MIN_FORMAT_VERSION_WITH_TAGS) {
    throw new RuntimeException("Post 0.96 security features require HFile version >= 3");
  }

  if (!conf.getBoolean(User.HBASE_SECURITY_AUTHORIZATION_CONF_KEY, false)) {
    throw new RuntimeException("Post 2.0.0 security features require set "
        + User.HBASE_SECURITY_AUTHORIZATION_CONF_KEY + " to true");
  }
}
项目:hbase    文件:TestCoprocessorWhitelistMasterObserver.java   
/**
 * Test a table creation including a coprocessor path
 * which is on the classpath
 * @result Table will be created with the coprocessor
 */
@Test
public void testCreationClasspathCoprocessor() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  // load coprocessor under test
  conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
      CoprocessorWhitelistMasterObserver.class.getName());
  conf.setStrings(CoprocessorWhitelistMasterObserver.CP_COPROCESSOR_WHITELIST_PATHS_KEY,
      new String[]{});
  // set retries low to raise exception quickly
  conf.setInt("hbase.client.retries.number", 5);
  UTIL.startMiniCluster();
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
  HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
  htd.addFamily(hcd);
  htd.addCoprocessor(TestRegionObserver.class.getName());
  Connection connection = ConnectionFactory.createConnection(conf);
  Admin admin = connection.getAdmin();
  LOG.info("Creating Table");
  admin.createTable(htd);
  // ensure table was created and coprocessor is added to table
  LOG.info("Done Creating Table");
  Table t = connection.getTable(TEST_TABLE);
  assertEquals(1, t.getTableDescriptor().getCoprocessors().size());
}
项目:hbase    文件:TestClientClusterStatus.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  Configuration conf = HBaseConfiguration.create();
  conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MyObserver.class.getName());
  UTIL = new HBaseTestingUtility(conf);
  UTIL.startMiniCluster(MASTERS, SLAVES);
  CLUSTER = UTIL.getHBaseCluster();
  CLUSTER.waitForActiveAndReadyMaster();
  ADMIN = UTIL.getAdmin();
  // Kill one region server
  List<RegionServerThread> rsts = CLUSTER.getLiveRegionServerThreads();
  RegionServerThread rst = rsts.get(rsts.size() - 1);
  DEAD = rst.getRegionServer();
  DEAD.stop("Test dead servers status");
  while (rst.isAlive()) {
    Thread.sleep(500);
  }
}
项目:hbase    文件:TestClientClusterMetrics.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  Configuration conf = HBaseConfiguration.create();
  conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MyObserver.class.getName());
  UTIL = new HBaseTestingUtility(conf);
  UTIL.startMiniCluster(MASTERS, SLAVES);
  CLUSTER = UTIL.getHBaseCluster();
  CLUSTER.waitForActiveAndReadyMaster();
  ADMIN = UTIL.getAdmin();
  // Kill one region server
  List<RegionServerThread> rsts = CLUSTER.getLiveRegionServerThreads();
  RegionServerThread rst = rsts.get(rsts.size() - 1);
  DEAD = rst.getRegionServer();
  DEAD.stop("Test dead servers metrics");
  while (rst.isAlive()) {
    Thread.sleep(500);
  }
}
项目:hbase    文件:TestMultiParallel.java   
@BeforeClass public static void beforeClass() throws Exception {
  // Uncomment the following lines if more verbosity is needed for
  // debugging (see HBASE-12285 for details).
  //((Log4JLogger)RpcServer.LOG).getLogger().setLevel(Level.ALL);
  //((Log4JLogger)RpcClient.LOG).getLogger().setLevel(Level.ALL);
  //((Log4JLogger)ScannerCallable.LOG).getLogger().setLevel(Level.ALL);
  UTIL.getConfiguration().set(HConstants.RPC_CODEC_CONF_KEY,
      KeyValueCodec.class.getCanonicalName());
  UTIL.getConfiguration().setBoolean(LoadBalancer.TABLES_ON_MASTER, true);
  // We used to ask for system tables on Master exclusively but not needed by test and doesn't
  // work anyways -- so commented out.
  // UTIL.getConfiguration().setBoolean(LoadBalancer.SYSTEM_TABLES_ON_MASTER, true);
  UTIL.getConfiguration()
      .set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MyMasterObserver.class.getName());
  UTIL.startMiniCluster(slaves);
  Table t = UTIL.createMultiRegionTable(TEST_TABLE, Bytes.toBytes(FAMILY));
  UTIL.waitTableEnabled(TEST_TABLE);
  t.close();
  CONNECTION = ConnectionFactory.createConnection(UTIL.getConfiguration());
  assertTrue(MyMasterObserver.start.get());
}
项目:hbase    文件:TestSnapshotWithAcl.java   
@BeforeClass
public static void setupBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  // Enable security
  enableSecurity(conf);
  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();
  TEST_UTIL.waitUntilAllRegionsAssigned(AccessControlLists.ACL_TABLE_NAME);
  MasterCoprocessorHost cpHost =
      TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
  cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);

  USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
  USER_RW = User.createUserForTesting(conf, "rwuser", new String[0]);
  USER_RO = User.createUserForTesting(conf, "rouser", new String[0]);
  USER_NONE = User.createUserForTesting(conf, "usernone", new String[0]);
}
项目:hbase    文件:TestAvoidCellReferencesIntoShippedBlocks.java   
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  ROWS[0] = ROW;
  ROWS[1] = ROW1;
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
    MultiRowMutationEndpoint.class.getName());
  conf.setBoolean("hbase.table.sanity.checks", true); // enable for below
                                                      // tests
  conf.setInt("hbase.regionserver.handler.count", 20);
  conf.setInt("hbase.bucketcache.size", 400);
  conf.setStrings(HConstants.BUCKET_CACHE_IOENGINE_KEY, "offheap");
  conf.setInt("hbase.hstore.compactionThreshold", 7);
  conf.setFloat("hfile.block.cache.size", 0.2f);
  conf.setFloat("hbase.regionserver.global.memstore.size", 0.1f);
  conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 0);// do not retry
  conf.setInt(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, 500000);
  FAMILIES_1[0] = FAMILY;
  TEST_UTIL.startMiniCluster(SLAVES);
  compactReadLatch = new CountDownLatch(1);
}
项目:hbase    文件:TestFromClientSide.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Uncomment the following lines if more verbosity is needed for
  // debugging (see HBASE-12285 for details).
  //((Log4JLogger)RpcServer.LOG).getLogger().setLevel(Level.ALL);
  //((Log4JLogger)RpcClient.LOG).getLogger().setLevel(Level.ALL);
  //((Log4JLogger)ScannerCallable.LOG).getLogger().setLevel(Level.ALL);
  // make sure that we do not get the same ts twice, see HBASE-19731 for more details.
  EnvironmentEdgeManager.injectEdge(new NonRepeatedEnvironmentEdge());
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
      MultiRowMutationEndpoint.class.getName());
  conf.setBoolean("hbase.table.sanity.checks", true); // enable for below tests
  conf.setLong(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, 6000000);
  // We need more than one region server in this test
  TEST_UTIL.startMiniCluster(SLAVES);
}
项目:hbase    文件:TestClientOperationInterrupt.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = HBaseConfiguration.create();
  conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      TestCoprocessor.class.getName());
  util = new HBaseTestingUtility(conf);
  util.startMiniCluster();

  Admin admin = util.getAdmin();
  if (admin.tableExists(tableName)) {
    if (admin.isTableEnabled(tableName)) {
      admin.disableTable(tableName);
    }
    admin.deleteTable(tableName);
  }
  Table ht = util.createTable(tableName, new byte[][]{dummy, test});

  Put p = new Put(row1);
  p.addColumn(dummy, dummy, dummy);
  ht.put(p);
}