Search in sources :

Example 16 with StartTestingClusterOption

use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.

the class TestJoinedScanners method setUpBeforeClass.

@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;
    StartTestingClusterOption option = StartTestingClusterOption.builder().numRegionServers(regionServersCount).dataNodeHosts(dataNodeHosts).build();
    TEST_UTIL.startMiniCluster(option);
}
Also used : StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) BeforeClass(org.junit.BeforeClass)

Example 17 with StartTestingClusterOption

use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.

the class MetaWithReplicasTestBase method startCluster.

protected static void startCluster() throws Exception {
    TEST_UTIL.getConfiguration().setInt("zookeeper.session.timeout", 30000);
    TEST_UTIL.getConfiguration().setInt(StorefileRefresherChore.REGIONSERVER_STOREFILE_REFRESH_PERIOD, 1000);
    StartTestingClusterOption option = StartTestingClusterOption.builder().numAlwaysStandByMasters(1).numMasters(1).numRegionServers(REGIONSERVERS_COUNT).build();
    TEST_UTIL.startMiniCluster(option);
    Admin admin = TEST_UTIL.getAdmin();
    HBaseTestingUtil.setReplicas(admin, TableName.META_TABLE_NAME, 3);
    AssignmentManager am = TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
    Set<ServerName> sns = new HashSet<ServerName>();
    ServerName hbaseMetaServerName = am.getRegionStates().getRegionStateNode(RegionInfoBuilder.FIRST_META_REGIONINFO).getRegionLocation();
    LOG.info("HBASE:META DEPLOY: on " + hbaseMetaServerName);
    sns.add(hbaseMetaServerName);
    for (int replicaId = 1; replicaId < 3; replicaId++) {
        RegionInfo h = RegionReplicaUtil.getRegionInfoForReplica(RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId);
        AssignmentTestingUtil.waitForAssignment(am, h);
        ServerName sn = am.getRegionStates().getRegionServerOfRegion(h);
        assertNotNull(sn);
        LOG.info("HBASE:META DEPLOY: " + h.getRegionNameAsString() + " on " + sn);
        sns.add(sn);
    }
    // to fail ... sometimes.
    if (sns.size() == 1) {
        int count = TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size();
        assertTrue("count=" + count, count == REGIONSERVERS_COUNT);
        LOG.warn("All hbase:meta replicas are on the one server; moving hbase:meta: " + sns);
        int metaServerIndex = TEST_UTIL.getHBaseCluster().getServerWithMeta();
        int newServerIndex = metaServerIndex;
        while (newServerIndex == metaServerIndex) {
            newServerIndex = (newServerIndex + 1) % REGIONSERVERS_COUNT;
        }
        assertNotEquals(metaServerIndex, newServerIndex);
        ServerName destinationServerName = TEST_UTIL.getHBaseCluster().getRegionServer(newServerIndex).getServerName();
        ServerName metaServerName = TEST_UTIL.getHBaseCluster().getRegionServer(metaServerIndex).getServerName();
        assertNotEquals(destinationServerName, metaServerName);
        TEST_UTIL.getAdmin().move(RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes(), destinationServerName);
    }
    // Disable the balancer
    LoadBalancerTracker l = new LoadBalancerTracker(TEST_UTIL.getZooKeeperWatcher(), new Abortable() {

        AtomicBoolean aborted = new AtomicBoolean(false);

        @Override
        public boolean isAborted() {
            return aborted.get();
        }

        @Override
        public void abort(String why, Throwable e) {
            aborted.set(true);
        }
    });
    l.setBalancerOn(false);
    LOG.debug("All meta replicas assigned");
}
Also used : AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LoadBalancerTracker(org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker) Abortable(org.apache.hadoop.hbase.Abortable) ServerName(org.apache.hadoop.hbase.ServerName) StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) HashSet(java.util.HashSet)

Example 18 with StartTestingClusterOption

use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.

the class TestRegionMoveAndAbandon method setup.

@Before
public void setup() throws Exception {
    UTIL = new HBaseTestingUtil();
    zkCluster = UTIL.startMiniZKCluster();
    StartTestingClusterOption option = StartTestingClusterOption.builder().numRegionServers(2).build();
    cluster = UTIL.startMiniHBaseCluster(option);
    rs1 = cluster.getRegionServer(0);
    rs2 = cluster.getRegionServer(1);
    assertEquals(2, cluster.getRegionServerThreads().size());
    tableName = TableName.valueOf(name.getMethodName());
    UTIL.createTable(tableName, Bytes.toBytes("cf"));
    UTIL.waitTableAvailable(tableName, 30_000);
    regionInfo = Iterables.getOnlyElement(cluster.getRegions(tableName)).getRegionInfo();
}
Also used : HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) Before(org.junit.Before)

Example 19 with StartTestingClusterOption

use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.

the class TestRegionSplitAndSeparateChildren method setupCluster.

@BeforeClass
public static void setupCluster() throws Exception {
    setupConf(UTIL.getConfiguration());
    StartTestingClusterOption option = StartTestingClusterOption.builder().numMasters(1).numRegionServers(3).numDataNodes(3).build();
    UTIL.startMiniCluster(option);
}
Also used : StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) BeforeClass(org.junit.BeforeClass)

Example 20 with StartTestingClusterOption

use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.

the class TestRegionMergeTransactionOnCluster method beforeAllTests.

@BeforeClass
public static void beforeAllTests() throws Exception {
    // Start a cluster
    StartTestingClusterOption option = StartTestingClusterOption.builder().masterClass(MyMaster.class).numRegionServers(NB_SERVERS).numDataNodes(NB_SERVERS).build();
    TEST_UTIL.startMiniCluster(option);
    SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    MASTER = cluster.getMaster();
    MASTER.balanceSwitch(false);
    ADMIN = TEST_UTIL.getConnection().getAdmin();
}
Also used : SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) BeforeClass(org.junit.BeforeClass)

Aggregations

StartTestingClusterOption (org.apache.hadoop.hbase.StartTestingClusterOption)42 BeforeClass (org.junit.BeforeClass)21 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)13 Test (org.junit.Test)13 Configuration (org.apache.hadoop.conf.Configuration)10 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)8 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)5 TableName (org.apache.hadoop.hbase.TableName)5 Table (org.apache.hadoop.hbase.client.Table)5 MasterThread (org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread)5 ServerName (org.apache.hadoop.hbase.ServerName)4 RegionLocator (org.apache.hadoop.hbase.client.RegionLocator)4 Path (org.apache.hadoop.fs.Path)3 ClusterMetrics (org.apache.hadoop.hbase.ClusterMetrics)3 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)3 Before (org.junit.Before)3 InetAddress (java.net.InetAddress)2 NetworkInterface (java.net.NetworkInterface)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2