/** * Starts up mini hbase cluster using default options. * Default options can be found in {@link StartMiniClusterOption.Builder}. * @see #startMiniHBaseCluster(StartMiniClusterOption) * @see #shutdownMiniHBaseCluster() */ public MiniHBaseCluster startMiniHBaseCluster() throws IOException, InterruptedException { return startMiniHBaseCluster(StartMiniClusterOption.builder().build()); }
public StartMiniClusterOption build() { if (dataNodeHosts != null && dataNodeHosts.length != 0) { numDataNodes = dataNodeHosts.length; } return new StartMiniClusterOption(numMasters, masterClass, numRegionServers, rsPorts, rsClass, numDataNodes, dataNodeHosts, numZkServers, createRootDir, createWALDir); }
/** * Start up a mini cluster of hbase, optionally dfs and zookeeper if needed. * It modifies Configuration. It homes the cluster data directory under a random * subdirectory in a directory under System property test.build.data, to be cleaned up on exit. * @see #shutdownMiniDFSCluster() */ public MiniHBaseCluster startMiniCluster(StartMiniClusterOption option) throws Exception { LOG.info("Starting up minicluster with option: {}", option); // If we already put up a cluster, fail. if (miniClusterRunning) { throw new IllegalStateException("A mini-cluster is already running"); } miniClusterRunning = true; setupClusterTestDir(); System.setProperty(TEST_DIRECTORY_KEY, this.clusterTestDir.getPath()); // Bring up mini dfs cluster. This spews a bunch of warnings about missing // scheme. Complaints are 'Scheme is undefined for build/test/data/dfs/name1'. if (dfsCluster == null) { LOG.info("STARTING DFS"); dfsCluster = startMiniDFSCluster(option.getNumDataNodes(), option.getDataNodeHosts()); } else { LOG.info("NOT STARTING DFS"); } // Start up a zk cluster. if (getZkCluster() == null) { startMiniZKCluster(option.getNumZkServers()); } // Start the MiniHBaseCluster return startMiniHBaseCluster(option); }
throws IOException, InterruptedException { createRootDir(option.isCreateRootDir()); if (option.isCreateWALDir()) { createWALRootDir(); conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, option.getNumRegionServers()); conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, option.getNumRegionServers()); TraceUtil.initTracer(c); this.hbaseCluster = new MiniHBaseCluster(c, option.getNumMasters(), option.getNumRegionServers(), option.getRsPorts(), option.getMasterClass(), option.getRsClass());
/** * Start up a minicluster of hbase, dfs and zookeeper all using default options. * Option default value can be found in {@link StartMiniClusterOption.Builder}. * @see #startMiniCluster(StartMiniClusterOption option) * @see #shutdownMiniDFSCluster() */ public MiniHBaseCluster startMiniCluster() throws Exception { return startMiniCluster(StartMiniClusterOption.builder().build()); }
/** * Start up a minicluster of hbase, dfs, and zookeeper where WAL's walDir is created separately. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param createWALDir Whether to create a new WAL directory. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(boolean createWALDir) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .createWALDir(createWALDir).build(); return startMiniCluster(option); }
@Before public void setup() throws Exception { testUtil = new HBaseTestingUtility(); conf = testUtil.getConfiguration(); conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, StopBlockingRegionObserver.class.getName()); conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, StopBlockingRegionObserver.class.getName()); // make sure we have multiple blocks so that the client does not prefetch all block locations conf.set("dfs.blocksize", Long.toString(100 * 1024)); // prefetch the first block conf.set(DFSConfigKeys.DFS_CLIENT_READ_PREFETCH_SIZE_KEY, Long.toString(100 * 1024)); conf.set(HConstants.REGION_IMPL, ErrorThrowingHRegion.class.getName()); testUtil.startMiniZKCluster(); dfsCluster = testUtil.startMiniDFSCluster(2); StartMiniClusterOption option = StartMiniClusterOption.builder().numRegionServers(2).build(); cluster = testUtil.startMiniHBaseCluster(option); }
@BeforeClass public static void setUpClass() throws Exception { TESTING_UTIL.getConfiguration().setLong(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, 500); TESTING_UTIL.getConfiguration().setLong(HConstants.HBASE_CLIENT_META_OPERATION_TIMEOUT, 500); TESTING_UTIL.getConfiguration().setLong(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, 500); TESTING_UTIL.getConfiguration().setLong(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1); // Set RegionServer class and use default values for other options. StartMiniClusterOption option = StartMiniClusterOption.builder() .rsClass(DelayedRegionServer.class).build(); TESTING_UTIL.startMiniCluster(option); }
/** * Starts up mini hbase cluster. * Usually you won't want this. You'll usually want {@link #startMiniCluster()}. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numRegionServers Number of region servers. * @return The mini HBase cluster created. * @see #shutdownMiniHBaseCluster() * @deprecated Use {@link #startMiniHBaseCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniHBaseCluster(int numMasters, int numRegionServers) throws IOException, InterruptedException { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numRegionServers).build(); return startMiniHBaseCluster(option); }
@BeforeClass public static void setUpBeforeClass() throws Exception { final int DEFAULT_BLOCK_SIZE = 1024 * 1024; TEST_UTIL.getConfiguration().setLong("dfs.blocksize", DEFAULT_BLOCK_SIZE); TEST_UTIL.getConfiguration().setInt("dfs.replication", 1); TEST_UTIL.getConfiguration().setLong("hbase.hregion.max.filesize", 322122547200L); String[] dataNodeHosts = new String[] {"host1", "host2", "host3"}; int regionServersCount = 3; StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(regionServersCount).dataNodeHosts(dataNodeHosts).build(); TEST_UTIL.startMiniCluster(option); }
TEST_UTIL.getConfiguration().setBoolean(HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true); try { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build(); TEST_UTIL.startMiniCluster(option);
@BeforeClass public static void setupTest() throws Exception { // Set createWALDir to true and use default values for other options. UTIL.startMiniCluster(StartMiniClusterOption.builder().createWALDir(true).build()); }
/** * Start up a minicluster of hbase, dfs and zookeeper clusters with given slave node number. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numSlaves slave node number, for both HBase region server and HDFS data node. * @see #startMiniCluster(StartMiniClusterOption option) * @see #shutdownMiniDFSCluster() */ public MiniHBaseCluster startMiniCluster(int numSlaves) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(numSlaves).numDataNodes(numSlaves).build(); return startMiniCluster(option); }
@BeforeClass public static void setup() throws Exception { // Set master number and use default values for other options. StartMiniClusterOption option = StartMiniClusterOption.builder().numMasters(2).build(); TEST_UTIL.startMiniCluster(option); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numSlaves Slave node number, for both HBase region server and HDFS data node. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numSlaves).numDataNodes(numSlaves).build(); return startMiniCluster(option); }
@BeforeClass public static void setUp() throws Exception { Configuration conf = UTIL.getConfiguration(); // Will schedule a abort timeout task after SLEEP_TIME_WHEN_CLOSE_REGION ms conf.setLong(HRegionServer.ABORT_TIMEOUT, SLEEP_TIME_WHEN_CLOSE_REGION); conf.set(HRegionServer.ABORT_TIMEOUT_TASK, TestAbortTimeoutTask.class.getName()); StartMiniClusterOption option = StartMiniClusterOption.builder().numRegionServers(2).build(); UTIL.startMiniCluster(option); TableDescriptor td = TableDescriptorBuilder.newBuilder(TABLE_NAME) .setCoprocessor(SleepWhenCloseCoprocessor.class.getName()) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(CF).build()).build(); UTIL.getAdmin().createTable(td, Bytes.toBytes("0"), Bytes.toBytes("9"), REGIONS_NUM); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numSlaves Slave node number, for both HBase region server and HDFS data node. * @param createRootDir Whether to create a new root or data directory path. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numSlaves, boolean createRootDir) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(numSlaves).numDataNodes(numSlaves).createRootDir(createRootDir).build(); return startMiniCluster(option); }
@BeforeClass public static void startCluster() throws Exception { LOG.info("Starting cluster"); // Set master class and use default values for other options. StartMiniClusterOption option = StartMiniClusterOption.builder().masterClass(MyMaster.class) .rsClass(MyRegionServer.class).build(); TEST_UTIL.startMiniCluster(option); cluster = TEST_UTIL.getHBaseCluster(); LOG.info("Waiting for active/ready master"); cluster.waitForActiveAndReadyMaster(); master = cluster.getMaster(); }
private void startCluster(int numRS) throws Exception { SplitLogCounters.resetCounters(); LOG.info("Starting cluster"); conf.setLong("hbase.splitlog.max.resubmit", 0); // Make the failure test faster conf.setInt("zookeeper.recovery.retry", 0); conf.setInt(HConstants.REGIONSERVER_INFO_PORT, -1); conf.setFloat(HConstants.LOAD_BALANCER_SLOP_KEY, (float) 100.0); // no load balancing conf.setInt(HBASE_SPLIT_WAL_MAX_SPLITTER, 3); conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10); conf.set("hbase.wal.provider", getWalProvider()); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(NUM_MASTERS).numRegionServers(numRS).build(); TEST_UTIL.startMiniHBaseCluster(option); cluster = TEST_UTIL.getHBaseCluster(); LOG.info("Waiting for active/ready master"); cluster.waitForActiveAndReadyMaster(); master = cluster.getMaster(); TEST_UTIL.waitFor(120000, 200, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return cluster.getLiveRegionServerThreads().size() >= numRS; } }); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numRegionServers Number of region servers. * @param numDataNodes Number of datanodes. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numMasters, int numRegionServers, int numDataNodes) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numRegionServers).numDataNodes(numDataNodes) .build(); return startMiniCluster(option); }