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());
}
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");
}
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));
}
}
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()));
}
}
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());
}
Aggregations