Search in sources :

Example 31 with ZooKeeperWatcher

use of org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher in project hbase by apache.

the class TestReplicationAdmin method testAddPeerWithUnDeletedQueues.

@Test
public void testAddPeerWithUnDeletedQueues() throws Exception {
    ReplicationPeerConfig rpc1 = new ReplicationPeerConfig();
    rpc1.setClusterKey(KEY_ONE);
    ReplicationPeerConfig rpc2 = new ReplicationPeerConfig();
    rpc2.setClusterKey(KEY_SECOND);
    Configuration conf = TEST_UTIL.getConfiguration();
    ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "Test HBaseAdmin", null);
    ReplicationQueues repQueues = ReplicationFactory.getReplicationQueues(new ReplicationQueuesArguments(conf, null, zkw));
    repQueues.init("server1");
    // add queue for ID_ONE
    repQueues.addLog(ID_ONE, "file1");
    try {
        admin.addPeer(ID_ONE, rpc1, null);
        fail();
    } catch (Exception e) {
    // OK!
    }
    repQueues.removeQueue(ID_ONE);
    assertEquals(0, repQueues.getAllQueues().size());
    // add recovered queue for ID_ONE
    repQueues.addLog(ID_ONE + "-server2", "file1");
    try {
        admin.addPeer(ID_ONE, rpc2, null);
        fail();
    } catch (Exception e) {
    // OK!
    }
    repQueues.removeAllQueues();
    zkw.close();
}
Also used : ReplicationQueues(org.apache.hadoop.hbase.replication.ReplicationQueues) ReplicationQueuesArguments(org.apache.hadoop.hbase.replication.ReplicationQueuesArguments) ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) Configuration(org.apache.hadoop.conf.Configuration) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) ReplicationPeerNotFoundException(org.apache.hadoop.hbase.ReplicationPeerNotFoundException) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) IOException(java.io.IOException) RetriesExhaustedException(org.apache.hadoop.hbase.client.RetriesExhaustedException) Test(org.junit.Test)

Example 32 with ZooKeeperWatcher

use of org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher in project hbase by apache.

the class TestSerialReplication method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    conf1 = HBaseConfiguration.create();
    conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
    // smaller block size and capacity to trigger more operations
    // and test them
    conf1.setInt("hbase.regionserver.hlog.blocksize", 1024 * 20);
    conf1.setInt("replication.source.size.capacity", 1024);
    conf1.setLong("replication.source.sleepforretries", 100);
    conf1.setInt("hbase.regionserver.maxlogs", 10);
    conf1.setLong("hbase.master.logcleaner.ttl", 10);
    conf1.setBoolean("dfs.support.append", true);
    conf1.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
    conf1.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, "org.apache.hadoop.hbase.replication.TestMasterReplication$CoprocessorCounter");
    // Each WAL is 120 bytes
    conf1.setLong("replication.source.per.peer.node.bandwidth", 100L);
    conf1.setLong("replication.source.size.capacity", 1L);
    conf1.setLong(HConstants.REPLICATION_SERIALLY_WAITING_KEY, 1000L);
    utility1 = new HBaseTestingUtility(conf1);
    utility1.startMiniZKCluster();
    MiniZooKeeperCluster miniZK = utility1.getZkCluster();
    new ZooKeeperWatcher(conf1, "cluster1", null, true);
    conf2 = new Configuration(conf1);
    conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
    utility2 = new HBaseTestingUtility(conf2);
    utility2.setZkCluster(miniZK);
    new ZooKeeperWatcher(conf2, "cluster2", null, true);
    utility1.startMiniCluster(1, 10);
    utility2.startMiniCluster(1, 1);
    ReplicationAdmin admin1 = new ReplicationAdmin(conf1);
    ReplicationPeerConfig rpc = new ReplicationPeerConfig();
    rpc.setClusterKey(utility2.getClusterKey());
    admin1.addPeer("1", rpc, null);
    utility1.getAdmin().setBalancerRunning(false, true);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) ReplicationAdmin(org.apache.hadoop.hbase.client.replication.ReplicationAdmin) MiniZooKeeperCluster(org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster) BeforeClass(org.junit.BeforeClass)

Example 33 with ZooKeeperWatcher

use of org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher in project hbase by apache.

