Java Code Examples for org.apache.hadoop.hbase.MiniHBaseCluster#getConf()

The following examples show how to use org.apache.hadoop.hbase.MiniHBaseCluster#getConf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBaseMiniCluster.java    From yuzhouwan with Apache License 2.0 6 votes vote down vote up
private HBaseTestingUtility hbaseOperation() throws Exception {

        HBaseTestingUtility hbaseTestingUtility = new HBaseTestingUtility();
        /**
         * # fsOwner's name is Benedict Jin, will throw exception: Illegal character in path at index 42
         * hbaseTestingUtility.getTestFileSystem().setOwner(new Path(BASE_PATH.concat("/owner")), "Benedict Jin", "supergroup");
         */
        MiniHBaseCluster hbaseCluster = hbaseTestingUtility.startMiniCluster();

        hbaseTestingUtility.createTable(Bytes.toBytes(TABLE_NAME), Bytes.toBytes("context"));
        hbaseTestingUtility.deleteTable(Bytes.toBytes(TABLE_NAME));

        Configuration config = hbaseCluster.getConf();
        Connection conn = ConnectionFactory.createConnection(config);
        HBaseAdmin hbaseAdmin = new HBaseAdmin(conn);

        HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLE_NAME));
        hbaseAdmin.createTable(desc);
        return hbaseTestingUtility;
    }
 
Example 2
Source File: HBaseMiniclusterHelper.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private static void startupMiniClusterAndImportData() throws Exception {

        logger.info("Going to start mini cluster.");

        if (existInClassPath(iiEndpointClassName)) {
            HBaseMiniclusterHelper.UTIL.getConfiguration().setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, iiEndpointClassName);
        }

        //https://issues.apache.org/jira/browse/HBASE-11711
        UTIL.getConfiguration().setInt("hbase.master.info.port", -1);//avoid port clobbering

        MiniHBaseCluster hbaseCluster = UTIL.startMiniCluster();

        Configuration config = hbaseCluster.getConf();
        String host = config.get(HConstants.ZOOKEEPER_QUORUM);
        String port = config.get(HConstants.ZOOKEEPER_CLIENT_PORT);
        String parent = config.get(HConstants.ZOOKEEPER_ZNODE_PARENT);

        // see in: https://hbase.apache.org/book.html#trouble.rs.runtime.zkexpired
        config.set("zookeeper.session.timeout", "1200000");
        config.set("hbase.zookeeper.property.tickTime", "6000");
        // reduce rpc retry
        config.set(HConstants.HBASE_CLIENT_PAUSE, "3000");
        config.set(HConstants.HBASE_CLIENT_RETRIES_NUMBER, "1");
        config.set(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, "60000");

        hbaseconnectionUrl = "hbase:" + host + ":" + port + ":" + parent;
        updateKylinConfigWithMinicluster();

        UTIL.startMiniMapReduceCluster();

        // create the metadata htables;
        @SuppressWarnings("unused")
        HBaseResourceStore store = new HBaseResourceStore(KylinConfig.getInstanceFromEnv());

        // import the table content
        HbaseImporter.importHBaseData(hbaseTarLocation, UTIL.getConfiguration());

    }
 
Example 3
Source File: MiniClusterTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        File miniclusterFolder = new File(AbstractKylinTestCase.MINICLUSTER_TEST_DATA);
        System.out.println("----" + miniclusterFolder.getAbsolutePath());

        //save the dfs data to minicluster folder
        System.setProperty("test.build.data", miniclusterFolder.getAbsolutePath());

        MiniHBaseCluster hbCluster = testUtil.startMiniCluster(1);
        testUtil.startMiniMapReduceCluster();
        System.out.println("Minicluster started.");

        Configuration conf = hbCluster.getConf();
        String host = conf.get(HConstants.ZOOKEEPER_QUORUM);
        String port = conf.get(HConstants.ZOOKEEPER_CLIENT_PORT);
        String parent = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT);

        // reduce rpc retry
        conf.set(HConstants.HBASE_CLIENT_PAUSE, "3000");
        conf.set(HConstants.HBASE_CLIENT_RETRIES_NUMBER, "5");
        conf.set(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, "60000");

        String connectionUrl = "hbase:" + host + ":" + port + ":" + parent;

        System.out.println("hbase connection url:" + connectionUrl);

        testUtil.getDFSCluster().getFileSystem();
        testUtil.shutdownMiniMapReduceCluster();
        testUtil.shutdownMiniCluster();
    }
 
Example 4
Source File: HBaseService.java    From kite with Apache License 2.0 5 votes vote down vote up
/**
 * Wait for the hbase cluster to start up and come online, and then return.
 * 
 * @param hbaseCluster
 *          The hbase cluster to wait for.
 * @throws IOException
 */
private static void waitForHBaseToComeOnline(MiniHBaseCluster hbaseCluster)
    throws IOException, InterruptedException {
  // Wait for the master to be initialized. This is required because even
  // before it's initialized, the regionserver can come online and the meta
  // table can be scannable. If the cluster is quickly shut down after all of
  // this before the master is initialized, it can cause the shutdown to hang
  // indefinitely as initialization tasks will block forever.
  //
  // Unfortunately, no method available to wait for master to come online like
  // regionservers, so we use a while loop with a sleep so we don't hammer the
  // isInitialized method.
  while (!hbaseCluster.getMaster().isInitialized()) {
    Thread.sleep(1000);
  }
  // Now wait for the regionserver to come online.
  hbaseCluster.getRegionServer(0).waitForServerOnline();
  // Don't leave here till we've done a successful scan of the hbase:meta
  // This validates that not only is the regionserver up, but that the
  // meta region is online so there are no race conditions where operations
  // requiring the meta region might run before it's available. Otherwise,
  // operations are susceptible to region not online errors.
  HTable t = new HTable(hbaseCluster.getConf(), HBASE_META_TABLE);
  ResultScanner s = t.getScanner(new Scan());
  while (s.next() != null) {
    continue;
  }
  s.close();
  t.close();
}