Search in sources :

Example 41 with ZKWatcher

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

the class RegionServerFlushTableProcedureManager method initialize.

/**
 * Initialize this region server flush procedure manager
 * Uses a zookeeper based member controller.
 * @param rss region server
 * @throws KeeperException if the zookeeper cannot be reached
 */
@Override
public void initialize(RegionServerServices rss) throws KeeperException {
    this.rss = rss;
    ZKWatcher zkw = rss.getZooKeeper();
    this.memberRpcs = new ZKProcedureMemberRpcs(zkw, MasterFlushTableProcedureManager.FLUSH_TABLE_PROCEDURE_SIGNATURE);
    Configuration conf = rss.getConfiguration();
    long keepAlive = conf.getLong(FLUSH_TIMEOUT_MILLIS_KEY, FLUSH_TIMEOUT_MILLIS_DEFAULT);
    int opThreads = conf.getInt(FLUSH_REQUEST_THREADS_KEY, FLUSH_REQUEST_THREADS_DEFAULT);
    // create the actual flush table procedure member
    ThreadPoolExecutor pool = ProcedureMember.defaultPool(rss.getServerName().toString(), opThreads, keepAlive);
    this.member = new ProcedureMember(memberRpcs, pool, new FlushTableSubprocedureBuilder());
}
Also used : ProcedureMember(org.apache.hadoop.hbase.procedure.ProcedureMember) Configuration(org.apache.hadoop.conf.Configuration) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) ZKProcedureMemberRpcs(org.apache.hadoop.hbase.procedure.ZKProcedureMemberRpcs) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 42 with ZKWatcher

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

the class IntegrationTestZKAndFSPermissions method testZNodeACLs.

private void testZNodeACLs() throws IOException, KeeperException, InterruptedException {
    ZKWatcher watcher = new ZKWatcher(conf, "IntegrationTestZnodeACLs", null);
    RecoverableZooKeeper zk = RecoverableZooKeeper.connect(this.conf, watcher);
    String baseZNode = watcher.getZNodePaths().baseZNode;
    LOG.info("");
    LOG.info("***********************************************************************************");
    LOG.info("Checking ZK permissions, root znode: " + baseZNode);
    LOG.info("***********************************************************************************");
    LOG.info("");
    checkZnodePermsRecursive(watcher, zk, baseZNode);
    LOG.info("Checking ZK permissions: SUCCESS");
}
Also used : RecoverableZooKeeper(org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher)

Example 43 with ZKWatcher

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

the class HBaseReplicationEndpoint method reloadZkWatcher.

/**
 * Closes the current ZKW (if not null) and creates a new one
 * @throws IOException If anything goes wrong connecting
 */
private void reloadZkWatcher() throws IOException {
    synchronized (zkwLock) {
        if (zkw != null) {
            zkw.close();
        }
        zkw = new ZKWatcher(ctx.getConfiguration(), "connection to cluster: " + ctx.getPeerId(), this);
        zkw.registerListener(new PeerRegionServerListener(this));
    }
}
Also used : ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher)

Example 44 with ZKWatcher

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

the class TestZooKeeper method testRegionAssignmentAfterMasterRecoveryDueToZKExpiry.

/**
 * Tests that the master does not call retainAssignment after recovery from expired zookeeper
 * session. Without the HBASE-6046 fix master always tries to assign all the user regions by
 * calling retainAssignment.
 */
@Test
public void testRegionAssignmentAfterMasterRecoveryDueToZKExpiry() throws Exception {
    SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    cluster.startRegionServer();
    cluster.waitForActiveAndReadyMaster(10000);
    HMaster m = cluster.getMaster();
    final ZKWatcher zkw = m.getZooKeeper();
    // now the cluster is up. So assign some regions.
    try (Admin admin = TEST_UTIL.getAdmin()) {
        byte[][] SPLIT_KEYS = new byte[][] { Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c"), Bytes.toBytes("d"), Bytes.toBytes("e"), Bytes.toBytes("f"), Bytes.toBytes("g"), Bytes.toBytes("h"), Bytes.toBytes("i"), Bytes.toBytes("j") };
        TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).setColumnFamily(ColumnFamilyDescriptorBuilder.of(HConstants.CATALOG_FAMILY)).build();
        admin.createTable(htd, SPLIT_KEYS);
        TEST_UTIL.waitUntilNoRegionsInTransition(60000);
        m.getZooKeeper().close();
        MockLoadBalancer.retainAssignCalled = false;
        final int expectedNumOfListeners = countPermanentListeners(zkw);
        m.abort("Test recovery from zk session expired", new KeeperException.SessionExpiredException());
        // Master doesn't recover any more
        assertTrue(m.isStopped());
        // The recovered master should not call retainAssignment, as it is not a
        // clean startup.
        assertFalse("Retain assignment should not be called", MockLoadBalancer.retainAssignCalled);
        // number of listeners should be same as the value before master aborted
        // wait for new master is initialized
        cluster.waitForActiveAndReadyMaster(120000);
        final HMaster newMaster = cluster.getMasterThread().getMaster();
        assertEquals(expectedNumOfListeners, countPermanentListeners(newMaster.getZooKeeper()));
    }
}
Also used : ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) HMaster(org.apache.hadoop.hbase.master.HMaster) Admin(org.apache.hadoop.hbase.client.Admin) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) KeeperException(org.apache.zookeeper.KeeperException) Test(org.junit.Test)

Example 45 with ZKWatcher

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

the class TestCleanupMetaReplica method testReplicaCleanup.

@Test
public void testReplicaCleanup() throws Exception {
    ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
    List<String> metaReplicaZnodes = zkw.getMetaReplicaNodes();
    assertEquals(3, metaReplicaZnodes.size());
    HBaseTestingUtil.setReplicas(TEST_UTIL.getAdmin(), TableName.META_TABLE_NAME, 1);
    metaReplicaZnodes = zkw.getMetaReplicaNodes();
    assertEquals(1, metaReplicaZnodes.size());
}
Also used : ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) Test(org.junit.Test)

Aggregations

ZKWatcher (org.apache.hadoop.hbase.zookeeper.ZKWatcher)66 Configuration (org.apache.hadoop.conf.Configuration)27 Test (org.junit.Test)24 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)13 ArrayList (java.util.ArrayList)10 ServerName (org.apache.hadoop.hbase.ServerName)10 IOException (java.io.IOException)8 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)8 Before (org.junit.Before)8 BeforeClass (org.junit.BeforeClass)8 Admin (org.apache.hadoop.hbase.client.Admin)7 Abortable (org.apache.hadoop.hbase.Abortable)6 HMaster (org.apache.hadoop.hbase.master.HMaster)6 MiniZooKeeperCluster (org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster)6 List (java.util.List)5 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)5 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)5 ReplicationPeerConfig (org.apache.hadoop.hbase.replication.ReplicationPeerConfig)5 KeeperException (org.apache.zookeeper.KeeperException)5 CountDownLatch (java.util.concurrent.CountDownLatch)4