the class TestTableCFsUpdater method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    TEST_UTIL.startMiniZKCluster();
    Configuration conf = TEST_UTIL.getConfiguration();
    abortable = new Abortable() {

        @Override
        public void abort(String why, Throwable e) {
            LOG.info(why, e);
        }

        @Override
        public boolean isAborted() {
            return false;
        }
    };
    zkw = new ZooKeeperWatcher(conf, "TableCFs", abortable, true);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Abortable(org.apache.hadoop.hbase.Abortable) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) BeforeClass(org.junit.BeforeClass)

Example 34 with ZooKeeperWatcher

use of org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher in project hbase by apache.

the class TestReplicationTrackerZKImpl method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    utility = new HBaseTestingUtility();
    utility.startMiniZKCluster();
    conf = utility.getConfiguration();
    ZooKeeperWatcher zk = HBaseTestingUtility.getZooKeeperWatcher(utility);
    ZKUtil.createWithParents(zk, zk.znodePaths.rsZNode);
}
Also used : HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) BeforeClass(org.junit.BeforeClass)

Example 35 with ZooKeeperWatcher

use of org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher in project hbase by apache.

the class TestMasterReplication method testLoopedReplication.

/**
   * Tests the replication scenario 0 -> 0. By default
   * {@link BaseReplicationEndpoint#canReplicateToSameCluster()} returns false, so the
   * ReplicationSource should terminate, and no further logs should get enqueued
   */
@Test(timeout = 300000)
public void testLoopedReplication() throws Exception {
    LOG.info("testLoopedReplication");
    startMiniClusters(1);
    createTableOnClusters(table);
    addPeer("1", 0, 0);
    Thread.sleep(SLEEP_TIME);
    // wait for source to terminate
    final ServerName rsName = utilities[0].getHBaseCluster().getRegionServer(0).getServerName();
    Waiter.waitFor(baseConfiguration, 10000, new Waiter.Predicate<Exception>() {

        @Override
        public boolean evaluate() throws Exception {
            ClusterStatus clusterStatus = utilities[0].getAdmin().getClusterStatus();
            ServerLoad serverLoad = clusterStatus.getLoad(rsName);
            List<ReplicationLoadSource> replicationLoadSourceList = serverLoad.getReplicationLoadSourceList();
            return replicationLoadSourceList.isEmpty();
        }
    });
    Table[] htables = getHTablesOnClusters(tableName);
    putAndWait(row, famName, htables[0], htables[0]);
    rollWALAndWait(utilities[0], table.getTableName(), row);
    ZooKeeperWatcher zkw = utilities[0].getZooKeeperWatcher();
    String queuesZnode = ZKUtil.joinZNode(zkw.getZNodePaths().baseZNode, ZKUtil.joinZNode("replication", "rs"));
    List<String> listChildrenNoWatch = ZKUtil.listChildrenNoWatch(zkw, ZKUtil.joinZNode(queuesZnode, rsName.toString()));
    assertEquals(0, listChildrenNoWatch.size());
}
Also used : Table(org.apache.hadoop.hbase.client.Table) IOException(java.io.IOException) ServerLoad(org.apache.hadoop.hbase.ServerLoad) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) ServerName(org.apache.hadoop.hbase.ServerName) List(java.util.List) Waiter(org.apache.hadoop.hbase.Waiter) ClusterStatus(org.apache.hadoop.hbase.ClusterStatus) Test(org.junit.Test)

Aggregations

ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)60 Test (org.junit.Test)33 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)20 Table (org.apache.hadoop.hbase.client.Table)19 Configuration (org.apache.hadoop.conf.Configuration)16 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)15 Ignore (org.junit.Ignore)15 IOException (java.io.IOException)13 ServerName (org.apache.hadoop.hbase.ServerName)12 RegionServerThread (org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread)12 TimeoutException (java.util.concurrent.TimeoutException)9 Waiter (org.apache.hadoop.hbase.Waiter)9 OperationConflictException (org.apache.hadoop.hbase.exceptions.OperationConflictException)9 ArrayList (java.util.ArrayList)8 RetriesExhaustedWithDetailsException (org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException)8 RegionInRecoveryException (org.apache.hadoop.hbase.exceptions.RegionInRecoveryException)8 ServerNotRunningYetException (org.apache.hadoop.hbase.ipc.ServerNotRunningYetException)8 MetaTableLocator (org.apache.hadoop.hbase.zookeeper.MetaTableLocator)7 HashSet (java.util.HashSet)6 TableName (org.apache.hadoop.hbase.TableName)6