Search in sources :

Example 61 with HBaseTestingUtil

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

the class TestFSUtils method setUp.

@Before
public void setUp() throws IOException {
    htu = new HBaseTestingUtil();
    fs = htu.getTestFileSystem();
    conf = htu.getConfiguration();
}
Also used : HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Before(org.junit.Before)

Example 62 with HBaseTestingUtil

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

the class TestMajorCompactor method setUp.

@Before
public void setUp() throws Exception {
    utility = new HBaseTestingUtil();
    utility.getConfiguration().setInt("hbase.hfile.compaction.discharger.interval", 10);
    utility.startMiniCluster();
}
Also used : HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Before(org.junit.Before)

Example 63 with HBaseTestingUtil

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

the class FromClientSideBase method initialize.

protected static final void initialize(Class<?> registryImpl, int numHedgedReqs, Class<?>... cps) throws Exception {
    // at the end of every parameterized run.
    if (isSameParameterizedCluster(registryImpl, numHedgedReqs)) {
        return;
    }
    // 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());
    if (TEST_UTIL != null) {
        // We reached end of a parameterized run, clean up.
        TEST_UTIL.shutdownMiniCluster();
    }
    TEST_UTIL = new HBaseTestingUtil();
    Configuration conf = TEST_UTIL.getConfiguration();
    conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, Arrays.stream(cps).map(Class::getName).toArray(String[]::new));
    // enable for below tests
    conf.setBoolean(TableDescriptorChecker.TABLE_SANITY_CHECKS, true);
    conf.setClass(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, registryImpl, ConnectionRegistry.class);
    Preconditions.checkArgument(numHedgedReqs > 0);
    conf.setInt(MasterRegistry.MASTER_REGISTRY_HEDGED_REQS_FANOUT_KEY, numHedgedReqs);
    StartTestingClusterOption.Builder builder = StartTestingClusterOption.builder();
    // Multiple masters needed only when hedged reads for master registry are enabled.
    builder.numMasters(numHedgedReqs > 1 ? 3 : 1).numRegionServers(SLAVES);
    TEST_UTIL.startMiniCluster(builder.build());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) NonRepeatedEnvironmentEdge(org.apache.hadoop.hbase.util.NonRepeatedEnvironmentEdge) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption)

Example 64 with HBaseTestingUtil

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

the class RegionReplicaTestHelper method moveRegion.

/**
 * Return the new location.
 */
static ServerName moveRegion(HBaseTestingUtil util, HRegionLocation currentLoc) throws Exception {
    ServerName serverName = currentLoc.getServerName();
    RegionInfo regionInfo = currentLoc.getRegion();
    TableName tableName = regionInfo.getTable();
    int replicaId = regionInfo.getReplicaId();
    ServerName newServerName = util.getHBaseCluster().getRegionServerThreads().stream().map(t -> t.getRegionServer().getServerName()).filter(sn -> !sn.equals(serverName)).findAny().get();
    util.getAdmin().move(regionInfo.getEncodedNameAsBytes(), newServerName);
    util.waitFor(30000, new ExplainingPredicate<Exception>() {

        @Override
        public boolean evaluate() throws Exception {
            Optional<ServerName> newServerName = getRSCarryingReplica(util, tableName, replicaId);
            return newServerName.isPresent() && !newServerName.get().equals(serverName);
        }

        @Override
        public String explainFailure() throws Exception {
            return regionInfo.getRegionNameAsString() + " is still on " + serverName;
        }
    });
    return newServerName;
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Waiter(org.apache.hadoop.hbase.Waiter) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Assert.assertNotNull(org.junit.Assert.assertNotNull) RegionLocations(org.apache.hadoop.hbase.RegionLocations) IOException(java.io.IOException) ArrayList(java.util.ArrayList) List(java.util.List) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) Region(org.apache.hadoop.hbase.regionserver.Region) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) Configuration(org.apache.hadoop.conf.Configuration) Optional(java.util.Optional) Assert.fail(org.junit.Assert.fail) ExplainingPredicate(org.apache.hadoop.hbase.Waiter.ExplainingPredicate) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) Assert.assertEquals(org.junit.Assert.assertEquals) ServerName(org.apache.hadoop.hbase.ServerName) TableName(org.apache.hadoop.hbase.TableName) Optional(java.util.Optional) ServerName(org.apache.hadoop.hbase.ServerName) IOException(java.io.IOException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException)

Example 65 with HBaseTestingUtil

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

the class TestClientOperationInterrupt method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    conf = HBaseConfiguration.create();
    conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, TestCoprocessor.class.getName());
    util = new HBaseTestingUtil(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);
}
Also used : HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) BeforeClass(org.junit.BeforeClass)

Aggregations

HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)144 Configuration (org.apache.hadoop.conf.Configuration)42 Test (org.junit.Test)42 Before (org.junit.Before)41 BeforeClass (org.junit.BeforeClass)37 Path (org.apache.hadoop.fs.Path)24 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)22 Admin (org.apache.hadoop.hbase.client.Admin)22 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)15 StartTestingClusterOption (org.apache.hadoop.hbase.StartTestingClusterOption)14 FileSystem (org.apache.hadoop.fs.FileSystem)13 MiniZooKeeperCluster (org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster)12 TableName (org.apache.hadoop.hbase.TableName)10 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)10 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)9 ServerName (org.apache.hadoop.hbase.ServerName)8 Table (org.apache.hadoop.hbase.client.Table)8 ZKWatcher (org.apache.hadoop.hbase.zookeeper.ZKWatcher)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7