void MiniCluster::Setup()

in src/hbase/test-util/mini-cluster.cc [106:178]


void MiniCluster::Setup() {
  lock_guard<mutex> lock(lock_);
  if (inited_) return;
  if (!env_) {
    env_ = CreateVM(&jvm_);
    CHECK_NOTNULL(env_);
  }
  testing_util_class_ = FindClassAndGetGlobalRef("org/apache/hadoop/hbase/HBaseTestingUtility");
  jmethodID mid = env_->GetMethodID(testing_util_class_, "<init>","()V");
  CHECK_NOTNULL(mid);
  jobject  local_htu = env_->NewObject(testing_util_class_, mid);
  if (!local_htu) {
    LOG(FATAL) << "Couldn't invoke method createLocalHTU in HBaseTestingUtility";
  }
  htu_ = env_->NewGlobalRef(local_htu);
  env_->DeleteLocalRef(local_htu);
  get_conn_mid_ = env_->GetMethodID(testing_util_class_, "getConnection",
      "()Lorg/apache/hadoop/hbase/client/Connection;");
  jclass conn_class = env_->FindClass("org/apache/hadoop/hbase/client/Connection");
  get_admin_mid_ =
      env_->GetMethodID(conn_class, "getAdmin", "()Lorg/apache/hadoop/hbase/client/Admin;");
  get_table_mid_ = env_->GetMethodID(conn_class, "getTable",
      "(Lorg/apache/hadoop/hbase/TableName;)Lorg/apache/hadoop/hbase/client/Table;");
  if (!get_table_mid_) {
    LOG(FATAL) << "Couldn't find getConnection";
  }
  jclass adminClass = env_->FindClass("org/apache/hadoop/hbase/client/Admin");
  move_mid_ = env_->GetMethodID(adminClass, "move", "([B[B)V");
  if (move_mid_ == nullptr) {
    LOG(FATAL) << "Couldn't find move";
  }
  create_table_mid_ = env_->GetMethodID(testing_util_class_, "createTable",
      "(Lorg/apache/hadoop/hbase/TableName;Ljava/lang/String;)Lorg/apache/hadoop/hbase/client/Table;");
  create_table_families_mid_ = env_->GetMethodID(testing_util_class_, "createTable",
      "(Lorg/apache/hadoop/hbase/TableName;[[B)Lorg/apache/hadoop/hbase/client/Table;");
  create_table_with_split_mid_ = env_->GetMethodID(testing_util_class_, "createTable",
      "(Lorg/apache/hadoop/hbase/TableName;[[B[[B)Lorg/apache/hadoop/hbase/client/Table;");
  if (create_table_with_split_mid_ == nullptr) {
    LOG(FATAL) << "Couldn't find method createTable with split";
  }
  table_name_class_ = FindClassAndGetGlobalRef("org/apache/hadoop/hbase/TableName");
  tbl_name_value_of_mid_ = env_->GetStaticMethodID(
      table_name_class_, "valueOf", "(Ljava/lang/String;)Lorg/apache/hadoop/hbase/TableName;");
  if (tbl_name_value_of_mid_ == nullptr) {
    LOG(FATAL) << "Couldn't find method valueOf in TableName";
  }
  jclass hbaseMiniClusterClass = env_->FindClass("org/apache/hadoop/hbase/MiniHBaseCluster");
  stop_rs_mid_ =env_->GetMethodID(hbaseMiniClusterClass, "stopRegionServer",
      "(I)Lorg/apache/hadoop/hbase/util/JVMClusterUtil$RegionServerThread;");
  get_conf_mid_ = env_->GetMethodID(hbaseMiniClusterClass, "getConfiguration",
      "()Lorg/apache/hadoop/conf/Configuration;");
  conf_class_ = FindClassAndGetGlobalRef("org/apache/hadoop/conf/Configuration");
  set_conf_mid_ = env_->GetMethodID(conf_class_, "set", "(Ljava/lang/String;Ljava/lang/String;)V");
  if (set_conf_mid_ == nullptr) {
    LOG(FATAL) << "Couldn't find method getConf in MiniHBaseCluster";
  }
  conf_get_mid_ = env_->GetMethodID(conf_class_, "get", "(Ljava/lang/String;)Ljava/lang/String;");
  jclass tableClass = env_->FindClass("org/apache/hadoop/hbase/client/Table");
  put_mid_ = env_->GetMethodID(tableClass, "put", "(Lorg/apache/hadoop/hbase/client/Put;)V");
  jclass connFactoryClass = env_->FindClass("org/apache/hadoop/hbase/client/ConnectionFactory");
  create_conn_mid_ = env_->GetStaticMethodID(connFactoryClass, "createConnection",
      "()Lorg/apache/hadoop/hbase/client/Connection;");
  if (create_conn_mid_ == nullptr) {
    LOG(FATAL) << "Couldn't find createConnection";
  }
  put_class_ = FindClassAndGetGlobalRef("org/apache/hadoop/hbase/client/Put");
  put_ctor_ = env_->GetMethodID(put_class_, "<init>", "([B)V");
  add_col_mid_ = env_->GetMethodID(put_class_, "addColumn", "([B[B[B)Lorg/apache/hadoop/hbase/client/Put;");
  if (add_col_mid_ == nullptr) {
    LOG(FATAL) << "Couldn't find method addColumn";
  }
  inited_ = true;
}