HBASE-19761:Fix Checkstyle errors in hbase-zookeeper

Signed-off-by: Jan Hentschel <jan.hentschel@ultratendency.com>
This commit is contained in:
maoling 2018-05-29 21:06:38 +08:00 committed by Jan Hentschel
parent 9d5004894c
commit 1b98a96caa
62 changed files with 288 additions and 262 deletions

View File

@ -81,7 +81,7 @@ public class IntegrationTestMetaReplicas {
}
private static void waitUntilZnodeAvailable(int replicaId) throws Exception {
String znode = util.getZooKeeperWatcher().znodePaths.getZNodeForReplica(replicaId);
String znode = util.getZooKeeperWatcher().getZNodePaths().getZNodeForReplica(replicaId);
int i = 0;
while (i < 1000) {
if (ZKUtil.checkExists(util.getZooKeeperWatcher(), znode) == -1) {

View File

@ -144,7 +144,7 @@ public class IntegrationTestZKAndFSPermissions extends AbstractHBaseTool {
ZKWatcher watcher = new ZKWatcher(conf, "IntegrationTestZnodeACLs", null);
RecoverableZooKeeper zk = ZKUtil.connect(this.conf, watcher);
String baseZNode = watcher.znodePaths.baseZNode;
String baseZNode = watcher.getZNodePaths().baseZNode;
LOG.info("");
LOG.info("***********************************************************************************");
@ -160,7 +160,7 @@ public class IntegrationTestZKAndFSPermissions extends AbstractHBaseTool {
private void checkZnodePermsRecursive(ZKWatcher watcher,
RecoverableZooKeeper zk, String znode) throws KeeperException, InterruptedException {
boolean expectedWorldReadable = watcher.znodePaths.isClientReadable(znode);
boolean expectedWorldReadable = watcher.getZNodePaths().isClientReadable(znode);
assertZnodePerms(zk, znode, expectedWorldReadable);

View File

@ -138,7 +138,7 @@ public class ReplicationTrackerZKImpl implements ReplicationTracker {
}
private boolean refreshListIfRightPath(String path) {
if (!path.startsWith(this.watcher.znodePaths.rsZNode)) {
if (!path.startsWith(this.watcher.getZNodePaths().rsZNode)) {
return false;
}
return refreshOtherRegionServersList(true);
@ -182,9 +182,10 @@ public class ReplicationTrackerZKImpl implements ReplicationTracker {
List<String> result = null;
try {
if (watch) {
result = ZKUtil.listChildrenAndWatchThem(this.zookeeper, this.zookeeper.znodePaths.rsZNode);
result = ZKUtil.listChildrenAndWatchThem(this.zookeeper,
this.zookeeper.getZNodePaths().rsZNode);
} else {
result = ZKUtil.listChildrenNoWatch(this.zookeeper, this.zookeeper.znodePaths.rsZNode);
result = ZKUtil.listChildrenNoWatch(this.zookeeper, this.zookeeper.getZNodePaths().rsZNode);
}
} catch (KeeperException e) {
this.abortable.abort("Get list of registered region servers", e);

View File

@ -50,7 +50,7 @@ public class ZKReplicationStorageBase {
this.zookeeper = zookeeper;
this.conf = conf;
this.replicationZNode = ZNodePaths.joinZNode(this.zookeeper.znodePaths.baseZNode,
this.replicationZNode = ZNodePaths.joinZNode(this.zookeeper.getZNodePaths().baseZNode,
conf.get(REPLICATION_ZNODE, REPLICATION_ZNODE_DEFAULT));
}

View File

@ -58,7 +58,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
conf.setBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY, true);
zkw = utility.getZooKeeperWatcher();
String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication");
replicationZNode = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, replicationZNodeName);
replicationZNode = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, replicationZNodeName);
KEY_ONE = initPeerClusterState("/hbase1");
KEY_TWO = initPeerClusterState("/hbase2");
}
@ -69,7 +69,8 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
Configuration testConf = new Configuration(conf);
testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
ZKWatcher zkw1 = new ZKWatcher(testConf, "test1", null);
String fakeRs = ZNodePaths.joinZNode(zkw1.znodePaths.rsZNode, "hostname1.example.org:1234");
String fakeRs = ZNodePaths.joinZNode(zkw1.getZNodePaths().rsZNode,
"hostname1.example.org:1234");
ZKUtil.createWithParents(zkw1, fakeRs);
ZKClusterId.setClusterId(zkw1, new ClusterId());
return ZKConfig.getZooKeeperClusterKey(testConf);

View File

@ -347,7 +347,7 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager {
}
List<RSGroupInfo> retrieveGroupListFromZookeeper() throws IOException {
String groupBasePath = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, rsGroupZNode);
String groupBasePath = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, rsGroupZNode);
List<RSGroupInfo> RSGroupInfoList = Lists.newArrayList();
//Overwrite any info stored by table, this takes precedence
try {
@ -488,7 +488,7 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager {
resetRSGroupAndTableMaps(newGroupMap, newTableMap);
try {
String groupBasePath = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, rsGroupZNode);
String groupBasePath = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, rsGroupZNode);
ZKUtil.createAndFailSilent(watcher, groupBasePath, ProtobufMagic.PB_MAGIC);
List<ZKUtil.ZKUtilOp> zkOps = new ArrayList<>(newGroupMap.size());
@ -549,7 +549,7 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager {
LOG.debug("Reading online RS from zookeeper");
List<ServerName> servers = new LinkedList<>();
try {
for (String el: ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.rsZNode)) {
for (String el: ZKUtil.listChildrenNoWatch(watcher, watcher.getZNodePaths().rsZNode)) {
servers.add(ServerName.parseServerName(el));
}
} catch (KeeperException e) {

View File

@ -134,7 +134,7 @@ public class VerifyingRSGroupAdminClient implements RSGroupAdmin {
Assert.assertEquals(Sets.newHashSet(groupMap.values()),
Sets.newHashSet(wrapped.listRSGroups()));
try {
String groupBasePath = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "rsgroup");
String groupBasePath = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "rsgroup");
for(String znode: ZKUtil.listChildrenNoWatch(zkw, groupBasePath)) {
byte[] data = ZKUtil.getData(zkw, ZNodePaths.joinZNode(groupBasePath, znode));
if(data.length > 0) {

View File

@ -55,7 +55,7 @@ public class ZKNamespaceManager extends ZKListener {
public ZKNamespaceManager(ZKWatcher zkw) throws IOException {
super(zkw);
nsZNode = zkw.znodePaths.namespaceZNode;
nsZNode = zkw.getZNodePaths().namespaceZNode;
cache = new ConcurrentSkipListMap<>();
}

View File

@ -186,7 +186,7 @@ public final class ZNodeClearer {
if (ZNodeClearer.tablesOnMaster(conf)) {
// In case of master crash also remove rsZnode since master is also regionserver
ZKUtil.deleteNodeFailSilent(zkw,
ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, znodeFileContent));
ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, znodeFileContent));
return MasterAddressTracker.deleteIfEquals(zkw,
ZNodeClearer.parseMasterServerName(znodeFileContent));
} else {

View File

@ -149,7 +149,7 @@ public class ZKTableArchiveClient extends Configured {
* @return get the znode for long-term archival of a table for
*/
public static String getArchiveZNode(Configuration conf, ZKWatcher zooKeeper) {
return ZNodePaths.joinZNode(zooKeeper.znodePaths.baseZNode, conf.get(
return ZNodePaths.joinZNode(zooKeeper.getZNodePaths().baseZNode, conf.get(
ZOOKEEPER_ZNODE_HFILE_ARCHIVE_KEY, TableHFileArchiveTracker.HFILE_ARCHIVE_ZNODE_PARENT));
}
}

View File

@ -122,7 +122,8 @@ public class ZKSplitLogManagerCoordination extends ZKListener implements
public int remainingTasksInCoordination() {
int count = 0;
try {
List<String> tasks = ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.splitLogZNode);
List<String> tasks = ZKUtil.listChildrenNoWatch(watcher,
watcher.getZNodePaths().splitLogZNode);
if (tasks != null) {
int listSize = tasks.size();
for (int i = 0; i < listSize; i++) {
@ -466,13 +467,14 @@ public class ZKSplitLogManagerCoordination extends ZKListener implements
private void lookForOrphans() {
List<String> orphans;
try {
orphans = ZKUtil.listChildrenNoWatch(this.watcher, this.watcher.znodePaths.splitLogZNode);
orphans = ZKUtil.listChildrenNoWatch(this.watcher,
this.watcher.getZNodePaths().splitLogZNode);
if (orphans == null) {
LOG.warn("Could not get children of " + this.watcher.znodePaths.splitLogZNode);
LOG.warn("Could not get children of " + this.watcher.getZNodePaths().splitLogZNode);
return;
}
} catch (KeeperException e) {
LOG.warn("Could not get children of " + this.watcher.znodePaths.splitLogZNode + " "
LOG.warn("Could not get children of " + this.watcher.getZNodePaths().splitLogZNode + " "
+ StringUtils.stringifyException(e));
return;
}
@ -480,7 +482,7 @@ public class ZKSplitLogManagerCoordination extends ZKListener implements
int listSize = orphans.size();
for (int i = 0; i < listSize; i++) {
String path = orphans.get(i);
String nodepath = ZNodePaths.joinZNode(watcher.znodePaths.splitLogZNode, path);
String nodepath = ZNodePaths.joinZNode(watcher.getZNodePaths().splitLogZNode, path);
if (ZKSplitLog.isRescanNode(watcher, nodepath)) {
rescan_nodes++;
LOG.debug("Found orphan rescan node " + path);

View File

@ -97,7 +97,7 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements
*/
@Override
public void nodeChildrenChanged(String path) {
if (path.equals(watcher.znodePaths.splitLogZNode)) {
if (path.equals(watcher.getZNodePaths().splitLogZNode)) {
if (LOG.isTraceEnabled()) {
LOG.trace("tasks arrived or departed on " + path);
}
@ -331,7 +331,7 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements
int availableRSs = 1;
try {
List<String> regionServers =
ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.rsZNode);
ZKUtil.listChildrenNoWatch(watcher, watcher.getZNodePaths().rsZNode);
availableRSs = Math.max(availableRSs, (regionServers == null) ? 0 : regionServers.size());
} catch (KeeperException e) {
// do nothing
@ -412,7 +412,7 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements
List<String> paths;
paths = getTaskList();
if (paths == null) {
LOG.warn("Could not get tasks, did someone remove " + watcher.znodePaths.splitLogZNode
LOG.warn("Could not get tasks, did someone remove " + watcher.getZNodePaths().splitLogZNode
+ " ... worker thread exiting.");
return;
}
@ -439,7 +439,7 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements
// don't call ZKSplitLog.getNodeName() because that will lead to
// double encoding of the path name
taskGrabbed |= grabTask(ZNodePaths.joinZNode(
watcher.znodePaths.splitLogZNode, paths.get(idx)));
watcher.getZNodePaths().splitLogZNode, paths.get(idx)));
break;
} else {
LOG.debug("Current region server " + server.getServerName() + " has "
@ -472,14 +472,14 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements
while (!shouldStop) {
try {
childrenPaths = ZKUtil.listChildrenAndWatchForNewChildren(watcher,
watcher.znodePaths.splitLogZNode);
watcher.getZNodePaths().splitLogZNode);
if (childrenPaths != null) {
return childrenPaths;
}
} catch (KeeperException e) {
LOG.warn("Could not get children of znode " + watcher.znodePaths.splitLogZNode, e);
LOG.warn("Could not get children of znode " + watcher.getZNodePaths().splitLogZNode, e);
}
LOG.debug("Retry listChildren of znode " + watcher.znodePaths.splitLogZNode
LOG.debug("Retry listChildren of znode " + watcher.getZNodePaths().splitLogZNode
+ " after sleep for " + sleepTime + "ms!");
Thread.sleep(sleepTime);
}
@ -495,14 +495,14 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements
public boolean isReady() throws InterruptedException {
int result = -1;
try {
result = ZKUtil.checkExists(watcher, watcher.znodePaths.splitLogZNode);
result = ZKUtil.checkExists(watcher, watcher.getZNodePaths().splitLogZNode);
} catch (KeeperException e) {
// ignore
LOG.warn("Exception when checking for " + watcher.znodePaths.splitLogZNode
LOG.warn("Exception when checking for " + watcher.getZNodePaths().splitLogZNode
+ " ... retrying", e);
}
if (result == -1) {
LOG.info(watcher.znodePaths.splitLogZNode
LOG.info(watcher.getZNodePaths().splitLogZNode
+ " znode does not exist, waiting for master to create");
Thread.sleep(1000);
}

View File

@ -93,7 +93,7 @@ public class ActiveMasterManager extends ZKListener {
// shut down, so that state is now irrelevant. This means that the shutdown
// state must be set while we wait on the active master in order
// to shutdown this master. See HBASE-8519.
if(path.equals(watcher.znodePaths.clusterStateZNode) && !master.isStopped()) {
if(path.equals(watcher.getZNodePaths().clusterStateZNode) && !master.isStopped()) {
clusterShutDown.set(true);
}
@ -101,7 +101,7 @@ public class ActiveMasterManager extends ZKListener {
}
void handle(final String path) {
if (path.equals(watcher.znodePaths.masterAddressZNode) && !master.isStopped()) {
if (path.equals(watcher.getZNodePaths().masterAddressZNode) && !master.isStopped()) {
handleMasterNodeChange();
}
}
@ -123,7 +123,7 @@ public class ActiveMasterManager extends ZKListener {
// Watch the node and check if it exists.
try {
synchronized(clusterHasActiveMaster) {
if (ZKUtil.watchAndCheckExists(watcher, watcher.znodePaths.masterAddressZNode)) {
if (ZKUtil.watchAndCheckExists(watcher, watcher.getZNodePaths().masterAddressZNode)) {
// A master node exists, there is an active master
LOG.trace("A master is now available");
clusterHasActiveMaster.set(true);
@ -157,14 +157,14 @@ public class ActiveMasterManager extends ZKListener {
boolean blockUntilBecomingActiveMaster(
int checkInterval, MonitoredTask startupStatus) {
String backupZNode = ZNodePaths.joinZNode(
this.watcher.znodePaths.backupMasterAddressesZNode, this.sn.toString());
this.watcher.getZNodePaths().backupMasterAddressesZNode, this.sn.toString());
while (!(master.isAborted() || master.isStopped())) {
startupStatus.setStatus("Trying to register in ZK as active master");
// Try to become the active master, watch if there is another master.
// Write out our ServerName as versioned bytes.
try {
if (MasterAddressTracker.setMasterAddress(this.watcher,
this.watcher.znodePaths.masterAddressZNode, this.sn, infoPort)) {
this.watcher.getZNodePaths().masterAddressZNode, this.sn, infoPort)) {
// If we were a backup master before, delete our ZNode from the backup
// master directory since we are the active now)
@ -188,7 +188,7 @@ public class ActiveMasterManager extends ZKListener {
String msg;
byte[] bytes =
ZKUtil.getDataAndWatch(this.watcher, this.watcher.znodePaths.masterAddressZNode);
ZKUtil.getDataAndWatch(this.watcher, this.watcher.getZNodePaths().masterAddressZNode);
if (bytes == null) {
msg = ("A master was detected, but went down before its address " +
"could be read. Attempting to become the next active master");
@ -205,7 +205,7 @@ public class ActiveMasterManager extends ZKListener {
msg = ("Current master has this master's address, " +
currentMaster + "; master was restarted? Deleting node.");
// Hurry along the expiration of the znode.
ZKUtil.deleteNode(this.watcher, this.watcher.znodePaths.masterAddressZNode);
ZKUtil.deleteNode(this.watcher, this.watcher.getZNodePaths().masterAddressZNode);
// We may have failed to delete the znode at the previous step, but
// we delete the file anyway: a second attempt to delete the znode is likely to fail again.
@ -245,7 +245,7 @@ public class ActiveMasterManager extends ZKListener {
*/
boolean hasActiveMaster() {
try {
if (ZKUtil.checkExists(watcher, watcher.znodePaths.masterAddressZNode) >= 0) {
if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().masterAddressZNode) >= 0) {
return true;
}
}
@ -271,7 +271,7 @@ public class ActiveMasterManager extends ZKListener {
LOG.warn("Failed get of master address: " + e.toString());
}
if (activeMaster != null && activeMaster.equals(this.sn)) {
ZKUtil.deleteNode(watcher, watcher.znodePaths.masterAddressZNode);
ZKUtil.deleteNode(watcher, watcher.getZNodePaths().masterAddressZNode);
// We may have failed to delete the znode at the previous step, but
// we delete the file anyway: a second attempt to delete the znode is likely to fail again.
ZNodeClearer.deleteMyEphemeralNodeOnDisk();

View File

@ -83,7 +83,7 @@ public class DrainingServerTracker extends ZKListener {
}
});
List<String> servers =
ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.drainingZNode);
ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().drainingZNode);
add(servers);
}
@ -110,7 +110,7 @@ public class DrainingServerTracker extends ZKListener {
@Override
public void nodeDeleted(final String path) {
if(path.startsWith(watcher.znodePaths.drainingZNode)) {
if(path.startsWith(watcher.getZNodePaths().drainingZNode)) {
final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(path));
LOG.info("Draining RS node deleted, removing from list [" +
sn + "]");
@ -120,10 +120,10 @@ public class DrainingServerTracker extends ZKListener {
@Override
public void nodeChildrenChanged(final String path) {
if(path.equals(watcher.znodePaths.drainingZNode)) {
if(path.equals(watcher.getZNodePaths().drainingZNode)) {
try {
final List<String> newNodes =
ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.drainingZNode);
ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().drainingZNode);
add(newNodes);
} catch (KeeperException e) {
abortable.abort("Unexpected zk exception getting RS nodes", e);

View File

@ -2025,7 +2025,7 @@ public class HMaster extends HRegionServer implements MasterServices {
private void startActiveMasterManager(int infoPort) throws KeeperException {
String backupZNode = ZNodePaths.joinZNode(
zooKeeper.znodePaths.backupMasterAddressesZNode, serverName.toString());
zooKeeper.getZNodePaths().backupMasterAddressesZNode, serverName.toString());
/*
* Add a ZNode for ourselves in the backup master directory since we
* may not become the active master. If so, we want the actual active
@ -2538,7 +2538,7 @@ public class HMaster extends HRegionServer implements MasterServices {
List<String> backupMasterStrings;
try {
backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper,
this.zooKeeper.znodePaths.backupMasterAddressesZNode);
this.zooKeeper.getZNodePaths().backupMasterAddressesZNode);
} catch (KeeperException e) {
LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e);
backupMasterStrings = null;
@ -2552,7 +2552,7 @@ public class HMaster extends HRegionServer implements MasterServices {
byte [] bytes;
try {
bytes = ZKUtil.getData(this.zooKeeper, ZNodePaths.joinZNode(
this.zooKeeper.znodePaths.backupMasterAddressesZNode, s));
this.zooKeeper.getZNodePaths().backupMasterAddressesZNode, s));
} catch (InterruptedException e) {
throw new InterruptedIOException();
}
@ -3500,7 +3500,7 @@ public class HMaster extends HRegionServer implements MasterServices {
throws HBaseIOException {
List<ServerName> serversAdded = new ArrayList<>(servers.size());
// Place the decommission marker first.
String parentZnode = getZooKeeper().znodePaths.drainingZNode;
String parentZnode = getZooKeeper().getZNodePaths().drainingZNode;
for (ServerName server : servers) {
try {
String node = ZNodePaths.joinZNode(parentZnode, server.getServerName());
@ -3549,7 +3549,7 @@ public class HMaster extends HRegionServer implements MasterServices {
public void recommissionRegionServer(final ServerName server,
final List<byte[]> encodedRegionNames) throws HBaseIOException {
// Remove the server from decommissioned (draining) server list.
String parentZnode = getZooKeeper().znodePaths.drainingZNode;
String parentZnode = getZooKeeper().getZNodePaths().drainingZNode;
String node = ZNodePaths.joinZNode(parentZnode, server.getServerName());
try {
ZKUtil.deleteNodeFailSilent(getZooKeeper(), node);

View File

@ -125,14 +125,14 @@ public class MasterMetaBootstrap {
try {
List<String> metaReplicaZnodes = zooKeeper.getMetaReplicaNodes();
for (String metaReplicaZnode : metaReplicaZnodes) {
int replicaId = zooKeeper.znodePaths.getMetaReplicaIdFromZnode(metaReplicaZnode);
int replicaId = zooKeeper.getZNodePaths().getMetaReplicaIdFromZnode(metaReplicaZnode);
if (replicaId >= numMetaReplicasConfigured) {
RegionState r = MetaTableLocator.getMetaRegionState(zooKeeper, replicaId);
LOG.info("Closing excess replica of meta region " + r.getRegion());
// send a close and wait for a max of 30 seconds
ServerManager.closeRegionSilentlyAndWait(master.getClusterConnection(),
r.getServerName(), r.getRegion(), 30000);
ZKUtil.deleteNode(zooKeeper, zooKeeper.znodePaths.getZNodeForReplica(replicaId));
ZKUtil.deleteNode(zooKeeper, zooKeeper.getZNodePaths().getZNodeForReplica(replicaId));
}
}
} catch (Exception ex) {

View File

@ -72,7 +72,7 @@ public class RegionServerTracker extends ZKListener {
public void start() throws KeeperException, IOException {
watcher.registerListener(this);
List<String> servers =
ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.rsZNode);
ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().rsZNode);
refresh(servers);
}
@ -84,7 +84,7 @@ public class RegionServerTracker extends ZKListener {
if (regionServers.get(sn) == null) {
RegionServerInfo.Builder rsInfoBuilder = RegionServerInfo.newBuilder();
try {
String nodePath = ZNodePaths.joinZNode(watcher.znodePaths.rsZNode, n);
String nodePath = ZNodePaths.joinZNode(watcher.getZNodePaths().rsZNode, n);
byte[] data = ZKUtil.getData(watcher, nodePath);
if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) {
int magicLen = ProtobufUtil.lengthOfPBMagic();
@ -114,7 +114,7 @@ public class RegionServerTracker extends ZKListener {
@Override
public void nodeCreated(String path) {
if (path.startsWith(watcher.znodePaths.rsZNode)) {
if (path.startsWith(watcher.getZNodePaths().rsZNode)) {
String serverName = ZKUtil.getNodeName(path);
LOG.info("RegionServer ephemeral node created, adding [" + serverName + "]");
if (server.isInitialized()) {
@ -127,7 +127,7 @@ public class RegionServerTracker extends ZKListener {
@Override
public void nodeDeleted(String path) {
if (path.startsWith(watcher.znodePaths.rsZNode)) {
if (path.startsWith(watcher.getZNodePaths().rsZNode)) {
String serverName = ZKUtil.getNodeName(path);
LOG.info("RegionServer ephemeral node deleted, processing expiration [" +
serverName + "]");
@ -144,11 +144,11 @@ public class RegionServerTracker extends ZKListener {
@Override
public void nodeChildrenChanged(String path) {
if (path.equals(watcher.znodePaths.rsZNode)
if (path.equals(watcher.getZNodePaths().rsZNode)
&& !server.isAborted() && !server.isStopped()) {
try {
List<String> servers =
ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.rsZNode);
ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().rsZNode);
refresh(servers);
} catch (IOException e) {
server.abort("Unexpected zk exception getting RS nodes", e);

View File

@ -551,7 +551,7 @@ public class ServerManager {
private List<String> getRegionServersInZK(final ZKWatcher zkw)
throws KeeperException {
return ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode);
return ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode);
}
/*

View File

@ -49,15 +49,15 @@ public class SplitOrMergeTracker {
public SplitOrMergeTracker(ZKWatcher watcher, Configuration conf,
Abortable abortable) {
try {
if (ZKUtil.checkExists(watcher, watcher.znodePaths.switchZNode) < 0) {
ZKUtil.createAndFailSilent(watcher, watcher.znodePaths.switchZNode);
if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().switchZNode) < 0) {
ZKUtil.createAndFailSilent(watcher, watcher.getZNodePaths().switchZNode);
}
} catch (KeeperException e) {
throw new RuntimeException(e);
}
splitZnode = ZNodePaths.joinZNode(watcher.znodePaths.switchZNode,
splitZnode = ZNodePaths.joinZNode(watcher.getZNodePaths().switchZNode,
conf.get("zookeeper.znode.switch.split", "split"));
mergeZnode = ZNodePaths.joinZNode(watcher.znodePaths.switchZNode,
mergeZnode = ZNodePaths.joinZNode(watcher.getZNodePaths().switchZNode,
conf.get("zookeeper.znode.switch.merge", "merge"));
splitStateTracker = new SwitchStateTracker(watcher, splitZnode, abortable);
mergeStateTracker = new SwitchStateTracker(watcher, mergeZnode, abortable);

View File

@ -68,7 +68,7 @@ public abstract class ClientZKSyncer extends ZKListener {
LOG.debug("Starting " + getClass().getSimpleName());
this.watcher.registerListener(this);
// create base znode on remote ZK
ZKUtil.createWithParents(clientZkWatcher, watcher.znodePaths.baseZNode);
ZKUtil.createWithParents(clientZkWatcher, watcher.getZNodePaths().baseZNode);
// set meta znodes for client ZK
Collection<String> nodes = getNodesToWatch();
LOG.debug("Znodes to watch: " + nodes);

View File

@ -35,7 +35,7 @@ public class MasterAddressSyncer extends ClientZKSyncer {
public MasterAddressSyncer(ZKWatcher watcher, ZKWatcher clientZkWatcher, Server server) {
super(watcher, clientZkWatcher, server);
masterAddressZNode = watcher.znodePaths.masterAddressZNode;
masterAddressZNode = watcher.getZNodePaths().masterAddressZNode;
}
@Override

View File

@ -36,11 +36,11 @@ public class MetaLocationSyncer extends ClientZKSyncer {
@Override
boolean validate(String path) {
return watcher.znodePaths.isAnyMetaReplicaZNode(path);
return watcher.getZNodePaths().isAnyMetaReplicaZNode(path);
}
@Override
Collection<String> getNodesToWatch() {
return watcher.znodePaths.metaReplicaZNodes.values();
return watcher.getZNodePaths().metaReplicaZNodes.values();
}
}

View File

@ -79,7 +79,7 @@ public abstract class ZKProcedureUtil
// make sure we are listening for events
watcher.registerListener(this);
// setup paths for the zknodes used in procedures
this.baseZNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, procDescription);
this.baseZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, procDescription);
acquiredZnode = ZNodePaths.joinZNode(baseZNode, ACQUIRED_BARRIER_ZNODE_DEFAULT);
reachedZnode = ZNodePaths.joinZNode(baseZNode, REACHED_BARRIER_ZNODE_DEFAULT);
abortZnode = ZNodePaths.joinZNode(baseZNode, ABORT_ZNODE_DEFAULT);

View File

@ -3507,7 +3507,7 @@ public class HRegionServer extends HasThread implements
}
private String getMyEphemeralNodePath() {
return ZNodePaths.joinZNode(this.zooKeeper.znodePaths.rsZNode, getServerName().toString());
return ZNodePaths.joinZNode(this.zooKeeper.getZNodePaths().rsZNode, getServerName().toString());
}
private boolean isHealthCheckerConfigured() {

View File

@ -155,7 +155,8 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
*/
protected static List<ServerName> fetchSlavesAddresses(ZKWatcher zkw)
throws KeeperException {
List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(zkw, zkw.znodePaths.rsZNode);
List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
zkw.getZNodePaths().rsZNode);
if (children == null) {
return Collections.emptyList();
}
@ -216,7 +217,7 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
public PeerRegionServerListener(HBaseReplicationEndpoint replicationPeer) {
super(replicationPeer.getZkw());
this.replicationEndpoint = replicationPeer;
this.regionServerListNode = replicationEndpoint.getZkw().znodePaths.rsZNode;
this.regionServerListNode = replicationEndpoint.getZkw().getZNodePaths().rsZNode;
}
@Override

View File

@ -97,7 +97,7 @@ public class ReplicationPeerConfigUpgrader{
@VisibleForTesting
protected String getTableCFsNode(String peerId) {
String replicationZNode = ZNodePaths.joinZNode(zookeeper.znodePaths.baseZNode,
String replicationZNode = ZNodePaths.joinZNode(zookeeper.getZNodePaths().baseZNode,
conf.get(REPLICATION_ZNODE, REPLICATION_ZNODE_DEFAULT));
String peersZNode =
ZNodePaths.joinZNode(replicationZNode, conf.get(PEERS_ZNODE, PEERS_ZNODE_DEFAULT));

View File

@ -67,7 +67,7 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable {
super(watcher);
this.authManager = authManager;
String aclZnodeParent = conf.get("zookeeper.znode.acl.parent", ACL_NODE);
this.aclZNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, aclZnodeParent);
this.aclZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, aclZnodeParent);
executor = Executors.newSingleThreadExecutor(
new DaemonThreadFactory("zk-permission-watcher"));
}
@ -260,7 +260,7 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable {
*/
public void writeToZookeeper(byte[] entry, byte[] permsData) {
String entryName = Bytes.toString(entry);
String zkNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE);
String zkNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, ACL_NODE);
zkNode = ZNodePaths.joinZNode(zkNode, entryName);
try {
@ -278,7 +278,7 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable {
* @param tableName
*/
public void deleteTableACLNode(final TableName tableName) {
String zkNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE);
String zkNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, ACL_NODE);
zkNode = ZNodePaths.joinZNode(zkNode, tableName.getNameAsString());
try {
@ -295,7 +295,7 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable {
* Delete the acl notify node of namespace
*/
public void deleteNamespaceACLNode(final String namespace) {
String zkNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE);
String zkNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, ACL_NODE);
zkNode = ZNodePaths.joinZNode(zkNode, AccessControlLists.NAMESPACE_PREFIX + namespace);
try {

View File

@ -54,7 +54,7 @@ public class ZKSecretWatcher extends ZKListener {
super(watcher);
this.secretManager = secretManager;
String keyZNodeParent = conf.get("zookeeper.znode.tokenauth.parent", DEFAULT_ROOT_NODE);
this.baseKeyZNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, keyZNodeParent);
this.baseKeyZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, keyZNodeParent);
this.keysParentZNode = ZNodePaths.joinZNode(baseKeyZNode, DEFAULT_KEYS_PARENT);
}

View File

@ -54,8 +54,9 @@ public class ZKVisibilityLabelWatcher extends ZKListener {
String labelZnodeParent = conf.get(VISIBILITY_LABEL_ZK_PATH, DEFAULT_VISIBILITY_LABEL_NODE);
String userAuthsZnodeParent = conf.get(VISIBILITY_USER_AUTHS_ZK_PATH,
DEFAULT_VISIBILITY_USER_AUTHS_NODE);
this.labelZnode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, labelZnodeParent);
this.userAuthsZnode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, userAuthsZnodeParent);
this.labelZnode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, labelZnodeParent);
this.userAuthsZnode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode,
userAuthsZnodeParent);
}
public void start() throws KeeperException {

View File

@ -722,7 +722,7 @@ public class HBaseFsck extends Configured implements Closeable {
private boolean setMasterInMaintenanceMode() throws IOException {
RetryCounter retryCounter = createZNodeRetryCounterFactory.create();
hbckEphemeralNodePath = ZNodePaths.joinZNode(
zkw.znodePaths.masterMaintZNode,
zkw.getZNodePaths().masterMaintZNode,
"hbck-" + Long.toString(EnvironmentEdgeManager.currentTime()));
do {
try {
@ -3672,7 +3672,7 @@ public class HBaseFsck extends Configured implements Closeable {
private void unassignMetaReplica(HbckInfo hi) throws IOException, InterruptedException,
KeeperException {
undeployRegions(hi);
ZKUtil.deleteNode(zkw, zkw.znodePaths.getZNodeForReplica(hi.metaEntry.getReplicaId()));
ZKUtil.deleteNode(zkw, zkw.getZNodePaths().getZNodeForReplica(hi.metaEntry.getReplicaId()));
}
private void assignMetaReplica(int replicaId)

View File

@ -60,7 +60,7 @@ public class ZKDataMigrator {
public static Map<TableName, TableState.State> queryForTableStates(ZKWatcher zkw)
throws KeeperException, InterruptedException {
Map<TableName, TableState.State> rv = new HashMap<>();
List<String> children = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.tableZNode);
List<String> children = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().tableZNode);
if (children == null)
return rv;
for (String child: children) {
@ -101,7 +101,8 @@ public class ZKDataMigrator {
private static ZooKeeperProtos.DeprecatedTableState.State getTableState(
final ZKWatcher zkw, final TableName tableName)
throws KeeperException, InterruptedException {
String znode = ZNodePaths.joinZNode(zkw.znodePaths.tableZNode, tableName.getNameAsString());
String znode = ZNodePaths.joinZNode(zkw.getZNodePaths().tableZNode,
tableName.getNameAsString());
byte [] data = ZKUtil.getData(zkw, znode);
if (data == null || data.length <= 0) return null;
try {

View File

@ -179,7 +179,7 @@ public class TestMetaWithReplicas {
for (int i = 1; i < 3; i++) {
String secZnode = ZNodePaths.joinZNode(baseZNode,
conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + i);
String str = zkw.znodePaths.getZNodeForReplica(i);
String str = zkw.getZNodePaths().getZNodeForReplica(i);
assertTrue(str.equals(secZnode));
// check that the data in the znode is parseable (this would also mean the znode exists)
data = ZKUtil.getData(zkw, secZnode);
@ -413,7 +413,7 @@ public class TestMetaWithReplicas {
HBaseFsckRepair.closeRegionSilentlyAndWait(c,
rl.getRegionLocation(2).getServerName(), rl.getRegionLocation(2).getRegionInfo());
ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
ZKUtil.deleteNode(zkw, zkw.znodePaths.getZNodeForReplica(2));
ZKUtil.deleteNode(zkw, zkw.getZNodePaths().getZNodeForReplica(2));
// check that problem exists
HBaseFsck hbck = doFsck(TEST_UTIL.getConfiguration(), false);
assertErrors(hbck, new ERROR_CODE[]{ERROR_CODE.UNKNOWN,ERROR_CODE.NO_META_REGION});

View File

@ -79,8 +79,8 @@ public class TestActiveMasterManager {
ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(),
"testActiveMasterManagerFromZK", null, true);
try {
ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode);
ZKUtil.deleteNode(zk, zk.znodePaths.clusterStateZNode);
ZKUtil.deleteNode(zk, zk.getZNodePaths().masterAddressZNode);
ZKUtil.deleteNode(zk, zk.getZNodePaths().clusterStateZNode);
} catch(KeeperException.NoNodeException nne) {}
// Create the master node with a dummy address
@ -121,8 +121,8 @@ public class TestActiveMasterManager {
ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(),
"testActiveMasterManagerFromZK", null, true);
try {
ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode);
ZKUtil.deleteNode(zk, zk.znodePaths.clusterStateZNode);
ZKUtil.deleteNode(zk, zk.getZNodePaths().masterAddressZNode);
ZKUtil.deleteNode(zk, zk.getZNodePaths().clusterStateZNode);
} catch(KeeperException.NoNodeException nne) {}
// Create the master node with a dummy address
@ -167,11 +167,12 @@ public class TestActiveMasterManager {
ms1.stop("stopping first server");
// Use a listener to capture when the node is actually deleted
NodeDeletionListener listener = new NodeDeletionListener(zk, zk.znodePaths.masterAddressZNode);
NodeDeletionListener listener = new NodeDeletionListener(zk,
zk.getZNodePaths().masterAddressZNode);
zk.registerListener(listener);
LOG.info("Deleting master node");
ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode);
ZKUtil.deleteNode(zk, zk.getZNodePaths().masterAddressZNode);
// Wait for the node to be deleted
LOG.info("Waiting for active master manager to be notified");
@ -191,7 +192,7 @@ public class TestActiveMasterManager {
assertTrue(t.isActiveMaster);
LOG.info("Deleting master node");
ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode);
ZKUtil.deleteNode(zk, zk.getZNodePaths().masterAddressZNode);
}
/**

View File

@ -72,7 +72,8 @@ public class TestHMasterRPCException {
testUtil.startMiniZKCluster();
ZKWatcher watcher = testUtil.getZooKeeperWatcher();
ZKUtil.createWithParents(watcher, watcher.znodePaths.masterAddressZNode, Bytes.toBytes("fake:123"));
ZKUtil.createWithParents(watcher, watcher.getZNodePaths().masterAddressZNode,
Bytes.toBytes("fake:123"));
master = new HMaster(conf);
rpcClient = RpcClientFactory.createClient(conf, HConstants.CLUSTER_ID_DEFAULT);
}
@ -109,7 +110,7 @@ public class TestHMasterRPCException {
LOG.info("Expected exception: ", ie);
if (!fakeZNodeDelete) {
testUtil.getZooKeeperWatcher().getRecoverableZooKeeper()
.delete(testUtil.getZooKeeperWatcher().znodePaths.masterAddressZNode, -1);
.delete(testUtil.getZooKeeperWatcher().getZNodePaths().masterAddressZNode, -1);
fakeZNodeDelete = true;
}
}

View File

@ -120,7 +120,7 @@ public class TestMasterNoCluster {
return false;
}
});
ZKUtil.deleteNodeRecursively(zkw, zkw.znodePaths.baseZNode);
ZKUtil.deleteNodeRecursively(zkw, zkw.getZNodePaths().baseZNode);
zkw.close();
}

View File

@ -102,7 +102,8 @@ public class TestMetaShutdownHandler {
// Delete the ephemeral node of the meta-carrying region server.
// This is trigger the expire of this region server on the master.
String rsEphemeralNodePath =
ZNodePaths.joinZNode(master.getZooKeeper().znodePaths.rsZNode, metaServerName.toString());
ZNodePaths.joinZNode(master.getZooKeeper().getZNodePaths().rsZNode,
metaServerName.toString());
ZKUtil.deleteNode(master.getZooKeeper(), rsEphemeralNodePath);
LOG.info("Deleted the znode for the RegionServer hosting hbase:meta; waiting on SSH");
// Wait for SSH to finish

View File

@ -82,7 +82,8 @@ public class TestMirroringTableStateManager {
private TableState.State getTableStateInZK(ZKWatcher watcher, final TableName tableName)
throws KeeperException, IOException, InterruptedException {
String znode = ZNodePaths.joinZNode(watcher.znodePaths.tableZNode, tableName.getNameAsString());
String znode = ZNodePaths.joinZNode(watcher.getZNodePaths().tableZNode,
tableName.getNameAsString());
byte [] data = ZKUtil.getData(watcher, znode);
if (data == null || data.length <= 0) {
return null;

View File

@ -127,13 +127,13 @@ public class TestSplitLogManager {
new ZKWatcher(conf, "split-log-manager-tests" + UUID.randomUUID().toString(), null);
master = new DummyMasterServices(zkw, conf);
ZKUtil.deleteChildrenRecursively(zkw, zkw.znodePaths.baseZNode);
ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.baseZNode);
assertTrue(ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) != -1);
LOG.debug(zkw.znodePaths.baseZNode + " created");
ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.splitLogZNode);
assertTrue(ZKUtil.checkExists(zkw, zkw.znodePaths.splitLogZNode) != -1);
LOG.debug(zkw.znodePaths.splitLogZNode + " created");
ZKUtil.deleteChildrenRecursively(zkw, zkw.getZNodePaths().baseZNode);
ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().baseZNode);
assertTrue(ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode) != -1);
LOG.debug(zkw.getZNodePaths().baseZNode + " created");
ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().splitLogZNode);
assertTrue(ZKUtil.checkExists(zkw, zkw.getZNodePaths().splitLogZNode) != -1);
LOG.debug(zkw.getZNodePaths().splitLogZNode + " created");
resetCounters();

View File

@ -87,7 +87,7 @@ public class TestMasterAddressTracker {
throws Exception {
ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(),
name.getMethodName(), null);
ZKUtil.createAndFailSilent(zk, zk.znodePaths.baseZNode);
ZKUtil.createAndFailSilent(zk, zk.getZNodePaths().baseZNode);
// Should not have a master yet
MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
@ -96,12 +96,14 @@ public class TestMasterAddressTracker {
zk.registerListener(addressTracker);
// Use a listener to capture when the node is actually created
NodeCreationListener listener = new NodeCreationListener(zk, zk.znodePaths.masterAddressZNode);
NodeCreationListener listener = new NodeCreationListener(zk,
zk.getZNodePaths().masterAddressZNode);
zk.registerListener(listener);
if (sn != null) {
LOG.info("Creating master node");
MasterAddressTracker.setMasterAddress(zk, zk.znodePaths.masterAddressZNode, sn, infoPort);
MasterAddressTracker.setMasterAddress(zk, zk.getZNodePaths().masterAddressZNode,
sn, infoPort);
// Wait for the node to be created
LOG.info("Waiting for master address manager to be notified");

View File

@ -106,7 +106,7 @@ public class TestRegionServerHostname {
TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
try {
ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode);
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode);
// there would be NUM_RS+1 children - one for the master
assertTrue(servers.size() ==
NUM_RS + (LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration())? 1: 0));
@ -167,7 +167,7 @@ public class TestRegionServerHostname {
boolean tablesOnMaster = LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration());
int expectedRS = NUM_RS + (tablesOnMaster? 1: 0);
try (ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher()) {
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode);
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode);
assertEquals(expectedRS, servers.size());
}
}

View File

@ -204,16 +204,16 @@ public class TestSplitLogWorker {
zkw = new ZKWatcher(TEST_UTIL.getConfiguration(),
"split-log-worker-tests", null);
ds = new DummyServer(zkw, conf);
ZKUtil.deleteChildrenRecursively(zkw, zkw.znodePaths.baseZNode);
ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.baseZNode);
assertThat(ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode), not (is(-1)));
LOG.debug(zkw.znodePaths.baseZNode + " created");
ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.splitLogZNode);
assertThat(ZKUtil.checkExists(zkw, zkw.znodePaths.splitLogZNode), not (is(-1)));
ZKUtil.deleteChildrenRecursively(zkw, zkw.getZNodePaths().baseZNode);
ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().baseZNode);
assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode), not(is(-1)));
LOG.debug(zkw.getZNodePaths().baseZNode + " created");
ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().splitLogZNode);
assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().splitLogZNode), not(is(-1)));
LOG.debug(zkw.znodePaths.splitLogZNode + " created");
ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.rsZNode);
assertThat(ZKUtil.checkExists(zkw, zkw.znodePaths.rsZNode), not (is(-1)));
LOG.debug(zkw.getZNodePaths().splitLogZNode + " created");
ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().rsZNode);
assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().rsZNode), not(is(-1)));
SplitLogCounters.resetCounters();
executorService = new ExecutorService("TestSplitLogWorker");
@ -430,7 +430,7 @@ public class TestSplitLogWorker {
waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 1, 2, WAIT_TIME);
waitForCounter(SplitLogCounters.tot_wkr_task_acquired_rescan, 0, 1, WAIT_TIME);
List<String> nodes = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.splitLogZNode);
List<String> nodes = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().splitLogZNode);
LOG.debug(Objects.toString(nodes));
int num = 0;
for (String node : nodes) {
@ -438,7 +438,8 @@ public class TestSplitLogWorker {
if (node.startsWith("RESCAN")) {
String name = ZKSplitLog.getEncodedNodeName(zkw, node);
String fn = ZKSplitLog.getFileName(name);
byte [] data = ZKUtil.getData(zkw, ZNodePaths.joinZNode(zkw.znodePaths.splitLogZNode, fn));
byte [] data = ZKUtil.getData(zkw,
ZNodePaths.joinZNode(zkw.getZNodePaths().splitLogZNode, fn));
slt = SplitLogTask.parseFrom(data);
assertTrue(slt.toString(), slt.isDone(SRV));
}
@ -494,9 +495,9 @@ public class TestSplitLogWorker {
RegionServerServices mockedRS = getRegionServer(RS);
// create two RS nodes
String rsPath = ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, RS.getServerName());
String rsPath = ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, RS.getServerName());
zkw.getRecoverableZooKeeper().create(rsPath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
rsPath = ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, RS2.getServerName());
rsPath = ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, RS2.getServerName());
zkw.getRecoverableZooKeeper().create(rsPath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
for (int i = 0; i < maxTasks; i++) {

View File

@ -83,13 +83,14 @@ public class TestReplicationTrackerZKImpl {
utility.startMiniZKCluster();
conf = utility.getConfiguration();
ZKWatcher zk = HBaseTestingUtility.getZooKeeperWatcher(utility);
ZKUtil.createWithParents(zk, zk.znodePaths.rsZNode);
ZKUtil.createWithParents(zk, zk.getZNodePaths().rsZNode);
}
@Before
public void setUp() throws Exception {
zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
String fakeRs1 = ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234");
String fakeRs1 = ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode,
"hostname1.example.org:1234");
try {
ZKClusterId.setClusterId(zkw, new ClusterId());
rp = ReplicationFactory.getReplicationPeers(zkw, conf);
@ -115,34 +116,34 @@ public class TestReplicationTrackerZKImpl {
// 1 region server
ZKUtil.createWithParents(zkw,
ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234"));
ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname1.example.org:1234"));
assertEquals(1, rt.getListOfRegionServers().size());
// 2 region servers
ZKUtil.createWithParents(zkw,
ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"));
ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname2.example.org:1234"));
assertEquals(2, rt.getListOfRegionServers().size());
// 1 region server
ZKUtil.deleteNode(zkw,
ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"));
ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname2.example.org:1234"));
assertEquals(1, rt.getListOfRegionServers().size());
// 0 region server
ZKUtil.deleteNode(zkw,
ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234"));
ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname1.example.org:1234"));
assertEquals(0, rt.getListOfRegionServers().size());
}
@Test
public void testRegionServerRemovedEvent() throws Exception {
ZKUtil.createAndWatch(zkw,
ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"),
ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname2.example.org:1234"),
HConstants.EMPTY_BYTE_ARRAY);
rt.registerListener(new DummyReplicationListener());
// delete one
ZKUtil.deleteNode(zkw,
ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"));
ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname2.example.org:1234"));
// wait for event
while (rsRemovedCount.get() < 1) {
Thread.sleep(5);

View File

@ -91,6 +91,13 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>warbucks-maven-plugin</artifactId>

View File

@ -48,7 +48,7 @@ public class ClusterStatusTracker extends ZKNodeTracker {
* @param abortable used to abort if a fatal error occurs
*/
public ClusterStatusTracker(ZKWatcher watcher, Abortable abortable) {
super(watcher, watcher.znodePaths.clusterStateZNode, abortable);
super(watcher, watcher.getZNodePaths().clusterStateZNode, abortable);
}
/**
@ -65,12 +65,12 @@ public class ClusterStatusTracker extends ZKNodeTracker {
* @throws KeeperException unexpected zk exception
*/
public void setClusterUp()
throws KeeperException {
throws KeeperException {
byte [] upData = toByteArray();
try {
ZKUtil.createAndWatch(watcher, watcher.znodePaths.clusterStateZNode, upData);
ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().clusterStateZNode, upData);
} catch(KeeperException.NodeExistsException nee) {
ZKUtil.setData(watcher, watcher.znodePaths.clusterStateZNode, upData);
ZKUtil.setData(watcher, watcher.getZNodePaths().clusterStateZNode, upData);
}
}
@ -79,12 +79,12 @@ public class ClusterStatusTracker extends ZKNodeTracker {
* @throws KeeperException unexpected zk exception
*/
public void setClusterDown()
throws KeeperException {
throws KeeperException {
try {
ZKUtil.deleteNode(watcher, watcher.znodePaths.clusterStateZNode);
ZKUtil.deleteNode(watcher, watcher.getZNodePaths().clusterStateZNode);
} catch(KeeperException.NoNodeException nne) {
LOG.warn("Attempted to set cluster as down but already down, cluster " +
"state node (" + watcher.znodePaths.clusterStateZNode + ") not found");
"state node (" + watcher.getZNodePaths().clusterStateZNode + ") not found");
}
}

View File

@ -39,7 +39,7 @@ public class LoadBalancerTracker extends ZKNodeTracker {
public LoadBalancerTracker(ZKWatcher watcher,
Abortable abortable) {
super(watcher, watcher.znodePaths.balancerZNode, abortable);
super(watcher, watcher.getZNodePaths().balancerZNode, abortable);
}
/**
@ -67,11 +67,11 @@ public class LoadBalancerTracker extends ZKNodeTracker {
byte [] upData = toByteArray(balancerOn);
try {
ZKUtil.setData(watcher, watcher.znodePaths.balancerZNode, upData);
ZKUtil.setData(watcher, watcher.getZNodePaths().balancerZNode, upData);
} catch(KeeperException.NoNodeException nne) {
ZKUtil.createAndWatch(watcher, watcher.znodePaths.balancerZNode, upData);
ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().balancerZNode, upData);
}
super.nodeDataChanged(watcher.znodePaths.balancerZNode);
super.nodeDataChanged(watcher.getZNodePaths().balancerZNode);
}
private byte [] toByteArray(boolean isBalancerOn) {
@ -82,7 +82,7 @@ public class LoadBalancerTracker extends ZKNodeTracker {
}
private LoadBalancerProtos.LoadBalancerState parseFrom(byte [] pbBytes)
throws DeserializationException {
throws DeserializationException {
ProtobufUtil.expectPBMagicPrefix(pbBytes);
LoadBalancerProtos.LoadBalancerState.Builder builder =
LoadBalancerProtos.LoadBalancerState.newBuilder();

View File

@ -65,7 +65,7 @@ public class MasterAddressTracker extends ZKNodeTracker {
* @param abortable abortable in case of fatal error
*/
public MasterAddressTracker(ZKWatcher watcher, Abortable abortable) {
super(watcher, watcher.znodePaths.masterAddressZNode, abortable);
super(watcher, watcher.getZNodePaths().masterAddressZNode, abortable);
}
/**
@ -101,7 +101,7 @@ public class MasterAddressTracker extends ZKNodeTracker {
* @return info port or 0 if timed out or exceptions
*/
public int getBackupMasterInfoPort(final ServerName sn) {
String backupZNode = ZNodePaths.joinZNode(watcher.znodePaths.backupMasterAddressesZNode,
String backupZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().backupMasterAddressesZNode,
sn.toString());
try {
byte[] data = ZKUtil.getData(watcher, backupZNode);
@ -147,7 +147,7 @@ public class MasterAddressTracker extends ZKNodeTracker {
throws KeeperException, IOException {
byte [] data;
try {
data = ZKUtil.getData(zkw, zkw.znodePaths.masterAddressZNode);
data = ZKUtil.getData(zkw, zkw.getZNodePaths().masterAddressZNode);
} catch (InterruptedException e) {
throw new InterruptedIOException();
}
@ -178,7 +178,7 @@ public class MasterAddressTracker extends ZKNodeTracker {
public static int getMasterInfoPort(final ZKWatcher zkw) throws KeeperException, IOException {
byte[] data;
try {
data = ZKUtil.getData(zkw, zkw.znodePaths.masterAddressZNode);
data = ZKUtil.getData(zkw, zkw.getZNodePaths().masterAddressZNode);
} catch (InterruptedException e) {
throw new InterruptedIOException();
}
@ -208,7 +208,7 @@ public class MasterAddressTracker extends ZKNodeTracker {
*/
public static boolean setMasterAddress(final ZKWatcher zkw,
final String znode, final ServerName master, int infoPort)
throws KeeperException {
throws KeeperException {
return ZKUtil.createEphemeralNodeAndWatch(zkw, znode, toByteArray(master, infoPort));
}
@ -265,10 +265,10 @@ public class MasterAddressTracker extends ZKNodeTracker {
try {
Stat stat = new Stat();
byte[] data = ZKUtil.getDataNoWatch(zkw, zkw.znodePaths.masterAddressZNode, stat);
byte[] data = ZKUtil.getDataNoWatch(zkw, zkw.getZNodePaths().masterAddressZNode, stat);
ServerName sn = ProtobufUtil.parseServerNameFrom(data);
if (sn != null && content.equals(sn.toString())) {
return (ZKUtil.deleteNode(zkw, zkw.znodePaths.masterAddressZNode, stat.getVersion()));
return (ZKUtil.deleteNode(zkw, zkw.getZNodePaths().masterAddressZNode, stat.getVersion()));
}
} catch (KeeperException e) {
LOG.warn("Can't get or delete the master znode", e);

View File

@ -40,7 +40,7 @@ public class MasterMaintenanceModeTracker extends ZKListener {
}
private void update(String path) {
if (path.startsWith(watcher.znodePaths.masterMaintZNode)) {
if (path.startsWith(watcher.getZNodePaths().masterMaintZNode)) {
update();
}
}
@ -48,7 +48,8 @@ public class MasterMaintenanceModeTracker extends ZKListener {
private void update() {
try {
List<String> children =
ZKUtil.listChildrenAndWatchForNewChildren(watcher, watcher.znodePaths.masterMaintZNode);
ZKUtil.listChildrenAndWatchForNewChildren(watcher,
watcher.getZNodePaths().masterMaintZNode);
hasChildren = (children != null && children.size() > 0);
} catch (KeeperException e) {
// Ignore the ZK keeper exception

View File

@ -191,7 +191,7 @@ public class MetaTableLocator {
* @throws NotAllMetaRegionsOnlineException if a meta or root region is not online
*/
public ServerName waitMetaRegionLocation(ZKWatcher zkw, long timeout)
throws InterruptedException, NotAllMetaRegionsOnlineException {
throws InterruptedException, NotAllMetaRegionsOnlineException {
return waitMetaRegionLocation(zkw, RegionInfo.DEFAULT_REPLICA_ID, timeout);
}
@ -209,9 +209,9 @@ public class MetaTableLocator {
* @throws NotAllMetaRegionsOnlineException if a meta or root region is not online
*/
public ServerName waitMetaRegionLocation(ZKWatcher zkw, int replicaId, long timeout)
throws InterruptedException, NotAllMetaRegionsOnlineException {
throws InterruptedException, NotAllMetaRegionsOnlineException {
try {
if (ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) == -1) {
if (ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode) == -1) {
String errorMsg = "Check the value configured in 'zookeeper.znode.parent'. "
+ "There could be a mismatch with the one configured in the master.";
LOG.error(errorMsg);
@ -388,7 +388,7 @@ public class MetaTableLocator {
service = connection.getAdmin(sn);
} catch (RetriesExhaustedException e) {
if (e.getCause() != null && e.getCause() instanceof ConnectException) {
// Catch this; presume it means the cached connection has gone bad.
LOG.debug("Catch this; presume it means the cached connection has gone bad.");
} else {
throw e;
}
@ -407,12 +407,12 @@ public class MetaTableLocator {
} catch (IOException ioe) {
Throwable cause = ioe.getCause();
if (ioe instanceof ConnectException) {
// Catch. Connect refused.
LOG.debug("Catch. Connect refused.");
} else if (cause != null && cause instanceof EOFException) {
// Catch. Other end disconnected us.
LOG.debug("Catch. Other end disconnected us.");
} else if (cause != null && cause.getMessage() != null &&
cause.getMessage().toLowerCase(Locale.ROOT).contains("connection reset")) {
// Catch. Connection reset.
LOG.debug("Catch. Connection reset.");
} else {
throw ioe;
}
@ -460,7 +460,7 @@ public class MetaTableLocator {
byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray());
try {
ZKUtil.setData(zookeeper,
zookeeper.znodePaths.getZNodeForReplica(replicaId), data);
zookeeper.getZNodePaths().getZNodeForReplica(replicaId), data);
} catch(KeeperException.NoNodeException nne) {
if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) {
LOG.debug("META region location doesn't exist, create it");
@ -468,7 +468,8 @@ public class MetaTableLocator {
LOG.debug("META region location doesn't exist for replicaId=" + replicaId +
", create it");
}
ZKUtil.createAndWatch(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId), data);
ZKUtil.createAndWatch(zookeeper, zookeeper.getZNodePaths().getZNodeForReplica(replicaId),
data);
}
}
@ -492,7 +493,7 @@ public class MetaTableLocator {
RegionState.State state = RegionState.State.OPEN;
ServerName serverName = null;
try {
byte[] data = ZKUtil.getData(zkw, zkw.znodePaths.getZNodeForReplica(replicaId));
byte[] data = ZKUtil.getData(zkw, zkw.getZNodePaths().getZNodeForReplica(replicaId));
if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) {
try {
int prefixLen = ProtobufUtil.lengthOfPBMagic();
@ -532,12 +533,12 @@ public class MetaTableLocator {
* @throws KeeperException unexpected zookeeper exception
*/
public void deleteMetaLocation(ZKWatcher zookeeper)
throws KeeperException {
throws KeeperException {
deleteMetaLocation(zookeeper, RegionInfo.DEFAULT_REPLICA_ID);
}
public void deleteMetaLocation(ZKWatcher zookeeper, int replicaId)
throws KeeperException {
throws KeeperException {
if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) {
LOG.info("Deleting hbase:meta region location in ZooKeeper");
} else {
@ -545,7 +546,7 @@ public class MetaTableLocator {
}
try {
// Just delete the node. Don't need any watches.
ZKUtil.deleteNode(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId));
ZKUtil.deleteNode(zookeeper, zookeeper.getZNodePaths().getZNodeForReplica(replicaId));
} catch(KeeperException.NoNodeException nne) {
// Has already been deleted
}

View File

@ -85,7 +85,7 @@ public class RecoverableZooKeeper {
public RecoverableZooKeeper(String quorumServers, int sessionTimeout,
Watcher watcher, int maxRetries, int retryIntervalMillis, int maxSleepTime)
throws IOException {
throws IOException {
this(quorumServers, sessionTimeout, watcher, maxRetries, retryIntervalMillis, maxSleepTime,
null);
}
@ -94,7 +94,7 @@ public class RecoverableZooKeeper {
justification="None. Its always been this way.")
public RecoverableZooKeeper(String quorumServers, int sessionTimeout,
Watcher watcher, int maxRetries, int retryIntervalMillis, int maxSleepTime, String identifier)
throws IOException {
throws IOException {
// TODO: Add support for zk 'chroot'; we don't add it to the quorumServers String as we should.
this.retryCounterFactory =
new RetryCounterFactory(maxRetries+1, retryIntervalMillis, maxSleepTime);
@ -300,7 +300,7 @@ public class RecoverableZooKeeper {
* @return List of children znodes
*/
public List<String> getChildren(String path, boolean watch)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.getChildren")) {
RetryCounter retryCounter = retryCounterFactory.create();
while (true) {
@ -331,7 +331,7 @@ public class RecoverableZooKeeper {
* @return Data
*/
public byte[] getData(String path, Watcher watcher, Stat stat)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.getData")) {
RetryCounter retryCounter = retryCounterFactory.create();
while (true) {
@ -362,7 +362,7 @@ public class RecoverableZooKeeper {
* @return Data
*/
public byte[] getData(String path, boolean watch, Stat stat)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.getData")) {
RetryCounter retryCounter = retryCounterFactory.create();
while (true) {
@ -395,7 +395,7 @@ public class RecoverableZooKeeper {
* @return Stat instance
*/
public Stat setData(String path, byte[] data, int version)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.setData")) {
RetryCounter retryCounter = retryCounterFactory.create();
byte[] newData = ZKMetadata.appendMetaData(id, data);
@ -445,7 +445,7 @@ public class RecoverableZooKeeper {
* @return list of ACLs
*/
public List<ACL> getAcl(String path, Stat stat)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.getAcl")) {
RetryCounter retryCounter = retryCounterFactory.create();
while (true) {
@ -476,7 +476,7 @@ public class RecoverableZooKeeper {
* @return list of ACLs
*/
public Stat setAcl(String path, List<ACL> acls, int version)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.setAcl")) {
RetryCounter retryCounter = retryCounterFactory.create();
while (true) {
@ -519,7 +519,7 @@ public class RecoverableZooKeeper {
*/
public String create(String path, byte[] data, List<ACL> acl,
CreateMode createMode)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.create")) {
byte[] newData = ZKMetadata.appendMetaData(id, data);
switch (createMode) {
@ -587,7 +587,7 @@ public class RecoverableZooKeeper {
private String createSequential(String path, byte[] data,
List<ACL> acl, CreateMode createMode)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
RetryCounter retryCounter = retryCounterFactory.create();
boolean first = true;
String newPath = path+this.identifier;
@ -653,7 +653,7 @@ public class RecoverableZooKeeper {
* Run multiple operations in a transactional manner. Retry before throwing exception
*/
public List<OpResult> multi(Iterable<Op> ops)
throws KeeperException, InterruptedException {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.multi")) {
RetryCounter retryCounter = retryCounterFactory.create();
Iterable<Op> multiOps = prepareZKMulti(ops);

View File

@ -38,7 +38,7 @@ public class RegionNormalizerTracker extends ZKNodeTracker {
private static final Logger LOG = LoggerFactory.getLogger(RegionNormalizerTracker.class);
public RegionNormalizerTracker(ZKWatcher watcher, Abortable abortable) {
super(watcher, watcher.znodePaths.regionNormalizerZNode, abortable);
super(watcher, watcher.getZNodePaths().regionNormalizerZNode, abortable);
}
/**
@ -65,11 +65,11 @@ public class RegionNormalizerTracker extends ZKNodeTracker {
public void setNormalizerOn(boolean normalizerOn) throws KeeperException {
byte [] upData = toByteArray(normalizerOn);
try {
ZKUtil.setData(watcher, watcher.znodePaths.regionNormalizerZNode, upData);
ZKUtil.setData(watcher, watcher.getZNodePaths().regionNormalizerZNode, upData);
} catch(KeeperException.NoNodeException nne) {
ZKUtil.createAndWatch(watcher, watcher.znodePaths.regionNormalizerZNode, upData);
ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().regionNormalizerZNode, upData);
}
super.nodeDataChanged(watcher.znodePaths.regionNormalizerZNode);
super.nodeDataChanged(watcher.getZNodePaths().regionNormalizerZNode);
}
private byte [] toByteArray(boolean isNormalizerOn) {

View File

@ -70,8 +70,8 @@ public class ZKAclReset extends Configured implements Tool {
ZKWatcher zkw = new ZKWatcher(conf, "ZKAclReset", null);
try {
LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for " +
zkw.getQuorum() + " " + zkw.znodePaths.baseZNode);
resetAcls(zkw, zkw.znodePaths.baseZNode, eraseAcls);
zkw.getQuorum() + " " + zkw.getZNodePaths().baseZNode);
resetAcls(zkw, zkw.getZNodePaths().baseZNode, eraseAcls);
} finally {
zkw.close();
}

View File

@ -61,11 +61,11 @@ public class ZKClusterId {
}
public static String readClusterIdZNode(ZKWatcher watcher)
throws KeeperException {
if (ZKUtil.checkExists(watcher, watcher.znodePaths.clusterIdZNode) != -1) {
throws KeeperException {
if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().clusterIdZNode) != -1) {
byte [] data;
try {
data = ZKUtil.getData(watcher, watcher.znodePaths.clusterIdZNode);
data = ZKUtil.getData(watcher, watcher.getZNodePaths().clusterIdZNode);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return null;
@ -83,7 +83,7 @@ public class ZKClusterId {
public static void setClusterId(ZKWatcher watcher, ClusterId id)
throws KeeperException {
ZKUtil.createSetData(watcher, watcher.znodePaths.clusterIdZNode, id.toByteArray());
ZKUtil.createSetData(watcher, watcher.getZNodePaths().clusterIdZNode, id.toByteArray());
}
/**

View File

@ -46,7 +46,7 @@ public class ZKMainServer {
*/
private static class HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain extends ZooKeeperMain {
public HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(String[] args)
throws IOException, InterruptedException {
throws IOException, InterruptedException {
super(args);
// Make sure we are connected before we proceed. Can take a while on some systems. If we
// run the command without being connected, we get ConnectionLoss KeeperErrorConnection...
@ -57,9 +57,9 @@ public class ZKMainServer {
/**
* Run the command-line args passed. Calls System.exit when done.
* @throws KeeperException
* @throws IOException
* @throws InterruptedException
* @throws KeeperException if an unexpected ZooKeeper exception happens
* @throws IOException in case of a network failure
* @throws InterruptedException if the ZooKeeper client closes
*/
void runCmdLine() throws KeeperException, IOException, InterruptedException {
processCmd(this.cl);

View File

@ -102,7 +102,7 @@ public abstract class ZKNodeTracker extends ZKListener {
* @throws InterruptedException if the waiting thread is interrupted
*/
public synchronized byte [] blockUntilAvailable()
throws InterruptedException {
throws InterruptedException {
return blockUntilAvailable(0, false);
}
@ -238,11 +238,11 @@ public abstract class ZKNodeTracker extends ZKListener {
*/
public boolean checkIfBaseNodeAvailable() {
try {
if (ZKUtil.checkExists(watcher, watcher.znodePaths.baseZNode) == -1) {
if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().baseZNode) == -1) {
return false;
}
} catch (KeeperException e) {
abortable.abort("Exception while checking if basenode (" + watcher.znodePaths.baseZNode
abortable.abort("Exception while checking if basenode (" + watcher.getZNodePaths().baseZNode
+ ") exists in ZooKeeper.",
e);
}

View File

@ -47,7 +47,7 @@ public final class ZKSplitLog {
* @param filename log file name (only the basename)
*/
public static String getEncodedNodeName(ZKWatcher zkw, String filename) {
return ZNodePaths.joinZNode(zkw.znodePaths.splitLogZNode, encode(filename));
return ZNodePaths.joinZNode(zkw.getZNodePaths().splitLogZNode, encode(filename));
}
public static String getFileName(String node) {
@ -72,7 +72,7 @@ public final class ZKSplitLog {
}
public static String getRescanNode(ZKWatcher zkw) {
return ZNodePaths.joinZNode(zkw.znodePaths.splitLogZNode, "RESCAN");
return ZNodePaths.joinZNode(zkw.getZNodePaths().splitLogZNode, "RESCAN");
}
/**

View File

@ -108,20 +108,20 @@ public final class ZKUtil {
* @throws IOException if unable to connect to zk or config problem
*/
public static RecoverableZooKeeper connect(Configuration conf, Watcher watcher)
throws IOException {
throws IOException {
String ensemble = ZKConfig.getZKQuorumServersString(conf);
return connect(conf, ensemble, watcher);
}
public static RecoverableZooKeeper connect(Configuration conf, String ensemble,
Watcher watcher)
throws IOException {
throws IOException {
return connect(conf, ensemble, watcher, null);
}
public static RecoverableZooKeeper connect(Configuration conf, String ensemble,
Watcher watcher, final String identifier)
throws IOException {
throws IOException {
if(ensemble == null) {
throw new IOException("Unable to determine ZooKeeper ensemble");
}
@ -347,7 +347,7 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static boolean watchAndCheckExists(ZKWatcher zkw, String znode)
throws KeeperException {
throws KeeperException {
try {
Stat s = zkw.getRecoverableZooKeeper().exists(znode, zkw);
boolean exists = s != null ? true : false;
@ -401,7 +401,7 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static int checkExists(ZKWatcher zkw, String znode)
throws KeeperException {
throws KeeperException {
try {
Stat s = zkw.getRecoverableZooKeeper().exists(znode, null);
return s != null ? s.getVersion() : -1;
@ -438,7 +438,7 @@ public final class ZKUtil {
*/
public static List<String> listChildrenAndWatchForNewChildren(
ZKWatcher zkw, String znode)
throws KeeperException {
throws KeeperException {
try {
List<String> children = zkw.getRecoverableZooKeeper().getChildren(znode, zkw);
return children;
@ -493,7 +493,7 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static List<String> listChildrenNoWatch(ZKWatcher zkw, String znode)
throws KeeperException {
throws KeeperException {
List<String> children = null;
try {
// List the children without watching
@ -550,7 +550,7 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static boolean nodeHasChildren(ZKWatcher zkw, String znode)
throws KeeperException {
throws KeeperException {
try {
return !zkw.getRecoverableZooKeeper().getChildren(znode, null).isEmpty();
} catch(KeeperException.NoNodeException ke) {
@ -582,7 +582,7 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static int getNumberOfChildren(ZKWatcher zkw, String znode)
throws KeeperException {
throws KeeperException {
try {
Stat stat = zkw.getRecoverableZooKeeper().exists(znode, null);
return stat == null ? 0 : stat.getNumChildren();
@ -633,7 +633,7 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static byte [] getDataAndWatch(ZKWatcher zkw, String znode)
throws KeeperException {
throws KeeperException {
return getDataInternal(zkw, znode, null, true);
}
@ -695,7 +695,7 @@ public final class ZKUtil {
*/
public static byte [] getDataNoWatch(ZKWatcher zkw, String znode,
Stat stat)
throws KeeperException {
throws KeeperException {
try {
byte [] data = zkw.getRecoverableZooKeeper().getData(znode, null, stat);
logRetrievedMsg(zkw, znode, data, false);
@ -801,7 +801,7 @@ public final class ZKUtil {
*/
public static boolean setData(ZKWatcher zkw, String znode,
byte [] data, int expectedVersion)
throws KeeperException, KeeperException.NoNodeException {
throws KeeperException, KeeperException.NoNodeException {
try {
return zkw.getRecoverableZooKeeper().setData(znode, data, expectedVersion) != null;
} catch (InterruptedException e) {
@ -845,12 +845,12 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static void setData(ZKWatcher zkw, String znode, byte [] data)
throws KeeperException, KeeperException.NoNodeException {
throws KeeperException, KeeperException.NoNodeException {
setData(zkw, (SetData)ZKUtilOp.setData(znode, data));
}
private static void setData(ZKWatcher zkw, SetData setData)
throws KeeperException, KeeperException.NoNodeException {
throws KeeperException, KeeperException.NoNodeException {
SetDataRequest sd = (SetDataRequest)toZooKeeperOp(zkw, setData).toRequestRecord();
setData(zkw, sd.getPath(), sd.getData(), sd.getVersion());
}
@ -891,7 +891,7 @@ public final class ZKUtil {
public static ArrayList<ACL> createACL(ZKWatcher zkw, String node,
boolean isSecureZooKeeper) {
if (!node.startsWith(zkw.znodePaths.baseZNode)) {
if (!node.startsWith(zkw.getZNodePaths().baseZNode)) {
return Ids.OPEN_ACL_UNSAFE;
}
if (isSecureZooKeeper) {
@ -923,7 +923,7 @@ public final class ZKUtil {
}
// Certain znodes are accessed directly by the client,
// so they must be readable by non-authenticated clients
if (zkw.znodePaths.isClientReadable(node)) {
if (zkw.getZNodePaths().isClientReadable(node)) {
acls.addAll(Ids.CREATOR_ALL_ACL);
acls.addAll(Ids.READ_ACL_UNSAFE);
} else {
@ -959,7 +959,7 @@ public final class ZKUtil {
*/
public static boolean createEphemeralNodeAndWatch(ZKWatcher zkw,
String znode, byte [] data)
throws KeeperException {
throws KeeperException {
boolean ret = true;
try {
zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
@ -999,7 +999,7 @@ public final class ZKUtil {
*/
public static boolean createNodeIfNotExistsAndWatch(
ZKWatcher zkw, String znode, byte [] data)
throws KeeperException {
throws KeeperException {
boolean ret = true;
try {
zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
@ -1066,7 +1066,7 @@ public final class ZKUtil {
*/
public static int createAndWatch(ZKWatcher zkw,
String znode, byte [] data)
throws KeeperException, KeeperException.NodeExistsException {
throws KeeperException, KeeperException.NodeExistsException {
try {
zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
CreateMode.PERSISTENT);
@ -1132,13 +1132,13 @@ public final class ZKUtil {
*/
public static void createAndFailSilent(ZKWatcher zkw,
String znode, byte[] data)
throws KeeperException {
throws KeeperException {
createAndFailSilent(zkw,
(CreateAndFailSilent)ZKUtilOp.createAndFailSilent(znode, data));
}
private static void createAndFailSilent(ZKWatcher zkw, CreateAndFailSilent cafs)
throws KeeperException {
throws KeeperException {
CreateRequest create = (CreateRequest)toZooKeeperOp(zkw, cafs).toRequestRecord();
String znode = create.getPath();
try {
@ -1173,7 +1173,7 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static void createWithParents(ZKWatcher zkw, String znode)
throws KeeperException {
throws KeeperException {
createWithParents(zkw, znode, new byte[0]);
}
@ -1191,7 +1191,7 @@ public final class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static void createWithParents(ZKWatcher zkw, String znode, byte[] data)
throws KeeperException {
throws KeeperException {
try {
if(znode == null) {
return;
@ -1216,7 +1216,7 @@ public final class ZKUtil {
* Delete the specified node. Sets no watches. Throws all exceptions.
*/
public static void deleteNode(ZKWatcher zkw, String node)
throws KeeperException {
throws KeeperException {
deleteNode(zkw, node, -1);
}
@ -1226,7 +1226,7 @@ public final class ZKUtil {
*/
public static boolean deleteNode(ZKWatcher zkw, String node,
int version)
throws KeeperException {
throws KeeperException {
try {
zkw.getRecoverableZooKeeper().delete(node, version);
return true;
@ -1246,7 +1246,7 @@ public final class ZKUtil {
* @throws KeeperException if a ZooKeeper operation fails
*/
public static void deleteNodeFailSilent(ZKWatcher zkw, String node)
throws KeeperException {
throws KeeperException {
deleteNodeFailSilent(zkw,
(DeleteNodeFailSilent)ZKUtilOp.deleteNodeFailSilent(node));
}
@ -1272,7 +1272,7 @@ public final class ZKUtil {
* children.
*/
public static void deleteNodeRecursively(ZKWatcher zkw, String node)
throws KeeperException {
throws KeeperException {
deleteNodeRecursivelyMultiOrSequential(zkw, true, node);
}
@ -1735,7 +1735,7 @@ public final class ZKUtil {
public static String dump(ZKWatcher zkw) {
StringBuilder sb = new StringBuilder();
try {
sb.append("HBase is rooted at ").append(zkw.znodePaths.baseZNode);
sb.append("HBase is rooted at ").append(zkw.getZNodePaths().baseZNode);
sb.append("\nActive master address: ");
try {
sb.append(MasterAddressTracker.getMasterAddress(zkw));
@ -1743,7 +1743,8 @@ public final class ZKUtil {
sb.append("<<FAILED LOOKUP: " + e.getMessage() + ">>");
}
sb.append("\nBackup master addresses:");
for (String child : listChildrenNoWatch(zkw, zkw.znodePaths.backupMasterAddressesZNode)) {
for (String child : listChildrenNoWatch(zkw,
zkw.getZNodePaths().backupMasterAddressesZNode)) {
sb.append("\n ").append(child);
}
sb.append("\nRegion server holding hbase:meta: "
@ -1756,7 +1757,7 @@ public final class ZKUtil {
+ new MetaTableLocator().getMetaRegionLocation(zkw, i));
}
sb.append("\nRegion servers:");
for (String child : listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode)) {
for (String child : listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode)) {
sb.append("\n ").append(child);
}
try {
@ -1799,7 +1800,7 @@ public final class ZKUtil {
*/
private static void getReplicationZnodesDump(ZKWatcher zkw, StringBuilder sb)
throws KeeperException {
String replicationZnode = zkw.znodePaths.replicationZNode;
String replicationZnode = zkw.getZNodePaths().replicationZNode;
if (ZKUtil.checkExists(zkw, replicationZnode) == -1) {
return;
@ -1810,11 +1811,11 @@ public final class ZKUtil {
List<String> children = ZKUtil.listChildrenNoWatch(zkw, replicationZnode);
for (String child : children) {
String znode = ZNodePaths.joinZNode(replicationZnode, child);
if (znode.equals(zkw.znodePaths.peersZNode)) {
if (znode.equals(zkw.getZNodePaths().peersZNode)) {
appendPeersZnodes(zkw, znode, sb);
} else if (znode.equals(zkw.znodePaths.queuesZNode)) {
} else if (znode.equals(zkw.getZNodePaths().queuesZNode)) {
appendRSZnodes(zkw, znode, sb);
} else if (znode.equals(zkw.znodePaths.hfileRefsZNode)) {
} else if (znode.equals(zkw.getZNodePaths().hfileRefsZNode)) {
appendHFileRefsZnodes(zkw, znode, sb);
}
}
@ -1944,7 +1945,7 @@ public final class ZKUtil {
* @throws IOException When the socket communication fails.
*/
public static String[] getServerStats(String server, int timeout)
throws IOException {
throws IOException {
String[] sp = server.split(":");
if (sp == null || sp.length == 0) {
return null;
@ -1989,9 +1990,9 @@ public final class ZKUtil {
" byte(s) of data from znode " + znode +
(watcherSet? " and set watcher; ": "; data=") +
(data == null? "null": data.length == 0? "empty": (
znode.startsWith(zkw.znodePaths.metaZNodePrefix)?
znode.startsWith(zkw.getZNodePaths().metaZNodePrefix)?
getServerNameOrEmptyString(data):
znode.startsWith(zkw.znodePaths.backupMasterAddressesZNode)?
znode.startsWith(zkw.getZNodePaths().backupMasterAddressesZNode)?
getServerNameOrEmptyString(data):
StringUtils.abbreviate(Bytes.toStringBinary(data), 32)))));
}

View File

@ -76,14 +76,14 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
// Used if abortable is null
private boolean aborted = false;
public final ZNodePaths znodePaths;
private final ZNodePaths znodePaths;
// listeners to be notified
private final List<ZKListener> listeners = new CopyOnWriteArrayList<>();
// Used by ZKUtil:waitForZKConnectionIfAuthenticating to wait for SASL
// negotiation to complete
public CountDownLatch saslLatch = new CountDownLatch(1);
private CountDownLatch saslLatch = new CountDownLatch(1);
private final Configuration conf;
@ -95,7 +95,7 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
* @param identifier string that is passed to RecoverableZookeeper to be used as
* identifier for this instance. Use null for default.
* @throws IOException if the connection to ZooKeeper fails
* @throws ZooKeeperConnectionException
* @throws ZooKeeperConnectionException if the client can't connect to ZooKeeper
*/
public ZKWatcher(Configuration conf, String identifier,
Abortable abortable) throws ZooKeeperConnectionException, IOException {
@ -111,11 +111,11 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
* context.
* @param canCreateBaseZNode true if a base ZNode can be created
* @throws IOException if the connection to ZooKeeper fails
* @throws ZooKeeperConnectionException
* @throws ZooKeeperConnectionException if the client can't connect to ZooKeeper
*/
public ZKWatcher(Configuration conf, String identifier,
Abortable abortable, boolean canCreateBaseZNode)
throws IOException, ZooKeeperConnectionException {
throws IOException, ZooKeeperConnectionException {
this(conf, identifier, abortable, canCreateBaseZNode, false);
}
@ -517,6 +517,8 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
}
break;
}
default:
throw new IllegalStateException("Received event is not valid: " + event.getState());
}
}

View File

@ -18,7 +18,6 @@
package org.apache.hadoop.hbase.zookeeper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View File

@ -43,7 +43,7 @@ public class TestZKMainServer {
// http://stackoverflow.com/questions/309396/java-how-to-test-methods-that-call-system-exit
protected static class ExitException extends SecurityException {
private static final long serialVersionUID = 1L;
public final int status;
private final int status;
public ExitException(int status) {
super("There is no escape!");
this.status = status;

View File

@ -90,7 +90,7 @@ public class TestZKMulti {
ZKUtil.multiOrSequential(zkw, new LinkedList<>(), false);
// single create
String path = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSimpleMulti");
String path = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSimpleMulti");
LinkedList<ZKUtilOp> singleCreate = new LinkedList<>();
singleCreate.add(ZKUtilOp.createAndFailSilent(path, new byte[0]));
ZKUtil.multiOrSequential(zkw, singleCreate, false);
@ -112,12 +112,12 @@ public class TestZKMulti {
@Test
public void testComplexMulti() throws Exception {
String path1 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti1");
String path2 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti2");
String path3 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti3");
String path4 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti4");
String path5 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti5");
String path6 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti6");
String path1 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti1");
String path2 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti2");
String path3 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti3");
String path4 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti4");
String path5 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti5");
String path6 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti6");
// create 4 nodes that we'll setData on or delete later
LinkedList<ZKUtilOp> create4Nodes = new LinkedList<>();
create4Nodes.add(ZKUtilOp.createAndFailSilent(path1, Bytes.toBytes(path1)));
@ -156,7 +156,7 @@ public class TestZKMulti {
public void testSingleFailure() throws Exception {
// try to delete a node that doesn't exist
boolean caughtNoNode = false;
String path = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureZ");
String path = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureZ");
LinkedList<ZKUtilOp> ops = new LinkedList<>();
ops.add(ZKUtilOp.deleteNodeFailSilent(path));
try {
@ -193,9 +193,9 @@ public class TestZKMulti {
@Test
public void testSingleFailureInMulti() throws Exception {
// try a multi where all but one operation succeeds
String pathA = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiA");
String pathB = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiB");
String pathC = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiC");
String pathA = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureInMultiA");
String pathB = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureInMultiB");
String pathC = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureInMultiC");
LinkedList<ZKUtilOp> ops = new LinkedList<>();
ops.add(ZKUtilOp.createAndFailSilent(pathA, Bytes.toBytes(pathA)));
ops.add(ZKUtilOp.createAndFailSilent(pathB, Bytes.toBytes(pathB)));
@ -215,17 +215,17 @@ public class TestZKMulti {
@Test
public void testMultiFailure() throws Exception {
String pathX = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureX");
String pathY = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureY");
String pathZ = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureZ");
String pathX = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureX");
String pathY = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureY");
String pathZ = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureZ");
// create X that we will use to fail create later
LinkedList<ZKUtilOp> ops = new LinkedList<>();
ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX)));
ZKUtil.multiOrSequential(zkw, ops, false);
// fail one of each create ,setData, delete
String pathV = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureV");
String pathW = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureW");
String pathV = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureV");
String pathW = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureW");
ops = new LinkedList<>();
ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- already exists
ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist
@ -269,10 +269,10 @@ public class TestZKMulti {
@Test
public void testRunSequentialOnMultiFailure() throws Exception {
String path1 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "runSequential1");
String path2 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "runSequential2");
String path3 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "runSequential3");
String path4 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "runSequential4");
String path1 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "runSequential1");
String path2 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "runSequential2");
String path3 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "runSequential3");
String path4 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "runSequential4");
// create some nodes that we will use later
LinkedList<ZKUtilOp> ops = new LinkedList<>();

View File

@ -99,9 +99,9 @@ public class TestZKNodeTracker {
Abortable abortable = new StubAbortable();
ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(),
"testNodeTracker", abortable);
ZKUtil.createAndFailSilent(zk, zk.znodePaths.baseZNode);
ZKUtil.createAndFailSilent(zk, zk.getZNodePaths().baseZNode);
final String node = ZNodePaths.joinZNode(zk.znodePaths.baseZNode,
final String node = ZNodePaths.joinZNode(zk.getZNodePaths().baseZNode,
Long.toString(ThreadLocalRandom.current().nextLong()));
final byte [] dataOne = Bytes.toBytes("dataOne");
@ -322,7 +322,7 @@ public class TestZKNodeTracker {
TEST_UTIL.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT));
final String nodeName = zkw.znodePaths.masterAddressZNode;
final String nodeName = zkw.getZNodePaths().masterAddressZNode;
// Check that we manage the case when there is no data
ZKUtil.createAndFailSilent(zkw, nodeName);

View File

@ -112,7 +112,7 @@ public class TestZKUtilNoServer {
}
};
Mockito.doThrow(new InterruptedException()).when(recoverableZk)
.getChildren(zkw.znodePaths.baseZNode, null);
ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.baseZNode);
.getChildren(zkw.getZNodePaths().baseZNode, null);
ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().baseZNode);
}
}