Search in sources :

Example 26 with HBaseTestingUtil

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

the class TestCompactionArchiveIOException method setup.

@Before
public void setup() throws Exception {
    testUtil = new HBaseTestingUtil();
    testUtil.startMiniDFSCluster(1);
    testDir = testUtil.getDataTestDirOnTestFS();
    CommonFSUtils.setRootDir(testUtil.getConfiguration(), testDir);
}
Also used : HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Before(org.junit.Before)

Example 27 with HBaseTestingUtil

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

the class TestGlobalReplicationThrottler method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    conf1 = HBaseConfiguration.create();
    conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
    conf1.setLong("replication.source.sleepforretries", 100);
    // Each WAL is about 120 bytes
    conf1.setInt(HConstants.REPLICATION_SOURCE_TOTAL_BUFFER_KEY, REPLICATION_SOURCE_QUOTA);
    conf1.setLong("replication.source.per.peer.node.bandwidth", 100L);
    utility1 = new HBaseTestingUtil(conf1);
    utility1.startMiniZKCluster();
    MiniZooKeeperCluster miniZK = utility1.getZkCluster();
    new ZKWatcher(conf1, "cluster1", null, true);
    conf2 = new Configuration(conf1);
    conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
    utility2 = new HBaseTestingUtil(conf2);
    utility2.setZkCluster(miniZK);
    new ZKWatcher(conf2, "cluster2", null, true);
    ReplicationPeerConfig rpc = ReplicationPeerConfig.newBuilder().setClusterKey(utility2.getClusterKey()).build();
    utility1.startMiniCluster();
    utility2.startMiniCluster();
    try (Connection connection = ConnectionFactory.createConnection(utility1.getConfiguration());
        Admin admin1 = connection.getAdmin()) {
        admin1.addReplicationPeer("peer1", rpc);
        admin1.addReplicationPeer("peer2", rpc);
        admin1.addReplicationPeer("peer3", rpc);
        numOfPeer = admin1.listReplicationPeers().size();
    }
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) Connection(org.apache.hadoop.hbase.client.Connection) MiniZooKeeperCluster(org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Admin(org.apache.hadoop.hbase.client.Admin) BeforeClass(org.junit.BeforeClass)

Example 28 with HBaseTestingUtil

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

the class WALEntryStreamTestBase method startCluster.

protected static void startCluster() throws Exception {
    TEST_UTIL = new HBaseTestingUtil();
    CONF = TEST_UTIL.getConfiguration();
    CONF.setLong("replication.source.sleepforretries", 10);
    TEST_UTIL.startMiniDFSCluster(3);
    cluster = TEST_UTIL.getDFSCluster();
    fs = cluster.getFileSystem();
}
Also used : HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil)

Example 29 with HBaseTestingUtil

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

the class TestBlockReorderBlockLocation method setUp.

@Before
public void setUp() throws Exception {
    htu = new HBaseTestingUtil();
    // For the test with multiple blocks
    htu.getConfiguration().setInt("dfs.blocksize", 1024);
    htu.getConfiguration().setInt("dfs.replication", 3);
    htu.startMiniDFSCluster(3, new String[] { "/r1", "/r2", "/r3" }, new String[] { host1, host2, host3 });
    conf = htu.getConfiguration();
    cluster = htu.getDFSCluster();
    dfs = (DistributedFileSystem) FileSystem.get(conf);
}
Also used : HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Before(org.junit.Before)

Example 30 with HBaseTestingUtil

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

the class TestFileLink method testGetUnderlyingFSDataInputStream.

/**
 * Test that the returned link from {@link FileLink#open(FileSystem)} can be unwrapped
 * to a {@link HdfsDataInputStream} by
 * {@link FileLink#getUnderlyingFileLinkInputStream(FSDataInputStream)}
 */
@Test
public void testGetUnderlyingFSDataInputStream() throws Exception {
    HBaseTestingUtil testUtil = new HBaseTestingUtil();
    Configuration conf = testUtil.getConfiguration();
    conf.setInt("dfs.blocksize", 1024 * 1024);
    conf.setInt("dfs.client.read.prefetch.size", 2 * 1024 * 1024);
    testUtil.startMiniDFSCluster(1);
    try {
        MiniDFSCluster cluster = testUtil.getDFSCluster();
        FileSystem fs = cluster.getFileSystem();
        Path originalPath = new Path(testUtil.getDefaultRootDirPath(), "test.file");
        writeSomeData(fs, originalPath, 256 << 20, (byte) 2);
        List<Path> files = new ArrayList<Path>();
        files.add(originalPath);
        FileLink link = new FileLink(files);
        FSDataInputStream stream = link.open(fs);
        FSDataInputStream underlying = FileLink.getUnderlyingFileLinkInputStream(stream);
        assertTrue(underlying instanceof HdfsDataInputStream);
    } finally {
        testUtil.shutdownMiniCluster();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) ArrayList(java.util.ArrayList) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) HdfsDataInputStream(org.apache.hadoop.hdfs.client.HdfsDataInputStream) Test(org.junit.Test)

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