HBASE-16690 Move znode path configs to a separated class
This commit is contained in:
parent
617dfe18cd
commit
3aa4dfa73d
|
@ -459,8 +459,8 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
|
|||
throws MasterNotRunningException {
|
||||
String errorMsg;
|
||||
try {
|
||||
if (ZKUtil.checkExists(zkw, zkw.baseZNode) == -1) {
|
||||
errorMsg = "The node " + zkw.baseZNode+" is not in ZooKeeper. "
|
||||
if (ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) == -1) {
|
||||
errorMsg = "The node " + zkw.znodePaths.baseZNode+" is not in ZooKeeper. "
|
||||
+ "It should have been written by the master. "
|
||||
+ "Check the value configured in 'zookeeper.znode.parent'. "
|
||||
+ "There could be a mismatch with the one configured in the master.";
|
||||
|
|
|
@ -2128,7 +2128,7 @@ public class HBaseAdmin implements Admin {
|
|||
ZooKeeperKeepAliveConnection zkw = ((ConnectionImplementation) connection).
|
||||
getKeepAliveZooKeeperWatcher();) {
|
||||
// This is NASTY. FIX!!!! Dependent on internal implementation! TODO
|
||||
zkw.getRecoverableZooKeeper().getZooKeeper().exists(zkw.baseZNode, false);
|
||||
zkw.getRecoverableZooKeeper().getZooKeeper().exists(zkw.znodePaths.baseZNode, false);
|
||||
connection.isMasterRunning();
|
||||
} catch (IOException e) {
|
||||
throw new ZooKeeperConnectionException("Can't connect to ZooKeeper", e);
|
||||
|
|
|
@ -121,7 +121,7 @@ class ZooKeeperRegistry implements Registry {
|
|||
try {
|
||||
// We go to zk rather than to master to get count of regions to avoid
|
||||
// HTable having a Master dependency. See HBase-2828
|
||||
return ZKUtil.getNumberOfChildren(zkw, zkw.rsZNode);
|
||||
return ZKUtil.getNumberOfChildren(zkw, zkw.znodePaths.rsZNode);
|
||||
} catch (KeeperException ke) {
|
||||
throw new IOException("Unexpected ZooKeeper exception", ke);
|
||||
} finally {
|
||||
|
|
|
@ -87,7 +87,8 @@ public abstract class ReplicationStateZKBase {
|
|||
this.peerStateNodeName = conf.get("zookeeper.znode.replication.peers.state", "peer-state");
|
||||
this.tableCFsNodeName = conf.get("zookeeper.znode.replication.peers.tableCFs", "tableCFs");
|
||||
this.ourClusterKey = ZKConfig.getZooKeeperClusterKey(this.conf);
|
||||
this.replicationZNode = ZKUtil.joinZNode(this.zookeeper.baseZNode, replicationZNodeName);
|
||||
this.replicationZNode = ZKUtil.joinZNode(this.zookeeper.znodePaths.baseZNode,
|
||||
replicationZNodeName);
|
||||
this.peersZNode = ZKUtil.joinZNode(replicationZNode, peersZNodeName);
|
||||
this.queuesZNode = ZKUtil.joinZNode(replicationZNode, queuesZNodeName);
|
||||
this.hfileRefsZNode = ZKUtil.joinZNode(replicationZNode, hfileRefsZNodeName);
|
||||
|
|
|
@ -136,7 +136,7 @@ public class ReplicationTrackerZKImpl extends ReplicationStateZKBase implements
|
|||
}
|
||||
|
||||
private boolean refreshListIfRightPath(String path) {
|
||||
if (!path.startsWith(this.watcher.rsZNode)) {
|
||||
if (!path.startsWith(this.watcher.znodePaths.rsZNode)) {
|
||||
return false;
|
||||
}
|
||||
return refreshOtherRegionServersList();
|
||||
|
@ -242,7 +242,7 @@ public class ReplicationTrackerZKImpl extends ReplicationStateZKBase implements
|
|||
private List<String> getRegisteredRegionServers() {
|
||||
List<String> result = null;
|
||||
try {
|
||||
result = ZKUtil.listChildrenAndWatchThem(this.zookeeper, this.zookeeper.rsZNode);
|
||||
result = ZKUtil.listChildrenAndWatchThem(this.zookeeper, this.zookeeper.znodePaths.rsZNode);
|
||||
} catch (KeeperException e) {
|
||||
this.abortable.abort("Get list of registered region servers", e);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
|
|||
* @param abortable abortable in case of fatal error
|
||||
*/
|
||||
public MasterAddressTracker(ZooKeeperWatcher watcher, Abortable abortable) {
|
||||
super(watcher, watcher.getMasterAddressZNode(), abortable);
|
||||
super(watcher, watcher.znodePaths.masterAddressZNode, abortable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,7 +100,8 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
|
|||
* @return info port or 0 if timed out or exceptions
|
||||
*/
|
||||
public int getBackupMasterInfoPort(final ServerName sn) {
|
||||
String backupZNode = ZKUtil.joinZNode(watcher.backupMasterAddressesZNode, sn.toString());
|
||||
String backupZNode = ZKUtil.joinZNode(watcher.znodePaths.backupMasterAddressesZNode,
|
||||
sn.toString());
|
||||
try {
|
||||
byte[] data = ZKUtil.getData(watcher, backupZNode);
|
||||
final ZooKeeperProtos.Master backup = parse(data);
|
||||
|
@ -145,7 +146,7 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
|
|||
throws KeeperException, IOException {
|
||||
byte [] data;
|
||||
try {
|
||||
data = ZKUtil.getData(zkw, zkw.getMasterAddressZNode());
|
||||
data = ZKUtil.getData(zkw, zkw.znodePaths.masterAddressZNode);
|
||||
} catch (InterruptedException e) {
|
||||
throw new InterruptedIOException();
|
||||
}
|
||||
|
@ -177,7 +178,7 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
|
|||
IOException {
|
||||
byte[] data;
|
||||
try {
|
||||
data = ZKUtil.getData(zkw, zkw.getMasterAddressZNode());
|
||||
data = ZKUtil.getData(zkw, zkw.znodePaths.masterAddressZNode);
|
||||
} catch (InterruptedException e) {
|
||||
throw new InterruptedIOException();
|
||||
}
|
||||
|
@ -264,10 +265,10 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
|
|||
|
||||
try {
|
||||
Stat stat = new Stat();
|
||||
byte[] data = ZKUtil.getDataNoWatch(zkw, zkw.getMasterAddressZNode(), stat);
|
||||
byte[] data = ZKUtil.getDataNoWatch(zkw, zkw.znodePaths.masterAddressZNode, stat);
|
||||
ServerName sn = ProtobufUtil.parseServerNameFrom(data);
|
||||
if (sn != null && content.equals(sn.toString())) {
|
||||
return (ZKUtil.deleteNode(zkw, zkw.getMasterAddressZNode(), stat.getVersion()));
|
||||
return (ZKUtil.deleteNode(zkw, zkw.znodePaths.masterAddressZNode, stat.getVersion()));
|
||||
}
|
||||
} catch (KeeperException e) {
|
||||
LOG.warn("Can't get or delete the master znode", e);
|
||||
|
|
|
@ -204,7 +204,7 @@ public class MetaTableLocator {
|
|||
public ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, int replicaId, long timeout)
|
||||
throws InterruptedException, NotAllMetaRegionsOnlineException {
|
||||
try {
|
||||
if (ZKUtil.checkExists(zkw, zkw.baseZNode) == -1) {
|
||||
if (ZKUtil.checkExists(zkw, zkw.znodePaths.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);
|
||||
|
@ -371,7 +371,6 @@ public class MetaTableLocator {
|
|||
* invocation, or may be null.
|
||||
* @throws IOException
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private static AdminService.BlockingInterface getCachedConnection(ClusterConnection connection,
|
||||
ServerName sn)
|
||||
throws IOException {
|
||||
|
@ -449,7 +448,7 @@ public class MetaTableLocator {
|
|||
.setState(state.convert()).build();
|
||||
byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray());
|
||||
try {
|
||||
ZKUtil.setData(zookeeper, zookeeper.getZNodeForReplica(replicaId), data);
|
||||
ZKUtil.setData(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId), data);
|
||||
} catch(KeeperException.NoNodeException nne) {
|
||||
if (replicaId == HRegionInfo.DEFAULT_REPLICA_ID) {
|
||||
LOG.debug("META region location doesn't exist, create it");
|
||||
|
@ -457,7 +456,7 @@ public class MetaTableLocator {
|
|||
LOG.debug("META region location doesn't exist for replicaId " + replicaId +
|
||||
", create it");
|
||||
}
|
||||
ZKUtil.createAndWatch(zookeeper, zookeeper.getZNodeForReplica(replicaId), data);
|
||||
ZKUtil.createAndWatch(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -480,7 +479,7 @@ public class MetaTableLocator {
|
|||
RegionState.State state = RegionState.State.OPEN;
|
||||
ServerName serverName = null;
|
||||
try {
|
||||
byte[] data = ZKUtil.getData(zkw, zkw.getZNodeForReplica(replicaId));
|
||||
byte[] data = ZKUtil.getData(zkw, zkw.znodePaths.getZNodeForReplica(replicaId));
|
||||
if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) {
|
||||
try {
|
||||
int prefixLen = ProtobufUtil.lengthOfPBMagic();
|
||||
|
@ -532,7 +531,7 @@ public class MetaTableLocator {
|
|||
}
|
||||
try {
|
||||
// Just delete the node. Don't need any watches.
|
||||
ZKUtil.deleteNode(zookeeper, zookeeper.getZNodeForReplica(replicaId));
|
||||
ZKUtil.deleteNode(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId));
|
||||
} catch(KeeperException.NoNodeException nne) {
|
||||
// Has already been deleted
|
||||
}
|
||||
|
|
|
@ -62,10 +62,10 @@ public class ZKClusterId {
|
|||
|
||||
public static String readClusterIdZNode(ZooKeeperWatcher watcher)
|
||||
throws KeeperException {
|
||||
if (ZKUtil.checkExists(watcher, watcher.clusterIdZNode) != -1) {
|
||||
if (ZKUtil.checkExists(watcher, watcher.znodePaths.clusterIdZNode) != -1) {
|
||||
byte [] data;
|
||||
try {
|
||||
data = ZKUtil.getData(watcher, watcher.clusterIdZNode);
|
||||
data = ZKUtil.getData(watcher, watcher.znodePaths.clusterIdZNode);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
|
@ -83,7 +83,7 @@ public class ZKClusterId {
|
|||
|
||||
public static void setClusterId(ZooKeeperWatcher watcher, ClusterId id)
|
||||
throws KeeperException {
|
||||
ZKUtil.createSetData(watcher, watcher.clusterIdZNode, id.toByteArray());
|
||||
ZKUtil.createSetData(watcher, watcher.znodePaths.clusterIdZNode, id.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -901,7 +901,7 @@ public class ZKUtil {
|
|||
|
||||
public static ArrayList<ACL> createACL(ZooKeeperWatcher zkw, String node,
|
||||
boolean isSecureZooKeeper) {
|
||||
if (!node.startsWith(zkw.baseZNode)) {
|
||||
if (!node.startsWith(zkw.znodePaths.baseZNode)) {
|
||||
return Ids.OPEN_ACL_UNSAFE;
|
||||
}
|
||||
if (isSecureZooKeeper) {
|
||||
|
@ -1701,7 +1701,7 @@ public class ZKUtil {
|
|||
public static String dump(ZooKeeperWatcher zkw) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try {
|
||||
sb.append("HBase is rooted at ").append(zkw.baseZNode);
|
||||
sb.append("HBase is rooted at ").append(zkw.znodePaths.baseZNode);
|
||||
sb.append("\nActive master address: ");
|
||||
try {
|
||||
sb.append(MasterAddressTracker.getMasterAddress(zkw));
|
||||
|
@ -1709,8 +1709,7 @@ public class ZKUtil {
|
|||
sb.append("<<FAILED LOOKUP: " + e.getMessage() + ">>");
|
||||
}
|
||||
sb.append("\nBackup master addresses:");
|
||||
for (String child : listChildrenNoWatch(zkw,
|
||||
zkw.backupMasterAddressesZNode)) {
|
||||
for (String child : listChildrenNoWatch(zkw, zkw.znodePaths.backupMasterAddressesZNode)) {
|
||||
sb.append("\n ").append(child);
|
||||
}
|
||||
sb.append("\nRegion server holding hbase:meta: "
|
||||
|
@ -1723,7 +1722,7 @@ public class ZKUtil {
|
|||
+ new MetaTableLocator().getMetaRegionLocation(zkw, i));
|
||||
}
|
||||
sb.append("\nRegion servers:");
|
||||
for (String child : listChildrenNoWatch(zkw, zkw.rsZNode)) {
|
||||
for (String child : listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode)) {
|
||||
sb.append("\n ").append(child);
|
||||
}
|
||||
try {
|
||||
|
@ -1767,7 +1766,7 @@ public class ZKUtil {
|
|||
throws KeeperException {
|
||||
String replicationZNodeName = zkw.getConfiguration().get("zookeeper.znode.replication",
|
||||
"replication");
|
||||
String replicationZnode = joinZNode(zkw.baseZNode, replicationZNodeName);
|
||||
String replicationZnode = joinZNode(zkw.znodePaths.baseZNode, replicationZNodeName);
|
||||
if (ZKUtil.checkExists(zkw, replicationZnode) == -1) return;
|
||||
// do a ls -r on this znode
|
||||
sb.append("\n").append(replicationZnode).append(": ");
|
||||
|
@ -1948,9 +1947,9 @@ public class ZKUtil {
|
|||
" byte(s) of data from znode " + znode +
|
||||
(watcherSet? " and set watcher; ": "; data=") +
|
||||
(data == null? "null": data.length == 0? "empty": (
|
||||
znode.startsWith(ZooKeeperWatcher.META_ZNODE_PREFIX)?
|
||||
znode.startsWith(zkw.znodePaths.metaZNodePrefix)?
|
||||
getServerNameOrEmptyString(data):
|
||||
znode.startsWith(zkw.backupMasterAddressesZNode)?
|
||||
znode.startsWith(zkw.znodePaths.backupMasterAddressesZNode)?
|
||||
getServerNameOrEmptyString(data):
|
||||
StringUtils.abbreviate(Bytes.toStringBinary(data), 32)))));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.zookeeper;
|
||||
|
||||
import static org.apache.hadoop.hbase.HConstants.DEFAULT_META_REPLICA_NUM;
|
||||
import static org.apache.hadoop.hbase.HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT;
|
||||
import static org.apache.hadoop.hbase.HConstants.META_REPLICAS_NUM;
|
||||
import static org.apache.hadoop.hbase.HConstants.SPLIT_LOGDIR_NAME;
|
||||
import static org.apache.hadoop.hbase.HConstants.ZOOKEEPER_ZNODE_PARENT;
|
||||
import static org.apache.hadoop.hbase.HRegionInfo.DEFAULT_REPLICA_ID;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
|
||||
/**
|
||||
* Class that hold all the paths of znode for HBase.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class ZNodePaths {
|
||||
|
||||
public final static String META_ZNODE_PREFIX = "meta-region-server";
|
||||
|
||||
// base znode for this cluster
|
||||
public final String baseZNode;
|
||||
// the prefix of meta znode, does not include baseZNode.
|
||||
public final String metaZNodePrefix;
|
||||
// znodes containing the locations of the servers hosting the meta replicas
|
||||
public final ImmutableMap<Integer, String> metaReplicaZNodes;
|
||||
// znode containing ephemeral nodes of the regionservers
|
||||
public final String rsZNode;
|
||||
// znode containing ephemeral nodes of the draining regionservers
|
||||
public final String drainingZNode;
|
||||
// znode of currently active master
|
||||
public final String masterAddressZNode;
|
||||
// znode of this master in backup master directory, if not the active master
|
||||
public final String backupMasterAddressesZNode;
|
||||
// znode containing the current cluster state
|
||||
public final String clusterStateZNode;
|
||||
// znode used for table disabling/enabling
|
||||
@Deprecated
|
||||
public final String tableZNode;
|
||||
// znode containing the unique cluster ID
|
||||
public final String clusterIdZNode;
|
||||
// znode used for log splitting work assignment
|
||||
public final String splitLogZNode;
|
||||
// znode containing the state of the load balancer
|
||||
public final String balancerZNode;
|
||||
// znode containing the state of region normalizer
|
||||
public final String regionNormalizerZNode;
|
||||
// znode containing the state of all switches, currently there are split and merge child node.
|
||||
public final String switchZNode;
|
||||
// znode containing the lock for the tables
|
||||
public final String tableLockZNode;
|
||||
// znode containing the state of recovering regions
|
||||
public final String recoveringRegionsZNode;
|
||||
// znode containing namespace descriptors
|
||||
public final String namespaceZNode;
|
||||
// znode of indicating master maintenance mode
|
||||
public final String masterMaintZNode;
|
||||
|
||||
public ZNodePaths(Configuration conf) {
|
||||
baseZNode = conf.get(ZOOKEEPER_ZNODE_PARENT, DEFAULT_ZOOKEEPER_ZNODE_PARENT);
|
||||
ImmutableMap.Builder<Integer, String> builder = ImmutableMap.builder();
|
||||
metaZNodePrefix = conf.get("zookeeper.znode.metaserver", META_ZNODE_PREFIX);
|
||||
String defaultMetaReplicaZNode = ZKUtil.joinZNode(baseZNode, metaZNodePrefix);
|
||||
builder.put(DEFAULT_REPLICA_ID, defaultMetaReplicaZNode);
|
||||
int numMetaReplicas = conf.getInt(META_REPLICAS_NUM, DEFAULT_META_REPLICA_NUM);
|
||||
IntStream.range(1, numMetaReplicas)
|
||||
.forEachOrdered(i -> builder.put(i, defaultMetaReplicaZNode + "-" + i));
|
||||
metaReplicaZNodes = builder.build();
|
||||
rsZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.rs", "rs"));
|
||||
drainingZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.draining.rs", "draining"));
|
||||
masterAddressZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.master", "master"));
|
||||
backupMasterAddressesZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.backup.masters", "backup-masters"));
|
||||
clusterStateZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.state", "running"));
|
||||
tableZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.tableEnableDisable", "table"));
|
||||
clusterIdZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.clusterId", "hbaseid"));
|
||||
splitLogZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.splitlog", SPLIT_LOGDIR_NAME));
|
||||
balancerZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.balancer", "balancer"));
|
||||
regionNormalizerZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.regionNormalizer", "normalizer"));
|
||||
switchZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.switch", "switch"));
|
||||
tableLockZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.tableLock", "table-lock"));
|
||||
recoveringRegionsZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.recovering.regions", "recovering-regions"));
|
||||
namespaceZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.namespace", "namespace"));
|
||||
masterMaintZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.masterMaintenance", "master-maintenance"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ZNodePaths [baseZNode=" + baseZNode + ", metaReplicaZNodes=" + metaReplicaZNodes
|
||||
+ ", rsZNode=" + rsZNode + ", drainingZNode=" + drainingZNode + ", masterAddressZNode="
|
||||
+ masterAddressZNode + ", backupMasterAddressesZNode=" + backupMasterAddressesZNode
|
||||
+ ", clusterStateZNode=" + clusterStateZNode + ", tableZNode=" + tableZNode
|
||||
+ ", clusterIdZNode=" + clusterIdZNode + ", splitLogZNode=" + splitLogZNode
|
||||
+ ", balancerZNode=" + balancerZNode + ", regionNormalizerZNode=" + regionNormalizerZNode
|
||||
+ ", switchZNode=" + switchZNode + ", tableLockZNode=" + tableLockZNode
|
||||
+ ", recoveringRegionsZNode=" + recoveringRegionsZNode + ", namespaceZNode="
|
||||
+ namespaceZNode + ", masterMaintZNode=" + masterMaintZNode + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the znode of any meta replica
|
||||
* @param node
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean isAnyMetaReplicaZNode(String node) {
|
||||
if (metaReplicaZNodes.containsValue(node)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the znode string corresponding to a replicaId
|
||||
* @param replicaId
|
||||
* @return znode
|
||||
*/
|
||||
public String getZNodeForReplica(int replicaId) {
|
||||
// return a newly created path but don't update the cache of paths
|
||||
// This is mostly needed for tests that attempt to create meta replicas
|
||||
// from outside the master
|
||||
return Optional.ofNullable(metaReplicaZNodes.get(replicaId))
|
||||
.orElseGet(() -> metaReplicaZNodes.get(DEFAULT_REPLICA_ID) + "-" + replicaId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the meta replicaId from the passed znode
|
||||
* @param znode
|
||||
* @return replicaId
|
||||
*/
|
||||
public int getMetaReplicaIdFromZnode(String znode) {
|
||||
if (znode.equals(metaZNodePrefix)) {
|
||||
return HRegionInfo.DEFAULT_REPLICA_ID;
|
||||
}
|
||||
return Integer.parseInt(znode.substring(metaZNodePrefix.length() + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it the default meta replica's znode
|
||||
* @param znode
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean isDefaultMetaReplicaZnode(String znode) {
|
||||
return metaReplicaZNodes.get(DEFAULT_REPLICA_ID).equals(znode);
|
||||
}
|
||||
}
|
|
@ -70,8 +70,8 @@ public class ZkAclReset extends Configured implements Tool {
|
|||
ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "ZkAclReset", null);
|
||||
try {
|
||||
LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for " +
|
||||
zkw.getQuorum() + " " + zkw.getBaseZNode());
|
||||
resetAcls(zkw, zkw.getBaseZNode(), eraseAcls);
|
||||
zkw.getQuorum() + " " + zkw.znodePaths.baseZNode);
|
||||
resetAcls(zkw, zkw.znodePaths.baseZNode, eraseAcls);
|
||||
} finally {
|
||||
zkw.close();
|
||||
}
|
||||
|
|
|
@ -232,15 +232,13 @@ public abstract class ZooKeeperNodeTracker extends ZooKeeperListener {
|
|||
*/
|
||||
public boolean checkIfBaseNodeAvailable() {
|
||||
try {
|
||||
if (ZKUtil.checkExists(watcher, watcher.baseZNode) == -1) {
|
||||
if (ZKUtil.checkExists(watcher, watcher.znodePaths.baseZNode) == -1) {
|
||||
return false;
|
||||
}
|
||||
} catch (KeeperException e) {
|
||||
abortable
|
||||
.abort(
|
||||
"Exception while checking if basenode ("+watcher.baseZNode+
|
||||
") exists in ZooKeeper.",
|
||||
e);
|
||||
abortable.abort("Exception while checking if basenode (" + watcher.znodePaths.baseZNode
|
||||
+ ") exists in ZooKeeper.",
|
||||
e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,8 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
// Used if abortable is null
|
||||
private boolean aborted = false;
|
||||
|
||||
public final ZNodePaths znodePaths;
|
||||
|
||||
// listeners to be notified
|
||||
private final List<ZooKeeperListener> listeners =
|
||||
new CopyOnWriteArrayList<ZooKeeperListener>();
|
||||
|
@ -88,45 +90,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
// negotiation to complete
|
||||
public CountDownLatch saslLatch = new CountDownLatch(1);
|
||||
|
||||
// node names
|
||||
|
||||
// base znode for this cluster
|
||||
public String baseZNode;
|
||||
//znodes containing the locations of the servers hosting the meta replicas
|
||||
private Map<Integer,String> metaReplicaZnodes = new HashMap<Integer, String>();
|
||||
// znode containing ephemeral nodes of the regionservers
|
||||
public String rsZNode;
|
||||
// znode containing ephemeral nodes of the draining regionservers
|
||||
public String drainingZNode;
|
||||
// znode of currently active master
|
||||
private String masterAddressZNode;
|
||||
// znode of this master in backup master directory, if not the active master
|
||||
public String backupMasterAddressesZNode;
|
||||
// znode containing the current cluster state
|
||||
public String clusterStateZNode;
|
||||
// znode used for table disabling/enabling
|
||||
@Deprecated
|
||||
public String tableZNode;
|
||||
// znode containing the unique cluster ID
|
||||
public String clusterIdZNode;
|
||||
// znode used for log splitting work assignment
|
||||
public String splitLogZNode;
|
||||
// znode containing the state of the load balancer
|
||||
public String balancerZNode;
|
||||
// znode containing the state of region normalizer
|
||||
private String regionNormalizerZNode;
|
||||
// znode containing the state of all switches, currently there are split and merge child node.
|
||||
private String switchZNode;
|
||||
// znode containing the lock for the tables
|
||||
public String tableLockZNode;
|
||||
// znode containing the state of recovering regions
|
||||
public String recoveringRegionsZNode;
|
||||
// znode containing namespace descriptors
|
||||
public String namespaceZNode = "namespace";
|
||||
// znode of indicating master maintenance mode
|
||||
public static String masterMaintZNode = "masterMaintenance";
|
||||
|
||||
public final static String META_ZNODE_PREFIX = "meta-region-server";
|
||||
|
||||
private final Configuration conf;
|
||||
|
||||
|
@ -166,7 +130,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
// handle the syncconnect event.
|
||||
this.identifier = identifier + "0x0";
|
||||
this.abortable = abortable;
|
||||
setNodeNames(conf);
|
||||
this.znodePaths = new ZNodePaths(conf);
|
||||
PendingWatcher pendingWatcher = new PendingWatcher();
|
||||
this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, pendingWatcher, identifier);
|
||||
pendingWatcher.prepare(this);
|
||||
|
@ -188,15 +152,15 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
private void createBaseZNodes() throws ZooKeeperConnectionException {
|
||||
try {
|
||||
// Create all the necessary "directories" of znodes
|
||||
ZKUtil.createWithParents(this, baseZNode);
|
||||
ZKUtil.createAndFailSilent(this, rsZNode);
|
||||
ZKUtil.createAndFailSilent(this, drainingZNode);
|
||||
ZKUtil.createAndFailSilent(this, tableZNode);
|
||||
ZKUtil.createAndFailSilent(this, splitLogZNode);
|
||||
ZKUtil.createAndFailSilent(this, backupMasterAddressesZNode);
|
||||
ZKUtil.createAndFailSilent(this, tableLockZNode);
|
||||
ZKUtil.createAndFailSilent(this, recoveringRegionsZNode);
|
||||
ZKUtil.createAndFailSilent(this, masterMaintZNode);
|
||||
ZKUtil.createWithParents(this, znodePaths.baseZNode);
|
||||
ZKUtil.createAndFailSilent(this, znodePaths.rsZNode);
|
||||
ZKUtil.createAndFailSilent(this, znodePaths.drainingZNode);
|
||||
ZKUtil.createAndFailSilent(this, znodePaths.tableZNode);
|
||||
ZKUtil.createAndFailSilent(this, znodePaths.splitLogZNode);
|
||||
ZKUtil.createAndFailSilent(this, znodePaths.backupMasterAddressesZNode);
|
||||
ZKUtil.createAndFailSilent(this, znodePaths.tableLockZNode);
|
||||
ZKUtil.createAndFailSilent(this, znodePaths.recoveringRegionsZNode);
|
||||
ZKUtil.createAndFailSilent(this, znodePaths.masterMaintZNode);
|
||||
} catch (KeeperException e) {
|
||||
throw new ZooKeeperConnectionException(
|
||||
prefix("Unexpected KeeperException creating base node"), e);
|
||||
|
@ -210,14 +174,14 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
// all clients need to access this data to work. Using zk for sharing data to clients (other
|
||||
// than service lookup case is not a recommended design pattern.
|
||||
return
|
||||
node.equals(baseZNode) ||
|
||||
isAnyMetaReplicaZnode(node) ||
|
||||
node.equals(getMasterAddressZNode()) ||
|
||||
node.equals(clusterIdZNode)||
|
||||
node.equals(rsZNode) ||
|
||||
node.equals(znodePaths.baseZNode) ||
|
||||
znodePaths.isAnyMetaReplicaZNode(node) ||
|
||||
node.equals(znodePaths.masterAddressZNode) ||
|
||||
node.equals(znodePaths.clusterIdZNode)||
|
||||
node.equals(znodePaths.rsZNode) ||
|
||||
// /hbase/table and /hbase/table/foo is allowed, /hbase/table-lock is not
|
||||
node.equals(tableZNode) ||
|
||||
node.startsWith(tableZNode + "/");
|
||||
node.equals(znodePaths.tableZNode) ||
|
||||
node.startsWith(znodePaths.tableZNode + "/");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,11 +199,11 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
// Check the base znodes permission first. Only do the recursion if base znode's perms are not
|
||||
// correct.
|
||||
try {
|
||||
List<ACL> actualAcls = recoverableZooKeeper.getAcl(baseZNode, new Stat());
|
||||
List<ACL> actualAcls = recoverableZooKeeper.getAcl(znodePaths.baseZNode, new Stat());
|
||||
|
||||
if (!isBaseZnodeAclSetup(actualAcls)) {
|
||||
LOG.info("setting znode ACLs");
|
||||
setZnodeAclsRecursive(baseZNode);
|
||||
setZnodeAclsRecursive(znodePaths.baseZNode);
|
||||
}
|
||||
} catch(KeeperException.NoNodeException nne) {
|
||||
return;
|
||||
|
@ -390,7 +354,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.identifier + ", quorum=" + quorum + ", baseZNode=" + baseZNode;
|
||||
return this.identifier + ", quorum=" + quorum + ", baseZNode=" + znodePaths.baseZNode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -403,83 +367,13 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
return this.toString() + " " + str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the local variable node names using the specified configuration.
|
||||
*/
|
||||
private void setNodeNames(Configuration conf) {
|
||||
baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
|
||||
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
|
||||
metaReplicaZnodes.put(0, ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.metaserver", "meta-region-server")));
|
||||
int numMetaReplicas = conf.getInt(HConstants.META_REPLICAS_NUM,
|
||||
HConstants.DEFAULT_META_REPLICA_NUM);
|
||||
for (int i = 1; i < numMetaReplicas; i++) {
|
||||
String str = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + i);
|
||||
metaReplicaZnodes.put(i, str);
|
||||
}
|
||||
rsZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.rs", "rs"));
|
||||
drainingZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.draining.rs", "draining"));
|
||||
masterAddressZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.master", "master"));
|
||||
backupMasterAddressesZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.backup.masters", "backup-masters"));
|
||||
clusterStateZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.state", "running"));
|
||||
tableZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.tableEnableDisable", "table"));
|
||||
clusterIdZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.clusterId", "hbaseid"));
|
||||
splitLogZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.splitlog", HConstants.SPLIT_LOGDIR_NAME));
|
||||
balancerZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.balancer", "balancer"));
|
||||
regionNormalizerZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.regionNormalizer", "normalizer"));
|
||||
switchZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.switch", "switch"));
|
||||
tableLockZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.tableLock", "table-lock"));
|
||||
recoveringRegionsZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.recovering.regions", "recovering-regions"));
|
||||
namespaceZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.namespace", "namespace"));
|
||||
masterMaintZNode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.masterMaintenance", "master-maintenance"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the znode of any meta replica
|
||||
* @param node
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean isAnyMetaReplicaZnode(String node) {
|
||||
if (metaReplicaZnodes.values().contains(node)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it the default meta replica's znode
|
||||
* @param node
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean isDefaultMetaReplicaZnode(String node) {
|
||||
if (getZNodeForReplica(HRegionInfo.DEFAULT_REPLICA_ID).equals(node)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the znodes corresponding to the meta replicas from ZK
|
||||
* @return list of znodes
|
||||
* @throws KeeperException
|
||||
*/
|
||||
public List<String> getMetaReplicaNodes() throws KeeperException {
|
||||
List<String> childrenOfBaseNode = ZKUtil.listChildrenNoWatch(this, baseZNode);
|
||||
List<String> childrenOfBaseNode = ZKUtil.listChildrenNoWatch(this, znodePaths.baseZNode);
|
||||
List<String> metaReplicaNodes = new ArrayList<String>(2);
|
||||
if (childrenOfBaseNode != null) {
|
||||
String pattern = conf.get("zookeeper.znode.metaserver","meta-region-server");
|
||||
|
@ -490,36 +384,6 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
return metaReplicaNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the znode string corresponding to a replicaId
|
||||
* @param replicaId
|
||||
* @return znode
|
||||
*/
|
||||
public String getZNodeForReplica(int replicaId) {
|
||||
String str = metaReplicaZnodes.get(replicaId);
|
||||
// return a newly created path but don't update the cache of paths
|
||||
// This is mostly needed for tests that attempt to create meta replicas
|
||||
// from outside the master
|
||||
if (str == null) {
|
||||
str = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + replicaId);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the meta replicaId from the passed znode
|
||||
* @param znode
|
||||
* @return replicaId
|
||||
*/
|
||||
public int getMetaReplicaIdFromZnode(String znode) {
|
||||
String pattern = conf.get("zookeeper.znode.metaserver","meta-region-server");
|
||||
if (znode.equals(pattern)) return HRegionInfo.DEFAULT_REPLICA_ID;
|
||||
// the non-default replicas are of the pattern meta-region-server-<replicaId>
|
||||
String nonDefaultPattern = pattern + "-";
|
||||
return Integer.parseInt(znode.substring(nonDefaultPattern.length()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the specified listener to receive ZooKeeper events.
|
||||
* @param listener
|
||||
|
@ -583,10 +447,12 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the base znode of this zookeeper connection instance.
|
||||
* Get the znodePaths.
|
||||
* <p>
|
||||
* Mainly used for mocking as mockito can not mock a field access.
|
||||
*/
|
||||
public String getBaseZNode() {
|
||||
return baseZNode;
|
||||
public ZNodePaths getZNodePaths() {
|
||||
return znodePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -765,25 +631,4 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
|
|||
public boolean isAborted() {
|
||||
return this.abortable == null? this.aborted: this.abortable.isAborted();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Path to the currently active master.
|
||||
*/
|
||||
public String getMasterAddressZNode() {
|
||||
return this.masterAddressZNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ZooKeeper znode for region normalizer state
|
||||
*/
|
||||
public String getRegionNormalizerZNode() {
|
||||
return regionNormalizerZNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ZK node for switch
|
||||
* */
|
||||
public String getSwitchZNode() {
|
||||
return switchZNode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
package org.apache.hadoop.hbase.zookeeper;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -28,31 +29,30 @@ import org.apache.hadoop.hbase.testclassification.SmallTests;
|
|||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category({SmallTests.class})
|
||||
@Category({ SmallTests.class })
|
||||
public class TestZooKeeperWatcher {
|
||||
|
||||
@Test
|
||||
public void testIsClientReadable() throws ZooKeeperConnectionException, IOException {
|
||||
ZooKeeperWatcher watcher = new ZooKeeperWatcher(HBaseConfiguration.create(),
|
||||
"testIsClientReadable", null, false);
|
||||
"testIsClientReadable", null, false);
|
||||
|
||||
assertTrue(watcher.isClientReadable(watcher.baseZNode));
|
||||
assertTrue(watcher.isClientReadable(watcher.getZNodeForReplica(0)));
|
||||
assertTrue(watcher.isClientReadable(watcher.getMasterAddressZNode()));
|
||||
assertTrue(watcher.isClientReadable(watcher.clusterIdZNode));
|
||||
assertTrue(watcher.isClientReadable(watcher.tableZNode));
|
||||
assertTrue(watcher.isClientReadable(ZKUtil.joinZNode(watcher.tableZNode, "foo")));
|
||||
assertTrue(watcher.isClientReadable(watcher.rsZNode));
|
||||
assertTrue(watcher.isClientReadable(watcher.znodePaths.baseZNode));
|
||||
assertTrue(watcher.isClientReadable(watcher.znodePaths.getZNodeForReplica(0)));
|
||||
assertTrue(watcher.isClientReadable(watcher.znodePaths.masterAddressZNode));
|
||||
assertTrue(watcher.isClientReadable(watcher.znodePaths.clusterIdZNode));
|
||||
assertTrue(watcher.isClientReadable(watcher.znodePaths.tableZNode));
|
||||
assertTrue(watcher.isClientReadable(ZKUtil.joinZNode(watcher.znodePaths.tableZNode, "foo")));
|
||||
assertTrue(watcher.isClientReadable(watcher.znodePaths.rsZNode));
|
||||
|
||||
|
||||
assertFalse(watcher.isClientReadable(watcher.tableLockZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.balancerZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.getRegionNormalizerZNode()));
|
||||
assertFalse(watcher.isClientReadable(watcher.clusterStateZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.drainingZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.recoveringRegionsZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.splitLogZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.backupMasterAddressesZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.znodePaths.tableLockZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.znodePaths.balancerZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.znodePaths.regionNormalizerZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.znodePaths.clusterStateZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.znodePaths.drainingZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.znodePaths.recoveringRegionsZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.znodePaths.splitLogZNode));
|
||||
assertFalse(watcher.isClientReadable(watcher.znodePaths.backupMasterAddressesZNode));
|
||||
|
||||
watcher.close();
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class IntegrationTestMetaReplicas {
|
|||
}
|
||||
|
||||
private static void waitUntilZnodeAvailable(int replicaId) throws Exception {
|
||||
String znode = util.getZooKeeperWatcher().getZNodeForReplica(replicaId);
|
||||
String znode = util.getZooKeeperWatcher().znodePaths.getZNodeForReplica(replicaId);
|
||||
int i = 0;
|
||||
while (i < 1000) {
|
||||
if (ZKUtil.checkExists(util.getZooKeeperWatcher(), znode) == -1) {
|
||||
|
|
|
@ -140,7 +140,7 @@ public class IntegrationTestZKAndFSPermissions extends AbstractHBaseTool {
|
|||
ZooKeeperWatcher watcher = new ZooKeeperWatcher(conf, "IntegrationTestZnodeACLs", null);
|
||||
RecoverableZooKeeper zk = ZKUtil.connect(this.conf, watcher);
|
||||
|
||||
String baseZNode = watcher.baseZNode;
|
||||
String baseZNode = watcher.znodePaths.baseZNode;
|
||||
|
||||
LOG.info("");
|
||||
LOG.info("***********************************************************************************");
|
||||
|
|
|
@ -297,7 +297,7 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
|
|||
groupList.addAll(rsGroupSerDe.retrieveGroupList(rsGroupTable));
|
||||
} else {
|
||||
LOG.debug("Refershing in Offline mode.");
|
||||
String groupBasePath = ZKUtil.joinZNode(watcher.baseZNode, rsGroupZNode);
|
||||
String groupBasePath = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, rsGroupZNode);
|
||||
groupList.addAll(rsGroupSerDe.retrieveGroupList(watcher, groupBasePath));
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
|
|||
|
||||
|
||||
try {
|
||||
String groupBasePath = ZKUtil.joinZNode(watcher.baseZNode, rsGroupZNode);
|
||||
String groupBasePath = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, rsGroupZNode);
|
||||
ZKUtil.createAndFailSilent(watcher, groupBasePath, ProtobufMagic.PB_MAGIC);
|
||||
|
||||
List<ZKUtil.ZKUtilOp> zkOps = new ArrayList<ZKUtil.ZKUtilOp>(newGroupMap.size());
|
||||
|
@ -452,7 +452,7 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
|
|||
try {
|
||||
LOG.debug("Reading online RS from zookeeper");
|
||||
List<ServerName> servers = new LinkedList<ServerName>();
|
||||
for (String el: ZKUtil.listChildrenNoWatch(watcher, watcher.rsZNode)) {
|
||||
for (String el: ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.rsZNode)) {
|
||||
servers.add(ServerName.parseServerName(el));
|
||||
}
|
||||
return servers;
|
||||
|
|
|
@ -122,7 +122,7 @@ public class VerifyingRSGroupAdminClient extends RSGroupAdmin {
|
|||
Assert.assertEquals(Sets.newHashSet(groupMap.values()),
|
||||
Sets.newHashSet(wrapped.listRSGroups()));
|
||||
try {
|
||||
String groupBasePath = ZKUtil.joinZNode(zkw.baseZNode, "rsgroup");
|
||||
String groupBasePath = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "rsgroup");
|
||||
for(String znode: ZKUtil.listChildrenNoWatch(zkw, groupBasePath)) {
|
||||
byte[] data = ZKUtil.getData(zkw, ZKUtil.joinZNode(groupBasePath, znode));
|
||||
if(data.length > 0) {
|
||||
|
|
|
@ -295,7 +295,7 @@ AssignmentManager assignmentManager = master.getAssignmentManager();
|
|||
</tr>
|
||||
<tr>
|
||||
<td>ZooKeeper Base Path</td>
|
||||
<td> <% master.getZooKeeper().getBaseZNode() %></td>
|
||||
<td> <% master.getZooKeeper().getZNodePaths().baseZNode %></td>
|
||||
<td>Root node of this cluster in ZK.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ZKNamespaceManager extends ZooKeeperListener {
|
|||
|
||||
public ZKNamespaceManager(ZooKeeperWatcher zkw) throws IOException {
|
||||
super(zkw);
|
||||
nsZNode = zkw.namespaceZNode;
|
||||
nsZNode = zkw.znodePaths.namespaceZNode;
|
||||
cache = new ConcurrentSkipListMap<String, NamespaceDescriptor>();
|
||||
}
|
||||
|
||||
|
|
|
@ -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, ZooKeeperWatcher zooKeeper) {
|
||||
return ZKUtil.joinZNode(zooKeeper.baseZNode, conf.get(ZOOKEEPER_ZNODE_HFILE_ARCHIVE_KEY,
|
||||
TableHFileArchiveTracker.HFILE_ARCHIVE_ZNODE_PARENT));
|
||||
return ZKUtil.joinZNode(zooKeeper.znodePaths.baseZNode, conf.get(
|
||||
ZOOKEEPER_ZNODE_HFILE_ARCHIVE_KEY, TableHFileArchiveTracker.HFILE_ARCHIVE_ZNODE_PARENT));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
public int remainingTasksInCoordination() {
|
||||
int count = 0;
|
||||
try {
|
||||
List<String> tasks = ZKUtil.listChildrenNoWatch(watcher, watcher.splitLogZNode);
|
||||
List<String> tasks = ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.splitLogZNode);
|
||||
if (tasks != null) {
|
||||
int listSize = tasks.size();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
|
@ -288,7 +288,7 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
final String metaEncodeRegionName = HRegionInfo.FIRST_META_REGIONINFO.getEncodedName();
|
||||
int count = 0;
|
||||
try {
|
||||
List<String> tasks = ZKUtil.listChildrenNoWatch(watcher, watcher.splitLogZNode);
|
||||
List<String> tasks = ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.splitLogZNode);
|
||||
if (tasks != null) {
|
||||
int listSize = tasks.size();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
|
@ -306,7 +306,8 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
lastRecoveringNodeCreationTime = Long.MAX_VALUE;
|
||||
} else if (!recoveredServerNameSet.isEmpty()) {
|
||||
// Remove recovering regions which don't have any RS associated with it
|
||||
List<String> regions = ZKUtil.listChildrenNoWatch(watcher, watcher.recoveringRegionsZNode);
|
||||
List<String> regions = ZKUtil.listChildrenNoWatch(watcher,
|
||||
watcher.znodePaths.recoveringRegionsZNode);
|
||||
if (regions != null) {
|
||||
int listSize = regions.size();
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
@ -323,7 +324,7 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
continue;
|
||||
}
|
||||
}
|
||||
String nodePath = ZKUtil.joinZNode(watcher.recoveringRegionsZNode, region);
|
||||
String nodePath = ZKUtil.joinZNode(watcher.znodePaths.recoveringRegionsZNode, region);
|
||||
List<String> failedServers = ZKUtil.listChildrenNoWatch(watcher, nodePath);
|
||||
if (failedServers == null || failedServers.isEmpty()) {
|
||||
ZKUtil.deleteNode(watcher, nodePath);
|
||||
|
@ -562,13 +563,13 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
private void lookForOrphans() {
|
||||
List<String> orphans;
|
||||
try {
|
||||
orphans = ZKUtil.listChildrenNoWatch(this.watcher, this.watcher.splitLogZNode);
|
||||
orphans = ZKUtil.listChildrenNoWatch(this.watcher, this.watcher.znodePaths.splitLogZNode);
|
||||
if (orphans == null) {
|
||||
LOG.warn("could not get children of " + this.watcher.splitLogZNode);
|
||||
LOG.warn("could not get children of " + this.watcher.znodePaths.splitLogZNode);
|
||||
return;
|
||||
}
|
||||
} catch (KeeperException e) {
|
||||
LOG.warn("could not get children of " + this.watcher.splitLogZNode + " "
|
||||
LOG.warn("could not get children of " + this.watcher.znodePaths.splitLogZNode + " "
|
||||
+ StringUtils.stringifyException(e));
|
||||
return;
|
||||
}
|
||||
|
@ -576,7 +577,7 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
int listSize = orphans.size();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
String path = orphans.get(i);
|
||||
String nodepath = ZKUtil.joinZNode(watcher.splitLogZNode, path);
|
||||
String nodepath = ZKUtil.joinZNode(watcher.znodePaths.splitLogZNode, path);
|
||||
if (ZKSplitLog.isRescanNode(watcher, nodepath)) {
|
||||
rescan_nodes++;
|
||||
LOG.debug("found orphan rescan node " + path);
|
||||
|
@ -604,7 +605,8 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
long retries = this.zkretries;
|
||||
|
||||
do {
|
||||
String nodePath = ZKUtil.joinZNode(watcher.recoveringRegionsZNode, regionEncodeName);
|
||||
String nodePath = ZKUtil.joinZNode(watcher.znodePaths.recoveringRegionsZNode,
|
||||
regionEncodeName);
|
||||
long lastRecordedFlushedSequenceId = -1;
|
||||
try {
|
||||
long lastSequenceId =
|
||||
|
@ -680,14 +682,15 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
throws IOException, InterruptedIOException {
|
||||
|
||||
try {
|
||||
List<String> tasks = ZKUtil.listChildrenNoWatch(watcher, watcher.splitLogZNode);
|
||||
List<String> tasks = ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.splitLogZNode);
|
||||
if (tasks != null) {
|
||||
int listSize = tasks.size();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
String t = tasks.get(i);
|
||||
byte[] data;
|
||||
try {
|
||||
data = ZKUtil.getData(this.watcher, ZKUtil.joinZNode(watcher.splitLogZNode, t));
|
||||
data = ZKUtil.getData(this.watcher,
|
||||
ZKUtil.joinZNode(watcher.znodePaths.splitLogZNode, t));
|
||||
} catch (InterruptedException e) {
|
||||
throw new InterruptedIOException();
|
||||
}
|
||||
|
@ -715,11 +718,13 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
}
|
||||
|
||||
// remove recovering regions which doesn't have any RS associated with it
|
||||
List<String> regions = ZKUtil.listChildrenNoWatch(watcher, watcher.recoveringRegionsZNode);
|
||||
List<String> regions = ZKUtil.listChildrenNoWatch(watcher,
|
||||
watcher.znodePaths.recoveringRegionsZNode);
|
||||
if (regions != null) {
|
||||
int listSize = regions.size();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
String nodePath = ZKUtil.joinZNode(watcher.recoveringRegionsZNode, regions.get(i));
|
||||
String nodePath = ZKUtil.joinZNode(watcher.znodePaths.recoveringRegionsZNode,
|
||||
regions.get(i));
|
||||
List<String> regionFailedServers = ZKUtil.listChildrenNoWatch(watcher, nodePath);
|
||||
if (regionFailedServers == null || regionFailedServers.isEmpty()) {
|
||||
ZKUtil.deleteNode(watcher, nodePath);
|
||||
|
@ -754,7 +759,8 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
}
|
||||
|
||||
private List<String> listSplitLogTasks() throws KeeperException {
|
||||
List<String> taskOrRescanList = ZKUtil.listChildrenNoWatch(watcher, watcher.splitLogZNode);
|
||||
List<String> taskOrRescanList = ZKUtil.listChildrenNoWatch(watcher,
|
||||
watcher.znodePaths.splitLogZNode);
|
||||
if (taskOrRescanList == null || taskOrRescanList.isEmpty()) {
|
||||
return Collections.<String> emptyList();
|
||||
}
|
||||
|
@ -799,7 +805,8 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
|
||||
// Firstly check if there are outstanding recovering regions
|
||||
try {
|
||||
List<String> regions = ZKUtil.listChildrenNoWatch(watcher, watcher.recoveringRegionsZNode);
|
||||
List<String> regions = ZKUtil.listChildrenNoWatch(watcher,
|
||||
watcher.znodePaths.recoveringRegionsZNode);
|
||||
if (regions != null && !regions.isEmpty()) {
|
||||
hasRecoveringRegions = true;
|
||||
previousRecoveryMode = RecoveryMode.LOG_REPLAY;
|
||||
|
@ -815,8 +822,8 @@ public class ZKSplitLogManagerCoordination extends ZooKeeperListener implements
|
|||
for (int i = 0; i < listSize; i++) {
|
||||
String task = tasks.get(i);
|
||||
try {
|
||||
byte[] data =
|
||||
ZKUtil.getData(this.watcher, ZKUtil.joinZNode(watcher.splitLogZNode, task));
|
||||
byte[] data = ZKUtil.getData(this.watcher,
|
||||
ZKUtil.joinZNode(watcher.znodePaths.splitLogZNode, task));
|
||||
if (data == null) continue;
|
||||
SplitLogTask slt = SplitLogTask.parseFrom(data);
|
||||
previousRecoveryMode = slt.getMode();
|
||||
|
|
|
@ -103,7 +103,7 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements
|
|||
*/
|
||||
@Override
|
||||
public void nodeChildrenChanged(String path) {
|
||||
if (path.equals(watcher.splitLogZNode)) {
|
||||
if (path.equals(watcher.znodePaths.splitLogZNode)) {
|
||||
if (LOG.isTraceEnabled()) LOG.trace("tasks arrived or departed on " + path);
|
||||
synchronized (taskReadyLock) {
|
||||
this.taskReadySeq.incrementAndGet();
|
||||
|
@ -335,7 +335,7 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements
|
|||
int availableRSs = 1;
|
||||
try {
|
||||
List<String> regionServers =
|
||||
ZKUtil.listChildrenNoWatch(watcher, watcher.rsZNode);
|
||||
ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.rsZNode);
|
||||
availableRSs = Math.max(availableRSs, (regionServers == null) ? 0 : regionServers.size());
|
||||
} catch (KeeperException e) {
|
||||
// do nothing
|
||||
|
@ -411,7 +411,7 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements
|
|||
List<String> paths = null;
|
||||
paths = getTaskList();
|
||||
if (paths == null) {
|
||||
LOG.warn("Could not get tasks, did someone remove " + watcher.splitLogZNode
|
||||
LOG.warn("Could not get tasks, did someone remove " + watcher.znodePaths.splitLogZNode
|
||||
+ " ... worker thread exiting.");
|
||||
return;
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements
|
|||
// don't call ZKSplitLog.getNodeName() because that will lead to
|
||||
// double encoding of the path name
|
||||
if (this.calculateAvailableSplitters(numTasks) > 0) {
|
||||
grabTask(ZKUtil.joinZNode(watcher.splitLogZNode, paths.get(idx)));
|
||||
grabTask(ZKUtil.joinZNode(watcher.znodePaths.splitLogZNode, paths.get(idx)));
|
||||
} else {
|
||||
LOG.debug("Current region server " + server.getServerName() + " has "
|
||||
+ this.tasksInProgress.get() + " tasks in progress and can't take more.");
|
||||
|
@ -453,7 +453,8 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements
|
|||
int listSize = tmpCopy.size();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
String region = tmpCopy.get(i);
|
||||
String nodePath = ZKUtil.joinZNode(watcher.recoveringRegionsZNode, region);
|
||||
String nodePath = ZKUtil.joinZNode(watcher.znodePaths.recoveringRegionsZNode,
|
||||
region);
|
||||
try {
|
||||
if (ZKUtil.checkExists(watcher, nodePath) == -1) {
|
||||
server.getExecutorService().submit(
|
||||
|
@ -486,16 +487,15 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements
|
|||
// it will come out if worker thread exited.
|
||||
while (!shouldStop) {
|
||||
try {
|
||||
childrenPaths =
|
||||
ZKUtil.listChildrenAndWatchForNewChildren(watcher,
|
||||
watcher.splitLogZNode);
|
||||
childrenPaths = ZKUtil.listChildrenAndWatchForNewChildren(watcher,
|
||||
watcher.znodePaths.splitLogZNode);
|
||||
if (childrenPaths != null) {
|
||||
return childrenPaths;
|
||||
}
|
||||
} catch (KeeperException e) {
|
||||
LOG.warn("Could not get children of znode " + watcher.splitLogZNode, e);
|
||||
LOG.warn("Could not get children of znode " + watcher.znodePaths.splitLogZNode, e);
|
||||
}
|
||||
LOG.debug("Retry listChildren of znode " + watcher.splitLogZNode
|
||||
LOG.debug("Retry listChildren of znode " + watcher.znodePaths.splitLogZNode
|
||||
+ " after sleep for " + sleepTime + "ms!");
|
||||
Thread.sleep(sleepTime);
|
||||
}
|
||||
|
@ -511,14 +511,14 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements
|
|||
public boolean isReady() throws InterruptedException {
|
||||
int result = -1;
|
||||
try {
|
||||
result = ZKUtil.checkExists(watcher, watcher.splitLogZNode);
|
||||
result = ZKUtil.checkExists(watcher, watcher.znodePaths.splitLogZNode);
|
||||
} catch (KeeperException e) {
|
||||
// ignore
|
||||
LOG.warn("Exception when checking for " + watcher.splitLogZNode
|
||||
LOG.warn("Exception when checking for " + watcher.znodePaths.splitLogZNode
|
||||
+ " ... retrying", e);
|
||||
}
|
||||
if (result == -1) {
|
||||
LOG.info(watcher.splitLogZNode
|
||||
LOG.info(watcher.znodePaths.splitLogZNode
|
||||
+ " znode does not exist, waiting for master to create");
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ActiveMasterManager extends ZooKeeperListener {
|
|||
// 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.clusterStateZNode) && !master.isStopped()) {
|
||||
if(path.equals(watcher.znodePaths.clusterStateZNode) && !master.isStopped()) {
|
||||
clusterShutDown.set(true);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class ActiveMasterManager extends ZooKeeperListener {
|
|||
}
|
||||
|
||||
void handle(final String path) {
|
||||
if (path.equals(watcher.getMasterAddressZNode()) && !master.isStopped()) {
|
||||
if (path.equals(watcher.znodePaths.masterAddressZNode) && !master.isStopped()) {
|
||||
handleMasterNodeChange();
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class ActiveMasterManager extends ZooKeeperListener {
|
|||
// Watch the node and check if it exists.
|
||||
try {
|
||||
synchronized(clusterHasActiveMaster) {
|
||||
if (ZKUtil.watchAndCheckExists(watcher, watcher.getMasterAddressZNode())) {
|
||||
if (ZKUtil.watchAndCheckExists(watcher, watcher.znodePaths.masterAddressZNode)) {
|
||||
// A master node exists, there is an active master
|
||||
LOG.debug("A master is now available");
|
||||
clusterHasActiveMaster.set(true);
|
||||
|
@ -156,14 +156,14 @@ public class ActiveMasterManager extends ZooKeeperListener {
|
|||
boolean blockUntilBecomingActiveMaster(
|
||||
int checkInterval, MonitoredTask startupStatus) {
|
||||
String backupZNode = ZKUtil.joinZNode(
|
||||
this.watcher.backupMasterAddressesZNode, this.sn.toString());
|
||||
this.watcher.znodePaths.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.getMasterAddressZNode(), this.sn, infoPort)) {
|
||||
this.watcher.znodePaths.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)
|
||||
|
@ -187,7 +187,7 @@ public class ActiveMasterManager extends ZooKeeperListener {
|
|||
|
||||
String msg;
|
||||
byte[] bytes =
|
||||
ZKUtil.getDataAndWatch(this.watcher, this.watcher.getMasterAddressZNode());
|
||||
ZKUtil.getDataAndWatch(this.watcher, this.watcher.znodePaths.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");
|
||||
|
@ -204,7 +204,7 @@ public class ActiveMasterManager extends ZooKeeperListener {
|
|||
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.getMasterAddressZNode());
|
||||
ZKUtil.deleteNode(this.watcher, this.watcher.znodePaths.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.
|
||||
|
@ -244,7 +244,7 @@ public class ActiveMasterManager extends ZooKeeperListener {
|
|||
*/
|
||||
boolean hasActiveMaster() {
|
||||
try {
|
||||
if (ZKUtil.checkExists(watcher, watcher.getMasterAddressZNode()) >= 0) {
|
||||
if (ZKUtil.checkExists(watcher, watcher.znodePaths.masterAddressZNode) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ public class ActiveMasterManager extends ZooKeeperListener {
|
|||
LOG.warn("Failed get of master address: " + e.toString());
|
||||
}
|
||||
if (activeMaster != null && activeMaster.equals(this.sn)) {
|
||||
ZKUtil.deleteNode(watcher, watcher.getMasterAddressZNode());
|
||||
ZKUtil.deleteNode(watcher, watcher.znodePaths.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();
|
||||
|
|
|
@ -765,7 +765,7 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
LOG.info("Converting state from zk to new states:" + entry);
|
||||
tableStateManager.setTableState(entry.getKey(), entry.getValue());
|
||||
}
|
||||
ZKUtil.deleteChildrenRecursively(getZooKeeper(), getZooKeeper().tableZNode);
|
||||
ZKUtil.deleteChildrenRecursively(getZooKeeper(), getZooKeeper().znodePaths.tableZNode);
|
||||
|
||||
status.setStatus("Submitting log splitting work for previously failed region servers");
|
||||
metaBootstrap.processDeadServers();
|
||||
|
@ -1690,7 +1690,7 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
|
||||
private void startActiveMasterManager(int infoPort) throws KeeperException {
|
||||
String backupZNode = ZKUtil.joinZNode(
|
||||
zooKeeper.backupMasterAddressesZNode, serverName.toString());
|
||||
zooKeeper.znodePaths.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
|
||||
|
@ -2090,7 +2090,7 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
List<String> backupMasterStrings;
|
||||
try {
|
||||
backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper,
|
||||
this.zooKeeper.backupMasterAddressesZNode);
|
||||
this.zooKeeper.znodePaths.backupMasterAddressesZNode);
|
||||
} catch (KeeperException e) {
|
||||
LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e);
|
||||
backupMasterStrings = null;
|
||||
|
@ -2104,7 +2104,7 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
byte [] bytes;
|
||||
try {
|
||||
bytes = ZKUtil.getData(this.zooKeeper, ZKUtil.joinZNode(
|
||||
this.zooKeeper.backupMasterAddressesZNode, s));
|
||||
this.zooKeeper.znodePaths.backupMasterAddressesZNode, s));
|
||||
} catch (InterruptedException e) {
|
||||
throw new InterruptedIOException();
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
package org.apache.hadoop.hbase.master;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -126,14 +125,14 @@ public class MasterMetaBootstrap {
|
|||
try {
|
||||
List<String> metaReplicaZnodes = zooKeeper.getMetaReplicaNodes();
|
||||
for (String metaReplicaZnode : metaReplicaZnodes) {
|
||||
int replicaId = zooKeeper.getMetaReplicaIdFromZnode(metaReplicaZnode);
|
||||
int replicaId = zooKeeper.znodePaths.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.getZNodeForReplica(replicaId));
|
||||
ZKUtil.deleteNode(zooKeeper, zooKeeper.znodePaths.getZNodeForReplica(replicaId));
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -243,7 +242,7 @@ public class MasterMetaBootstrap {
|
|||
private Set<ServerName> getPreviouselyFailedMetaServersFromZK() throws KeeperException {
|
||||
final ZooKeeperWatcher zooKeeper = master.getZooKeeper();
|
||||
Set<ServerName> result = new HashSet<ServerName>();
|
||||
String metaRecoveringZNode = ZKUtil.joinZNode(zooKeeper.recoveringRegionsZNode,
|
||||
String metaRecoveringZNode = ZKUtil.joinZNode(zooKeeper.znodePaths.recoveringRegionsZNode,
|
||||
HRegionInfo.FIRST_META_REGIONINFO.getEncodedName());
|
||||
List<String> regionFailedServers = ZKUtil.listChildrenNoWatch(zooKeeper, metaRecoveringZNode);
|
||||
if (regionFailedServers == null) return result;
|
||||
|
|
|
@ -564,7 +564,7 @@ public class ServerManager {
|
|||
}
|
||||
|
||||
try {
|
||||
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.rsZNode);
|
||||
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode);
|
||||
if (servers == null || servers.size() == 0 || (servers.size() == 1
|
||||
&& servers.contains(sn.toString()))) {
|
||||
LOG.info("ZK shows there is only the master self online, exiting now");
|
||||
|
|
|
@ -316,7 +316,7 @@ public abstract class TableLockManager {
|
|||
}
|
||||
|
||||
private InterProcessLock createTableLock() {
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.tableLockZNode,
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.znodePaths.tableLockZNode,
|
||||
tableName.getNameAsString());
|
||||
|
||||
ZooKeeperProtos.TableLock data = ZooKeeperProtos.TableLock.newBuilder()
|
||||
|
@ -376,7 +376,7 @@ public abstract class TableLockManager {
|
|||
|
||||
public void visitAllLocks(MetadataHandler handler) throws IOException {
|
||||
for (String tableName : getTableNames()) {
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, tableName);
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.znodePaths.tableLockZNode, tableName);
|
||||
ZKInterProcessReadWriteLock lock = new ZKInterProcessReadWriteLock(
|
||||
zkWatcher, tableLockZNode, null);
|
||||
lock.readLock(null).visitLocks(handler);
|
||||
|
@ -388,7 +388,7 @@ public abstract class TableLockManager {
|
|||
|
||||
List<String> tableNames;
|
||||
try {
|
||||
tableNames = ZKUtil.listChildrenNoWatch(zkWatcher, zkWatcher.tableLockZNode);
|
||||
tableNames = ZKUtil.listChildrenNoWatch(zkWatcher, zkWatcher.znodePaths.tableLockZNode);
|
||||
} catch (KeeperException e) {
|
||||
LOG.error("Unexpected ZooKeeper error when listing children", e);
|
||||
throw new IOException("Unexpected ZooKeeper exception", e);
|
||||
|
@ -401,7 +401,7 @@ public abstract class TableLockManager {
|
|||
//get the table names
|
||||
try {
|
||||
for (String tableName : getTableNames()) {
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, tableName);
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.znodePaths.tableLockZNode, tableName);
|
||||
ZKInterProcessReadWriteLock lock = new ZKInterProcessReadWriteLock(
|
||||
zkWatcher, tableLockZNode, null);
|
||||
lock.writeLock(null).reapAllLocks();
|
||||
|
@ -418,7 +418,7 @@ public abstract class TableLockManager {
|
|||
//get the table names
|
||||
try {
|
||||
for (String tableName : getTableNames()) {
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, tableName);
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.znodePaths.tableLockZNode, tableName);
|
||||
ZKInterProcessReadWriteLock lock = new ZKInterProcessReadWriteLock(
|
||||
zkWatcher, tableLockZNode, null);
|
||||
lock.readLock(null).reapExpiredLocks(lockExpireTimeoutMs);
|
||||
|
@ -435,7 +435,7 @@ public abstract class TableLockManager {
|
|||
public void tableDeleted(TableName tableName) throws IOException {
|
||||
//table write lock from DeleteHandler is already released, just delete the parent znode
|
||||
String tableNameStr = tableName.getNameAsString();
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, tableNameStr);
|
||||
String tableLockZNode = ZKUtil.joinZNode(zkWatcher.znodePaths.tableLockZNode, tableNameStr);
|
||||
try {
|
||||
ZKUtil.deleteNode(zkWatcher, tableLockZNode);
|
||||
} catch (KeeperException ex) {
|
||||
|
|
|
@ -200,7 +200,8 @@ public class SweepJob {
|
|||
JavaSerialization.class.getName() + "," + WritableSerialization.class.getName());
|
||||
conf.set(SWEEP_JOB_ID, id);
|
||||
conf.set(SWEEP_JOB_SERVERNAME, serverName.toString());
|
||||
String tableLockNode = ZKUtil.joinZNode(zkw.tableLockZNode, lockName.getNameAsString());
|
||||
String tableLockNode = ZKUtil.joinZNode(zkw.znodePaths.tableLockZNode,
|
||||
lockName.getNameAsString());
|
||||
conf.set(SWEEP_JOB_TABLE_NODE, tableLockNode);
|
||||
job = prepareJob(tn, familyName, scan, conf);
|
||||
job.getConfiguration().set(TableInputFormat.SCAN_COLUMN_FAMILY, familyName);
|
||||
|
|
|
@ -78,7 +78,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 = ZKUtil.joinZNode(watcher.baseZNode, procDescription);
|
||||
this.baseZNode = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, procDescription);
|
||||
acquiredZnode = ZKUtil.joinZNode(baseZNode, ACQUIRED_BARRIER_ZNODE_DEFAULT);
|
||||
reachedZnode = ZKUtil.joinZNode(baseZNode, REACHED_BARRIER_ZNODE_DEFAULT);
|
||||
abortZnode = ZKUtil.joinZNode(baseZNode, ABORT_ZNODE_DEFAULT);
|
||||
|
|
|
@ -3225,7 +3225,7 @@ public class HRegionServer extends HasThread implements
|
|||
}
|
||||
|
||||
private String getMyEphemeralNodePath() {
|
||||
return ZKUtil.joinZNode(this.zooKeeper.rsZNode, getServerName().toString());
|
||||
return ZKUtil.joinZNode(this.zooKeeper.znodePaths.rsZNode, getServerName().toString());
|
||||
}
|
||||
|
||||
private boolean isHealthCheckerConfigured() {
|
||||
|
@ -3267,7 +3267,7 @@ public class HRegionServer extends HasThread implements
|
|||
|
||||
try {
|
||||
long lastRecordedFlushedSequenceId = -1;
|
||||
String nodePath = ZKUtil.joinZNode(this.zooKeeper.recoveringRegionsZNode,
|
||||
String nodePath = ZKUtil.joinZNode(this.zooKeeper.znodePaths.recoveringRegionsZNode,
|
||||
regionInfo.getEncodedName());
|
||||
// recovering-region level
|
||||
byte[] data;
|
||||
|
@ -3308,7 +3308,7 @@ public class HRegionServer extends HasThread implements
|
|||
String result = null;
|
||||
long maxZxid = 0;
|
||||
ZooKeeperWatcher zkw = this.getZooKeeper();
|
||||
String nodePath = ZKUtil.joinZNode(zkw.recoveringRegionsZNode, encodedRegionName);
|
||||
String nodePath = ZKUtil.joinZNode(zkw.znodePaths.recoveringRegionsZNode, encodedRegionName);
|
||||
List<String> failedServers = ZKUtil.listChildrenNoWatch(zkw, nodePath);
|
||||
if (failedServers == null || failedServers.isEmpty()) {
|
||||
return result;
|
||||
|
|
|
@ -147,7 +147,7 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
|
|||
*/
|
||||
protected static List<ServerName> fetchSlavesAddresses(ZooKeeperWatcher zkw)
|
||||
throws KeeperException {
|
||||
List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(zkw, zkw.rsZNode);
|
||||
List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(zkw, zkw.znodePaths.rsZNode);
|
||||
if (children == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint
|
|||
public PeerRegionServerListener(HBaseReplicationEndpoint replicationPeer) {
|
||||
super(replicationPeer.getZkw());
|
||||
this.replicationEndpoint = replicationPeer;
|
||||
this.regionServerListNode = replicationEndpoint.getZkw().rsZNode;
|
||||
this.regionServerListNode = replicationEndpoint.getZkw().znodePaths.rsZNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,7 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
|
|||
super(watcher);
|
||||
this.authManager = authManager;
|
||||
String aclZnodeParent = conf.get("zookeeper.znode.acl.parent", ACL_NODE);
|
||||
this.aclZNode = ZKUtil.joinZNode(watcher.baseZNode, aclZnodeParent);
|
||||
this.aclZNode = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, aclZnodeParent);
|
||||
executor = Executors.newSingleThreadExecutor(
|
||||
new DaemonThreadFactory("zk-permission-watcher"));
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
|
|||
*/
|
||||
public void writeToZookeeper(byte[] entry, byte[] permsData) {
|
||||
String entryName = Bytes.toString(entry);
|
||||
String zkNode = ZKUtil.joinZNode(watcher.baseZNode, ACL_NODE);
|
||||
String zkNode = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE);
|
||||
zkNode = ZKUtil.joinZNode(zkNode, entryName);
|
||||
|
||||
try {
|
||||
|
@ -267,7 +267,7 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
|
|||
* @param tableName
|
||||
*/
|
||||
public void deleteTableACLNode(final TableName tableName) {
|
||||
String zkNode = ZKUtil.joinZNode(watcher.baseZNode, ACL_NODE);
|
||||
String zkNode = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE);
|
||||
zkNode = ZKUtil.joinZNode(zkNode, tableName.getNameAsString());
|
||||
|
||||
try {
|
||||
|
@ -284,7 +284,7 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
|
|||
* Delete the acl notify node of namespace
|
||||
*/
|
||||
public void deleteNamespaceACLNode(final String namespace) {
|
||||
String zkNode = ZKUtil.joinZNode(watcher.baseZNode, ACL_NODE);
|
||||
String zkNode = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE);
|
||||
zkNode = ZKUtil.joinZNode(zkNode, AccessControlLists.NAMESPACE_PREFIX + namespace);
|
||||
|
||||
try {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ZKSecretWatcher extends ZooKeeperListener {
|
|||
super(watcher);
|
||||
this.secretManager = secretManager;
|
||||
String keyZNodeParent = conf.get("zookeeper.znode.tokenauth.parent", DEFAULT_ROOT_NODE);
|
||||
this.baseKeyZNode = ZKUtil.joinZNode(watcher.baseZNode, keyZNodeParent);
|
||||
this.baseKeyZNode = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, keyZNodeParent);
|
||||
this.keysParentZNode = ZKUtil.joinZNode(baseKeyZNode, DEFAULT_KEYS_PARENT);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ public class ZKVisibilityLabelWatcher extends ZooKeeperListener {
|
|||
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 = ZKUtil.joinZNode(watcher.baseZNode, labelZnodeParent);
|
||||
this.userAuthsZnode = ZKUtil.joinZNode(watcher.baseZNode, userAuthsZnodeParent);
|
||||
this.labelZnode = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, labelZnodeParent);
|
||||
this.userAuthsZnode = ZKUtil.joinZNode(watcher.znodePaths.baseZNode, userAuthsZnodeParent);
|
||||
}
|
||||
|
||||
public void start() throws KeeperException {
|
||||
|
|
|
@ -697,7 +697,7 @@ public class HBaseFsck extends Configured implements Closeable {
|
|||
private boolean setMasterInMaintenanceMode() throws IOException {
|
||||
RetryCounter retryCounter = createZNodeRetryCounterFactory.create();
|
||||
hbckEphemeralNodePath = ZKUtil.joinZNode(
|
||||
ZooKeeperWatcher.masterMaintZNode,
|
||||
zkw.znodePaths.masterMaintZNode,
|
||||
"hbck-" + Long.toString(EnvironmentEdgeManager.currentTime()));
|
||||
do {
|
||||
try {
|
||||
|
@ -3406,7 +3406,7 @@ public class HBaseFsck extends Configured implements Closeable {
|
|||
private void unassignMetaReplica(HbckInfo hi) throws IOException, InterruptedException,
|
||||
KeeperException {
|
||||
undeployRegions(hi);
|
||||
ZKUtil.deleteNode(zkw, zkw.getZNodeForReplica(hi.metaEntry.getReplicaId()));
|
||||
ZKUtil.deleteNode(zkw, zkw.znodePaths.getZNodeForReplica(hi.metaEntry.getReplicaId()));
|
||||
}
|
||||
|
||||
private void assignMetaReplica(int replicaId)
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ZKDataMigrator {
|
|||
public static Map<TableName, TableState.State> queryForTableStates(ZooKeeperWatcher zkw)
|
||||
throws KeeperException, InterruptedException {
|
||||
Map<TableName, TableState.State> rv = new HashMap<>();
|
||||
List<String> children = ZKUtil.listChildrenNoWatch(zkw, zkw.tableZNode);
|
||||
List<String> children = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.tableZNode);
|
||||
if (children == null)
|
||||
return rv;
|
||||
for (String child: children) {
|
||||
|
@ -94,7 +94,7 @@ public class ZKDataMigrator {
|
|||
private static ZooKeeperProtos.DeprecatedTableState.State getTableState(
|
||||
final ZooKeeperWatcher zkw, final TableName tableName)
|
||||
throws KeeperException, InterruptedException {
|
||||
String znode = ZKUtil.joinZNode(zkw.tableZNode, tableName.getNameAsString());
|
||||
String znode = ZKUtil.joinZNode(zkw.znodePaths.tableZNode, tableName.getNameAsString());
|
||||
byte [] data = ZKUtil.getData(zkw, znode);
|
||||
if (data == null || data.length <= 0) return null;
|
||||
try {
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ReplicationChecker {
|
|||
}
|
||||
|
||||
String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication");
|
||||
String replicationZNode = ZKUtil.joinZNode(this.zkw.baseZNode, replicationZNodeName);
|
||||
String replicationZNode = ZKUtil.joinZNode(this.zkw.znodePaths.baseZNode, replicationZNodeName);
|
||||
String hfileRefsZNodeName =
|
||||
conf.get(ReplicationStateZKBase.ZOOKEEPER_ZNODE_REPLICATION_HFILE_REFS_KEY,
|
||||
ReplicationStateZKBase.ZOOKEEPER_ZNODE_REPLICATION_HFILE_REFS_DEFAULT);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ClusterStatusTracker extends ZooKeeperNodeTracker {
|
|||
* @param abortable
|
||||
*/
|
||||
public ClusterStatusTracker(ZooKeeperWatcher watcher, Abortable abortable) {
|
||||
super(watcher, watcher.clusterStateZNode, abortable);
|
||||
super(watcher, watcher.znodePaths.clusterStateZNode, abortable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,9 +66,9 @@ public class ClusterStatusTracker extends ZooKeeperNodeTracker {
|
|||
throws KeeperException {
|
||||
byte [] upData = toByteArray();
|
||||
try {
|
||||
ZKUtil.createAndWatch(watcher, watcher.clusterStateZNode, upData);
|
||||
ZKUtil.createAndWatch(watcher, watcher.znodePaths.clusterStateZNode, upData);
|
||||
} catch(KeeperException.NodeExistsException nee) {
|
||||
ZKUtil.setData(watcher, watcher.clusterStateZNode, upData);
|
||||
ZKUtil.setData(watcher, watcher.znodePaths.clusterStateZNode, upData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,10 @@ public class ClusterStatusTracker extends ZooKeeperNodeTracker {
|
|||
public void setClusterDown()
|
||||
throws KeeperException {
|
||||
try {
|
||||
ZKUtil.deleteNode(watcher, watcher.clusterStateZNode);
|
||||
ZKUtil.deleteNode(watcher, watcher.znodePaths.clusterStateZNode);
|
||||
} catch(KeeperException.NoNodeException nne) {
|
||||
LOG.warn("Attempted to set cluster as down but already down, cluster " +
|
||||
"state node (" + watcher.clusterStateZNode + ") not found");
|
||||
"state node (" + watcher.znodePaths.clusterStateZNode + ") not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class DrainingServerTracker extends ZooKeeperListener {
|
|||
public void start() throws KeeperException, IOException {
|
||||
watcher.registerListener(this);
|
||||
List<String> servers =
|
||||
ZKUtil.listChildrenAndWatchThem(watcher, watcher.drainingZNode);
|
||||
ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.drainingZNode);
|
||||
add(servers);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class DrainingServerTracker extends ZooKeeperListener {
|
|||
|
||||
@Override
|
||||
public void nodeDeleted(final String path) {
|
||||
if(path.startsWith(watcher.drainingZNode)) {
|
||||
if(path.startsWith(watcher.znodePaths.drainingZNode)) {
|
||||
final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(path));
|
||||
LOG.info("Draining RS node deleted, removing from list [" +
|
||||
sn + "]");
|
||||
|
@ -106,10 +106,10 @@ public class DrainingServerTracker extends ZooKeeperListener {
|
|||
|
||||
@Override
|
||||
public void nodeChildrenChanged(final String path) {
|
||||
if(path.equals(watcher.drainingZNode)) {
|
||||
if(path.equals(watcher.znodePaths.drainingZNode)) {
|
||||
try {
|
||||
final List<String> newNodes =
|
||||
ZKUtil.listChildrenAndWatchThem(watcher, watcher.drainingZNode);
|
||||
ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.drainingZNode);
|
||||
add(newNodes);
|
||||
} catch (KeeperException e) {
|
||||
abortable.abort("Unexpected zk exception getting RS nodes", e);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class LoadBalancerTracker extends ZooKeeperNodeTracker {
|
|||
|
||||
public LoadBalancerTracker(ZooKeeperWatcher watcher,
|
||||
Abortable abortable) {
|
||||
super(watcher, watcher.balancerZNode, abortable);
|
||||
super(watcher, watcher.znodePaths.balancerZNode, abortable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,11 +64,11 @@ public class LoadBalancerTracker extends ZooKeeperNodeTracker {
|
|||
public void setBalancerOn(boolean balancerOn) throws KeeperException {
|
||||
byte [] upData = toByteArray(balancerOn);
|
||||
try {
|
||||
ZKUtil.setData(watcher, watcher.balancerZNode, upData);
|
||||
ZKUtil.setData(watcher, watcher.znodePaths.balancerZNode, upData);
|
||||
} catch(KeeperException.NoNodeException nne) {
|
||||
ZKUtil.createAndWatch(watcher, watcher.balancerZNode, upData);
|
||||
ZKUtil.createAndWatch(watcher, watcher.znodePaths.balancerZNode, upData);
|
||||
}
|
||||
super.nodeDataChanged(watcher.balancerZNode);
|
||||
super.nodeDataChanged(watcher.znodePaths.balancerZNode);
|
||||
}
|
||||
|
||||
private byte [] toByteArray(boolean isBalancerOn) {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class MasterMaintenanceModeTracker extends ZooKeeperListener {
|
|||
}
|
||||
|
||||
private void update(String path) {
|
||||
if (path.startsWith(ZooKeeperWatcher.masterMaintZNode)) {
|
||||
if (path.startsWith(watcher.znodePaths.masterMaintZNode)) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class MasterMaintenanceModeTracker extends ZooKeeperListener {
|
|||
private void update() {
|
||||
try {
|
||||
List<String> children =
|
||||
ZKUtil.listChildrenAndWatchForNewChildren(watcher, ZooKeeperWatcher.masterMaintZNode);
|
||||
ZKUtil.listChildrenAndWatchForNewChildren(watcher, watcher.znodePaths.masterMaintZNode);
|
||||
hasChildren = (children != null && children.size() > 0);
|
||||
} catch (KeeperException e) {
|
||||
// Ignore the ZK keeper exception
|
||||
|
|
|
@ -54,7 +54,7 @@ public class RecoveringRegionWatcher extends ZooKeeperListener {
|
|||
}
|
||||
|
||||
String parentPath = path.substring(0, path.lastIndexOf('/'));
|
||||
if (!this.watcher.recoveringRegionsZNode.equalsIgnoreCase(parentPath)) {
|
||||
if (!this.watcher.znodePaths.recoveringRegionsZNode.equalsIgnoreCase(parentPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class RecoveringRegionWatcher extends ZooKeeperListener {
|
|||
*/
|
||||
private void registerWatcher(String path) {
|
||||
String parentPath = path.substring(0, path.lastIndexOf('/'));
|
||||
if (!this.watcher.recoveringRegionsZNode.equalsIgnoreCase(parentPath)) {
|
||||
if (!this.watcher.znodePaths.recoveringRegionsZNode.equalsIgnoreCase(parentPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RegionNormalizerTracker extends ZooKeeperNodeTracker {
|
|||
|
||||
public RegionNormalizerTracker(ZooKeeperWatcher watcher,
|
||||
Abortable abortable) {
|
||||
super(watcher, watcher.getRegionNormalizerZNode(), abortable);
|
||||
super(watcher, watcher.znodePaths.regionNormalizerZNode, abortable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,11 +64,11 @@ public class RegionNormalizerTracker extends ZooKeeperNodeTracker {
|
|||
public void setNormalizerOn(boolean normalizerOn) throws KeeperException {
|
||||
byte [] upData = toByteArray(normalizerOn);
|
||||
try {
|
||||
ZKUtil.setData(watcher, watcher.getRegionNormalizerZNode(), upData);
|
||||
ZKUtil.setData(watcher, watcher.znodePaths.regionNormalizerZNode, upData);
|
||||
} catch(KeeperException.NoNodeException nne) {
|
||||
ZKUtil.createAndWatch(watcher, watcher.getRegionNormalizerZNode(), upData);
|
||||
ZKUtil.createAndWatch(watcher, watcher.znodePaths.regionNormalizerZNode, upData);
|
||||
}
|
||||
super.nodeDataChanged(watcher.getRegionNormalizerZNode());
|
||||
super.nodeDataChanged(watcher.znodePaths.regionNormalizerZNode);
|
||||
}
|
||||
|
||||
private byte [] toByteArray(boolean isNormalizerOn) {
|
||||
|
|
|
@ -71,7 +71,7 @@ public class RegionServerTracker extends ZooKeeperListener {
|
|||
public void start() throws KeeperException, IOException {
|
||||
watcher.registerListener(this);
|
||||
List<String> servers =
|
||||
ZKUtil.listChildrenAndWatchThem(watcher, watcher.rsZNode);
|
||||
ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.rsZNode);
|
||||
add(servers);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class RegionServerTracker extends ZooKeeperListener {
|
|||
if (regionServers.get(sn) == null) {
|
||||
RegionServerInfo.Builder rsInfoBuilder = RegionServerInfo.newBuilder();
|
||||
try {
|
||||
String nodePath = ZKUtil.joinZNode(watcher.rsZNode, n);
|
||||
String nodePath = ZKUtil.joinZNode(watcher.znodePaths.rsZNode, n);
|
||||
byte[] data = ZKUtil.getData(watcher, nodePath);
|
||||
if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) {
|
||||
int magicLen = ProtobufUtil.lengthOfPBMagic();
|
||||
|
@ -113,7 +113,7 @@ public class RegionServerTracker extends ZooKeeperListener {
|
|||
|
||||
@Override
|
||||
public void nodeDeleted(String path) {
|
||||
if (path.startsWith(watcher.rsZNode)) {
|
||||
if (path.startsWith(watcher.znodePaths.rsZNode)) {
|
||||
String serverName = ZKUtil.getNodeName(path);
|
||||
LOG.info("RegionServer ephemeral node deleted, processing expiration [" +
|
||||
serverName + "]");
|
||||
|
@ -130,11 +130,11 @@ public class RegionServerTracker extends ZooKeeperListener {
|
|||
|
||||
@Override
|
||||
public void nodeChildrenChanged(String path) {
|
||||
if (path.equals(watcher.rsZNode)
|
||||
if (path.equals(watcher.znodePaths.rsZNode)
|
||||
&& !server.isAborted() && !server.isStopped()) {
|
||||
try {
|
||||
List<String> servers =
|
||||
ZKUtil.listChildrenAndWatchThem(watcher, watcher.rsZNode);
|
||||
ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.rsZNode);
|
||||
add(servers);
|
||||
} catch (IOException e) {
|
||||
server.abort("Unexpected zk exception getting RS nodes", e);
|
||||
|
|
|
@ -46,15 +46,15 @@ public class SplitOrMergeTracker {
|
|||
public SplitOrMergeTracker(ZooKeeperWatcher watcher, Configuration conf,
|
||||
Abortable abortable) {
|
||||
try {
|
||||
if (ZKUtil.checkExists(watcher, watcher.getSwitchZNode()) < 0) {
|
||||
ZKUtil.createAndFailSilent(watcher, watcher.getSwitchZNode());
|
||||
if (ZKUtil.checkExists(watcher, watcher.znodePaths.switchZNode) < 0) {
|
||||
ZKUtil.createAndFailSilent(watcher, watcher.znodePaths.switchZNode);
|
||||
}
|
||||
} catch (KeeperException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
splitZnode = ZKUtil.joinZNode(watcher.getSwitchZNode(),
|
||||
splitZnode = ZKUtil.joinZNode(watcher.znodePaths.switchZNode,
|
||||
conf.get("zookeeper.znode.switch.split", "split"));
|
||||
mergeZnode = ZKUtil.joinZNode(watcher.getSwitchZNode(),
|
||||
mergeZnode = ZKUtil.joinZNode(watcher.znodePaths.switchZNode,
|
||||
conf.get("zookeeper.znode.switch.merge", "merge"));
|
||||
splitStateTracker = new SwitchStateTracker(watcher, splitZnode, abortable);
|
||||
mergeStateTracker = new SwitchStateTracker(watcher, mergeZnode, abortable);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ZKSplitLog {
|
|||
* @param filename log file name (only the basename)
|
||||
*/
|
||||
public static String getEncodedNodeName(ZooKeeperWatcher zkw, String filename) {
|
||||
return ZKUtil.joinZNode(zkw.splitLogZNode, encode(filename));
|
||||
return ZKUtil.joinZNode(zkw.znodePaths.splitLogZNode, encode(filename));
|
||||
}
|
||||
|
||||
public static String getFileName(String node) {
|
||||
|
@ -75,7 +75,7 @@ public class ZKSplitLog {
|
|||
}
|
||||
|
||||
public static String getRescanNode(ZooKeeperWatcher zkw) {
|
||||
return ZKUtil.joinZNode(zkw.splitLogZNode, "RESCAN");
|
||||
return ZKUtil.joinZNode(zkw.znodePaths.splitLogZNode, "RESCAN");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,7 +106,7 @@ public class ZKSplitLog {
|
|||
|
||||
public static boolean isTaskPath(ZooKeeperWatcher zkw, String path) {
|
||||
String dirname = path.substring(0, path.lastIndexOf('/'));
|
||||
return dirname.equals(zkw.splitLogZNode);
|
||||
return dirname.equals(zkw.znodePaths.splitLogZNode);
|
||||
}
|
||||
|
||||
public static Path getSplitLogDir(Path rootdir, String tmpname) {
|
||||
|
@ -153,7 +153,7 @@ public class ZKSplitLog {
|
|||
isRegionMarkedRecoveringInZK(ZooKeeperWatcher zkw, String regionEncodedName)
|
||||
throws KeeperException {
|
||||
boolean result = false;
|
||||
String nodePath = ZKUtil.joinZNode(zkw.recoveringRegionsZNode, regionEncodedName);
|
||||
String nodePath = ZKUtil.joinZNode(zkw.znodePaths.recoveringRegionsZNode, regionEncodedName);
|
||||
|
||||
byte[] node = ZKUtil.getDataAndWatch(zkw, nodePath);
|
||||
if (node != null) {
|
||||
|
@ -182,10 +182,10 @@ public class ZKSplitLog {
|
|||
if (regions == null) {
|
||||
// remove all children under /home/recovering-regions
|
||||
LOG.debug("Garbage collecting all recovering region znodes");
|
||||
ZKUtil.deleteChildrenRecursively(watcher, watcher.recoveringRegionsZNode);
|
||||
ZKUtil.deleteChildrenRecursively(watcher, watcher.znodePaths.recoveringRegionsZNode);
|
||||
} else {
|
||||
for (String curRegion : regions) {
|
||||
String nodePath = ZKUtil.joinZNode(watcher.recoveringRegionsZNode, curRegion);
|
||||
String nodePath = ZKUtil.joinZNode(watcher.znodePaths.recoveringRegionsZNode, curRegion);
|
||||
ZKUtil.deleteNodeRecursively(watcher, nodePath);
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ public class ZKSplitLog {
|
|||
// Therefore, in this mode we need to fetch last sequence Ids from ZK where we keep history of
|
||||
// last flushed sequence Id for each failed RS instance.
|
||||
RegionStoreSequenceIds result = null;
|
||||
String nodePath = ZKUtil.joinZNode(zkw.recoveringRegionsZNode, encodedRegionName);
|
||||
String nodePath = ZKUtil.joinZNode(zkw.znodePaths.recoveringRegionsZNode, encodedRegionName);
|
||||
nodePath = ZKUtil.joinZNode(nodePath, serverName);
|
||||
try {
|
||||
byte[] data;
|
||||
|
|
|
@ -131,7 +131,7 @@ public class TestMetaWithReplicas {
|
|||
for (int i = 1; i < 3; i++) {
|
||||
String secZnode = ZKUtil.joinZNode(baseZNode,
|
||||
conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + i);
|
||||
String str = zkw.getZNodeForReplica(i);
|
||||
String str = zkw.znodePaths.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);
|
||||
|
@ -353,7 +353,7 @@ public class TestMetaWithReplicas {
|
|||
HBaseFsckRepair.closeRegionSilentlyAndWait(c,
|
||||
rl.getRegionLocation(2).getServerName(), rl.getRegionLocation(2).getRegionInfo());
|
||||
ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
|
||||
ZKUtil.deleteNode(zkw, zkw.getZNodeForReplica(2));
|
||||
ZKUtil.deleteNode(zkw, zkw.znodePaths.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});
|
||||
|
|
|
@ -72,8 +72,8 @@ public class TestActiveMasterManager {
|
|||
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||
"testActiveMasterManagerFromZK", null, true);
|
||||
try {
|
||||
ZKUtil.deleteNode(zk, zk.getMasterAddressZNode());
|
||||
ZKUtil.deleteNode(zk, zk.clusterStateZNode);
|
||||
ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode);
|
||||
ZKUtil.deleteNode(zk, zk.znodePaths.clusterStateZNode);
|
||||
} catch(KeeperException.NoNodeException nne) {}
|
||||
|
||||
// Create the master node with a dummy address
|
||||
|
@ -114,8 +114,8 @@ public class TestActiveMasterManager {
|
|||
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||
"testActiveMasterManagerFromZK", null, true);
|
||||
try {
|
||||
ZKUtil.deleteNode(zk, zk.getMasterAddressZNode());
|
||||
ZKUtil.deleteNode(zk, zk.clusterStateZNode);
|
||||
ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode);
|
||||
ZKUtil.deleteNode(zk, zk.znodePaths.clusterStateZNode);
|
||||
} catch(KeeperException.NoNodeException nne) {}
|
||||
|
||||
// Create the master node with a dummy address
|
||||
|
@ -160,11 +160,11 @@ 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.getMasterAddressZNode());
|
||||
NodeDeletionListener listener = new NodeDeletionListener(zk, zk.znodePaths.masterAddressZNode);
|
||||
zk.registerListener(listener);
|
||||
|
||||
LOG.info("Deleting master node");
|
||||
ZKUtil.deleteNode(zk, zk.getMasterAddressZNode());
|
||||
ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode);
|
||||
|
||||
// Wait for the node to be deleted
|
||||
LOG.info("Waiting for active master manager to be notified");
|
||||
|
@ -184,7 +184,7 @@ public class TestActiveMasterManager {
|
|||
assertTrue(t.isActiveMaster);
|
||||
|
||||
LOG.info("Deleting master node");
|
||||
ZKUtil.deleteNode(zk, zk.getMasterAddressZNode());
|
||||
ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -459,7 +459,7 @@ public class TestDistributedLogSplitting {
|
|||
@Override
|
||||
public boolean evaluate() throws Exception {
|
||||
List<String> recoveringRegions = zkw.getRecoverableZooKeeper().getChildren(
|
||||
zkw.recoveringRegionsZNode, false);
|
||||
zkw.znodePaths.recoveringRegionsZNode, false);
|
||||
return (recoveringRegions != null && recoveringRegions.size() == 0);
|
||||
}
|
||||
});
|
||||
|
@ -566,7 +566,7 @@ public class TestDistributedLogSplitting {
|
|||
@Override
|
||||
public boolean evaluate() throws Exception {
|
||||
List<String> recoveringRegions = zkw.getRecoverableZooKeeper().getChildren(
|
||||
zkw.recoveringRegionsZNode, false);
|
||||
zkw.znodePaths.recoveringRegionsZNode, false);
|
||||
boolean done = recoveringRegions != null && recoveringRegions.size() == 0;
|
||||
if (!done) {
|
||||
LOG.info("Recovering regions: " + recoveringRegions);
|
||||
|
@ -658,7 +658,7 @@ public class TestDistributedLogSplitting {
|
|||
@Override
|
||||
public boolean evaluate() throws Exception {
|
||||
List<String> recoveringRegions = zkw.getRecoverableZooKeeper().getChildren(
|
||||
zkw.recoveringRegionsZNode, false);
|
||||
zkw.znodePaths.recoveringRegionsZNode, false);
|
||||
return (recoveringRegions != null && recoveringRegions.size() == 0);
|
||||
}
|
||||
});
|
||||
|
@ -702,7 +702,7 @@ public class TestDistributedLogSplitting {
|
|||
slm.markRegionsRecovering(secondFailedServer, regionSet);
|
||||
|
||||
List<String> recoveringRegions = ZKUtil.listChildrenNoWatch(zkw,
|
||||
ZKUtil.joinZNode(zkw.recoveringRegionsZNode, region.getEncodedName()));
|
||||
ZKUtil.joinZNode(zkw.znodePaths.recoveringRegionsZNode, region.getEncodedName()));
|
||||
|
||||
assertEquals(recoveringRegions.size(), 2);
|
||||
|
||||
|
@ -859,7 +859,7 @@ public class TestDistributedLogSplitting {
|
|||
@Override
|
||||
public boolean evaluate() throws Exception {
|
||||
List<String> recoveringRegions = zkw.getRecoverableZooKeeper().getChildren(
|
||||
zkw.recoveringRegionsZNode, false);
|
||||
zkw.znodePaths.recoveringRegionsZNode, false);
|
||||
ServerManager serverManager = master.getServerManager();
|
||||
return (!serverManager.areDeadServersInProgress() &&
|
||||
recoveringRegions != null && recoveringRegions.size() == 0);
|
||||
|
@ -1104,7 +1104,7 @@ public class TestDistributedLogSplitting {
|
|||
@Override
|
||||
public boolean evaluate() throws Exception {
|
||||
List<String> recoveringRegions = zkw.getRecoverableZooKeeper().getChildren(
|
||||
zkw.recoveringRegionsZNode, false);
|
||||
zkw.znodePaths.recoveringRegionsZNode, false);
|
||||
return (recoveringRegions != null && recoveringRegions.size() == 0);
|
||||
}
|
||||
});
|
||||
|
@ -1210,7 +1210,7 @@ public class TestDistributedLogSplitting {
|
|||
master.getMasterWalManager().prepareLogReplay(hrs.getServerName(), userRegionSet);
|
||||
boolean isMetaRegionInRecovery = false;
|
||||
List<String> recoveringRegions =
|
||||
zkw.getRecoverableZooKeeper().getChildren(zkw.recoveringRegionsZNode, false);
|
||||
zkw.getRecoverableZooKeeper().getChildren(zkw.znodePaths.recoveringRegionsZNode, false);
|
||||
for (String curEncodedRegionName : recoveringRegions) {
|
||||
if (curEncodedRegionName.equals(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName())) {
|
||||
isMetaRegionInRecovery = true;
|
||||
|
@ -1223,7 +1223,7 @@ public class TestDistributedLogSplitting {
|
|||
|
||||
isMetaRegionInRecovery = false;
|
||||
recoveringRegions =
|
||||
zkw.getRecoverableZooKeeper().getChildren(zkw.recoveringRegionsZNode, false);
|
||||
zkw.getRecoverableZooKeeper().getChildren(zkw.znodePaths.recoveringRegionsZNode, false);
|
||||
for (String curEncodedRegionName : recoveringRegions) {
|
||||
if (curEncodedRegionName.equals(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName())) {
|
||||
isMetaRegionInRecovery = true;
|
||||
|
|
|
@ -70,7 +70,7 @@ public class TestHMasterRPCException {
|
|||
|
||||
CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
|
||||
ZooKeeperWatcher watcher = testUtil.getZooKeeperWatcher();
|
||||
ZKUtil.createWithParents(watcher, watcher.getMasterAddressZNode(), Bytes.toBytes("fake:123"));
|
||||
ZKUtil.createWithParents(watcher, watcher.znodePaths.masterAddressZNode, Bytes.toBytes("fake:123"));
|
||||
master = new HMaster(conf, cp);
|
||||
rpcClient = RpcClientFactory.createClient(conf, HConstants.CLUSTER_ID_DEFAULT);
|
||||
}
|
||||
|
@ -107,11 +107,11 @@ public class TestHMasterRPCException {
|
|||
LOG.info("Expected exception: ", ie);
|
||||
if (!fakeZNodeDelete) {
|
||||
testUtil.getZooKeeperWatcher().getRecoverableZooKeeper()
|
||||
.delete(testUtil.getZooKeeperWatcher().getMasterAddressZNode(), -1);
|
||||
.delete(testUtil.getZooKeeperWatcher().znodePaths.masterAddressZNode, -1);
|
||||
fakeZNodeDelete = true;
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public class TestMasterNoCluster {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
ZKUtil.deleteNodeRecursively(zkw, zkw.baseZNode);
|
||||
ZKUtil.deleteNodeRecursively(zkw, zkw.znodePaths.baseZNode);
|
||||
zkw.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
|
|||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||
import org.apache.hadoop.hbase.regionserver.MetricsRegionServer;
|
||||
import org.apache.hadoop.hbase.regionserver.MetricsRegionServerWrapperStub;
|
||||
|
@ -98,6 +99,7 @@ public class TestMasterStatusServlet {
|
|||
|
||||
// Fake ZKW
|
||||
ZooKeeperWatcher zkw = Mockito.mock(ZooKeeperWatcher.class);
|
||||
Mockito.doReturn(new ZNodePaths(conf)).when(zkw).getZNodePaths();
|
||||
Mockito.doReturn("fakequorum").when(zkw).getQuorum();
|
||||
Mockito.doReturn(zkw).when(master).getZooKeeper();
|
||||
|
||||
|
|
|
@ -83,9 +83,10 @@ public class TestMasterWalManager {
|
|||
zkw.getRecoverableZooKeeper().create(ZKSplitLog.getEncodedNodeName(zkw, walPath),
|
||||
new SplitLogTask.Owned(inRecoveryServerName, mwm.getLogRecoveryMode()).toByteArray(),
|
||||
Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
|
||||
String staleRegionPath = ZKUtil.joinZNode(zkw.recoveringRegionsZNode, staleRegion);
|
||||
String staleRegionPath = ZKUtil.joinZNode(zkw.znodePaths.recoveringRegionsZNode, staleRegion);
|
||||
ZKUtil.createWithParents(zkw, staleRegionPath);
|
||||
String inRecoveringRegionPath = ZKUtil.joinZNode(zkw.recoveringRegionsZNode, failedRegion);
|
||||
String inRecoveringRegionPath = ZKUtil.joinZNode(zkw.znodePaths.recoveringRegionsZNode,
|
||||
failedRegion);
|
||||
inRecoveringRegionPath = ZKUtil.joinZNode(inRecoveringRegionPath,
|
||||
inRecoveryServerName.getServerName());
|
||||
ZKUtil.createWithParents(zkw, inRecoveringRegionPath);
|
||||
|
@ -97,8 +98,8 @@ public class TestMasterWalManager {
|
|||
assertFalse(ZKUtil.checkExists(zkw, staleRegionPath) != -1);
|
||||
assertTrue(ZKUtil.checkExists(zkw, inRecoveringRegionPath) != -1);
|
||||
|
||||
ZKUtil.deleteChildrenRecursively(zkw, zkw.recoveringRegionsZNode);
|
||||
ZKUtil.deleteChildrenRecursively(zkw, zkw.splitLogZNode);
|
||||
ZKUtil.deleteChildrenRecursively(zkw, zkw.znodePaths.recoveringRegionsZNode);
|
||||
ZKUtil.deleteChildrenRecursively(zkw, zkw.znodePaths.splitLogZNode);
|
||||
zkw.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ 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 =
|
||||
ZKUtil.joinZNode(master.getZooKeeper().rsZNode, metaServerName.toString());
|
||||
ZKUtil.joinZNode(master.getZooKeeper().znodePaths.rsZNode, metaServerName.toString());
|
||||
ZKUtil.deleteNode(master.getZooKeeper(), rsEphemeralNodePath);
|
||||
// Wait for SSH to finish
|
||||
final ServerManager serverManager = master.getServerManager();
|
||||
|
|
|
@ -134,13 +134,13 @@ public class TestSplitLogManager {
|
|||
new ZooKeeperWatcher(conf, "split-log-manager-tests" + UUID.randomUUID().toString(), null);
|
||||
master = new DummyMasterServices(zkw, conf);
|
||||
|
||||
ZKUtil.deleteChildrenRecursively(zkw, zkw.baseZNode);
|
||||
ZKUtil.createAndFailSilent(zkw, zkw.baseZNode);
|
||||
assertTrue(ZKUtil.checkExists(zkw, zkw.baseZNode) != -1);
|
||||
LOG.debug(zkw.baseZNode + " created");
|
||||
ZKUtil.createAndFailSilent(zkw, zkw.splitLogZNode);
|
||||
assertTrue(ZKUtil.checkExists(zkw, zkw.splitLogZNode) != -1);
|
||||
LOG.debug(zkw.splitLogZNode + " created");
|
||||
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");
|
||||
|
||||
resetCounters();
|
||||
|
||||
|
@ -567,7 +567,7 @@ public class TestSplitLogManager {
|
|||
LOG.info("testRecoveryRegionRemovedFromZK");
|
||||
conf.setBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, false);
|
||||
String nodePath =
|
||||
ZKUtil.joinZNode(zkw.recoveringRegionsZNode,
|
||||
ZKUtil.joinZNode(zkw.znodePaths.recoveringRegionsZNode,
|
||||
HRegionInfo.FIRST_META_REGIONINFO.getEncodedName());
|
||||
ZKUtil.createSetData(zkw, nodePath, ZKUtil.positionToByteArray(0L));
|
||||
|
||||
|
@ -575,7 +575,7 @@ public class TestSplitLogManager {
|
|||
slm.removeStaleRecoveringRegions(null);
|
||||
|
||||
List<String> recoveringRegions =
|
||||
zkw.getRecoverableZooKeeper().getChildren(zkw.recoveringRegionsZNode, false);
|
||||
zkw.getRecoverableZooKeeper().getChildren(zkw.znodePaths.recoveringRegionsZNode, false);
|
||||
|
||||
assertTrue("Recovery regions isn't cleaned", recoveringRegions.isEmpty());
|
||||
}
|
||||
|
|
|
@ -220,7 +220,8 @@ public class TestTableLockManager {
|
|||
|
||||
//ensure that znode for the table node has been deleted
|
||||
final ZooKeeperWatcher zkWatcher = TEST_UTIL.getZooKeeperWatcher();
|
||||
final String znode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, TABLE_NAME.getNameAsString());
|
||||
final String znode = ZKUtil.joinZNode(zkWatcher.znodePaths.tableLockZNode,
|
||||
TABLE_NAME.getNameAsString());
|
||||
|
||||
TEST_UTIL.waitFor(5000, new Waiter.Predicate<Exception>() {
|
||||
@Override
|
||||
|
@ -230,7 +231,7 @@ public class TestTableLockManager {
|
|||
}
|
||||
});
|
||||
int ver = ZKUtil.checkExists(zkWatcher,
|
||||
ZKUtil.joinZNode(zkWatcher.tableLockZNode, TABLE_NAME.getNameAsString()));
|
||||
ZKUtil.joinZNode(zkWatcher.znodePaths.tableLockZNode, TABLE_NAME.getNameAsString()));
|
||||
assertTrue("Unexpected znode version " + ver, ver < 0);
|
||||
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class TestTableStateManager {
|
|||
private void setTableStateInZK(ZooKeeperWatcher watcher, final TableName tableName,
|
||||
final ZooKeeperProtos.DeprecatedTableState.State state)
|
||||
throws KeeperException, IOException {
|
||||
String znode = ZKUtil.joinZNode(watcher.tableZNode, tableName.getNameAsString());
|
||||
String znode = ZKUtil.joinZNode(watcher.znodePaths.tableZNode, tableName.getNameAsString());
|
||||
if (ZKUtil.checkExists(watcher, znode) == -1) {
|
||||
ZKUtil.createAndFailSilent(watcher, znode);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class TestMobSweepMapper {
|
|||
ZooKeeperWatcher zkw = new ZooKeeperWatcher(configuration, "1", new DummyMobAbortable());
|
||||
TableName tn = TableName.valueOf("testSweepMapper");
|
||||
TableName lockName = MobUtils.getTableLockName(tn);
|
||||
String znode = ZKUtil.joinZNode(zkw.tableLockZNode, lockName.getNameAsString());
|
||||
String znode = ZKUtil.joinZNode(zkw.znodePaths.tableLockZNode, lockName.getNameAsString());
|
||||
configuration.set(SweepJob.SWEEP_JOB_ID, "1");
|
||||
configuration.set(SweepJob.SWEEP_JOB_TABLE_NODE, znode);
|
||||
ServerName serverName = SweepJob.getCurrentServerName(configuration);
|
||||
|
|
|
@ -162,7 +162,7 @@ public class TestMobSweepReducer {
|
|||
|
||||
ZooKeeperWatcher zkw = new ZooKeeperWatcher(configuration, "1", new DummyMobAbortable());
|
||||
TableName lockName = MobUtils.getTableLockName(tn);
|
||||
String znode = ZKUtil.joinZNode(zkw.tableLockZNode, lockName.getNameAsString());
|
||||
String znode = ZKUtil.joinZNode(zkw.znodePaths.tableLockZNode, lockName.getNameAsString());
|
||||
configuration.set(SweepJob.SWEEP_JOB_ID, "1");
|
||||
configuration.set(SweepJob.SWEEP_JOB_TABLE_NODE, znode);
|
||||
ServerName serverName = SweepJob.getCurrentServerName(configuration);
|
||||
|
|
|
@ -82,7 +82,7 @@ public class TestMasterAddressTracker {
|
|||
throws Exception {
|
||||
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||
name.getMethodName(), null);
|
||||
ZKUtil.createAndFailSilent(zk, zk.baseZNode);
|
||||
ZKUtil.createAndFailSilent(zk, zk.znodePaths.baseZNode);
|
||||
|
||||
// Should not have a master yet
|
||||
MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
|
||||
|
@ -91,12 +91,12 @@ public class TestMasterAddressTracker {
|
|||
zk.registerListener(addressTracker);
|
||||
|
||||
// Use a listener to capture when the node is actually created
|
||||
NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
|
||||
NodeCreationListener listener = new NodeCreationListener(zk, zk.znodePaths.masterAddressZNode);
|
||||
zk.registerListener(listener);
|
||||
|
||||
if (sn != null) {
|
||||
LOG.info("Creating master node");
|
||||
MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn, infoPort);
|
||||
MasterAddressTracker.setMasterAddress(zk, zk.znodePaths.masterAddressZNode, sn, infoPort);
|
||||
|
||||
// Wait for the node to be created
|
||||
LOG.info("Waiting for master address manager to be notified");
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TestRegionServerHostname {
|
|||
TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
|
||||
try {
|
||||
ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
|
||||
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.rsZNode);
|
||||
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode);
|
||||
// there would be NUM_RS+1 children - one for the master
|
||||
assertTrue(servers.size() == NUM_RS+1);
|
||||
for (String server : servers) {
|
||||
|
|
|
@ -188,16 +188,16 @@ public class TestSplitLogWorker {
|
|||
zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||
"split-log-worker-tests", null);
|
||||
ds = new DummyServer(zkw, conf);
|
||||
ZKUtil.deleteChildrenRecursively(zkw, zkw.baseZNode);
|
||||
ZKUtil.createAndFailSilent(zkw, zkw.baseZNode);
|
||||
assertThat(ZKUtil.checkExists(zkw, zkw.baseZNode), not (is(-1)));
|
||||
LOG.debug(zkw.baseZNode + " created");
|
||||
ZKUtil.createAndFailSilent(zkw, zkw.splitLogZNode);
|
||||
assertThat(ZKUtil.checkExists(zkw, zkw.splitLogZNode), not (is(-1)));
|
||||
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)));
|
||||
|
||||
LOG.debug(zkw.splitLogZNode + " created");
|
||||
ZKUtil.createAndFailSilent(zkw, zkw.rsZNode);
|
||||
assertThat(ZKUtil.checkExists(zkw, zkw.rsZNode), 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)));
|
||||
|
||||
SplitLogCounters.resetCounters();
|
||||
executorService = new ExecutorService("TestSplitLogWorker");
|
||||
|
@ -416,7 +416,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.splitLogZNode);
|
||||
List<String> nodes = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.splitLogZNode);
|
||||
LOG.debug(nodes);
|
||||
int num = 0;
|
||||
for (String node : nodes) {
|
||||
|
@ -424,7 +424,7 @@ public class TestSplitLogWorker {
|
|||
if (node.startsWith("RESCAN")) {
|
||||
String name = ZKSplitLog.getEncodedNodeName(zkw, node);
|
||||
String fn = ZKSplitLog.getFileName(name);
|
||||
byte [] data = ZKUtil.getData(zkw, ZKUtil.joinZNode(zkw.splitLogZNode, fn));
|
||||
byte [] data = ZKUtil.getData(zkw, ZKUtil.joinZNode(zkw.znodePaths.splitLogZNode, fn));
|
||||
slt = SplitLogTask.parseFrom(data);
|
||||
assertTrue(slt.toString(), slt.isDone(SRV));
|
||||
}
|
||||
|
@ -480,9 +480,9 @@ public class TestSplitLogWorker {
|
|||
RegionServerServices mockedRS = getRegionServer(RS);
|
||||
|
||||
// create two RS nodes
|
||||
String rsPath = ZKUtil.joinZNode(zkw.rsZNode, RS.getServerName());
|
||||
String rsPath = ZKUtil.joinZNode(zkw.znodePaths.rsZNode, RS.getServerName());
|
||||
zkw.getRecoverableZooKeeper().create(rsPath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
|
||||
rsPath = ZKUtil.joinZNode(zkw.rsZNode, RS2.getServerName());
|
||||
rsPath = ZKUtil.joinZNode(zkw.znodePaths.rsZNode, RS2.getServerName());
|
||||
zkw.getRecoverableZooKeeper().create(rsPath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
|
||||
|
||||
for (int i = 0; i < maxTasks; i++) {
|
||||
|
|
|
@ -87,7 +87,7 @@ public class TestReplicationStateHBaseImpl {
|
|||
utility.startMiniCluster();
|
||||
zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
|
||||
String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication");
|
||||
replicationZNode = ZKUtil.joinZNode(zkw.baseZNode, replicationZNodeName);
|
||||
replicationZNode = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, replicationZNodeName);
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -68,7 +68,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
|
|||
conf.setBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY, true);
|
||||
zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
|
||||
String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication");
|
||||
replicationZNode = ZKUtil.joinZNode(zkw.baseZNode, replicationZNodeName);
|
||||
replicationZNode = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, replicationZNodeName);
|
||||
KEY_ONE = initPeerClusterState("/hbase1");
|
||||
KEY_TWO = initPeerClusterState("/hbase2");
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
|
|||
Configuration testConf = new Configuration(conf);
|
||||
testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
|
||||
ZooKeeperWatcher zkw1 = new ZooKeeperWatcher(testConf, "test1", null);
|
||||
String fakeRs = ZKUtil.joinZNode(zkw1.rsZNode, "hostname1.example.org:1234");
|
||||
String fakeRs = ZKUtil.joinZNode(zkw1.znodePaths.rsZNode, "hostname1.example.org:1234");
|
||||
ZKUtil.createWithParents(zkw1, fakeRs);
|
||||
ZKClusterId.setClusterId(zkw1, new ClusterId());
|
||||
return ZKConfig.getZooKeeperClusterKey(testConf);
|
||||
|
|
|
@ -81,13 +81,13 @@ public class TestReplicationTrackerZKImpl {
|
|||
utility.startMiniZKCluster();
|
||||
conf = utility.getConfiguration();
|
||||
ZooKeeperWatcher zk = HBaseTestingUtility.getZooKeeperWatcher(utility);
|
||||
ZKUtil.createWithParents(zk, zk.rsZNode);
|
||||
ZKUtil.createWithParents(zk, zk.znodePaths.rsZNode);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
|
||||
String fakeRs1 = ZKUtil.joinZNode(zkw.rsZNode, "hostname1.example.org:1234");
|
||||
String fakeRs1 = ZKUtil.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234");
|
||||
try {
|
||||
ZKClusterId.setClusterId(zkw, new ClusterId());
|
||||
rp = ReplicationFactory.getReplicationPeers(zkw, conf, zkw);
|
||||
|
@ -115,29 +115,32 @@ public class TestReplicationTrackerZKImpl {
|
|||
assertEquals(0, rt.getListOfRegionServers().size());
|
||||
|
||||
// 1 region server
|
||||
ZKUtil.createWithParents(zkw, ZKUtil.joinZNode(zkw.rsZNode, "hostname1.example.org:1234"));
|
||||
ZKUtil.createWithParents(zkw,
|
||||
ZKUtil.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234"));
|
||||
assertEquals(1, rt.getListOfRegionServers().size());
|
||||
|
||||
// 2 region servers
|
||||
ZKUtil.createWithParents(zkw, ZKUtil.joinZNode(zkw.rsZNode, "hostname2.example.org:1234"));
|
||||
ZKUtil.createWithParents(zkw,
|
||||
ZKUtil.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"));
|
||||
assertEquals(2, rt.getListOfRegionServers().size());
|
||||
|
||||
// 1 region server
|
||||
ZKUtil.deleteNode(zkw, ZKUtil.joinZNode(zkw.rsZNode, "hostname2.example.org:1234"));
|
||||
ZKUtil.deleteNode(zkw, ZKUtil.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"));
|
||||
assertEquals(1, rt.getListOfRegionServers().size());
|
||||
|
||||
// 0 region server
|
||||
ZKUtil.deleteNode(zkw, ZKUtil.joinZNode(zkw.rsZNode, "hostname1.example.org:1234"));
|
||||
ZKUtil.deleteNode(zkw, ZKUtil.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234"));
|
||||
assertEquals(0, rt.getListOfRegionServers().size());
|
||||
}
|
||||
|
||||
@Test(timeout = 30000)
|
||||
public void testRegionServerRemovedEvent() throws Exception {
|
||||
ZKUtil.createAndWatch(zkw, ZKUtil.joinZNode(zkw.rsZNode, "hostname2.example.org:1234"),
|
||||
ZKUtil.createAndWatch(zkw,
|
||||
ZKUtil.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"),
|
||||
HConstants.EMPTY_BYTE_ARRAY);
|
||||
rt.registerListener(new DummyReplicationListener());
|
||||
// delete one
|
||||
ZKUtil.deleteNode(zkw, ZKUtil.joinZNode(zkw.rsZNode, "hostname2.example.org:1234"));
|
||||
ZKUtil.deleteNode(zkw, ZKUtil.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"));
|
||||
// wait for event
|
||||
while (rsRemovedCount.get() < 1) {
|
||||
Thread.sleep(5);
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TestZKMulti {
|
|||
ZKUtil.multiOrSequential(zkw, new LinkedList<ZKUtilOp>(), false);
|
||||
|
||||
// single create
|
||||
String path = ZKUtil.joinZNode(zkw.baseZNode, "testSimpleMulti");
|
||||
String path = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testSimpleMulti");
|
||||
LinkedList<ZKUtilOp> singleCreate = new LinkedList<ZKUtilOp>();
|
||||
singleCreate.add(ZKUtilOp.createAndFailSilent(path, new byte[0]));
|
||||
ZKUtil.multiOrSequential(zkw, singleCreate, false);
|
||||
|
@ -110,12 +110,12 @@ public class TestZKMulti {
|
|||
|
||||
@Test (timeout=60000)
|
||||
public void testComplexMulti() throws Exception {
|
||||
String path1 = ZKUtil.joinZNode(zkw.baseZNode, "testComplexMulti1");
|
||||
String path2 = ZKUtil.joinZNode(zkw.baseZNode, "testComplexMulti2");
|
||||
String path3 = ZKUtil.joinZNode(zkw.baseZNode, "testComplexMulti3");
|
||||
String path4 = ZKUtil.joinZNode(zkw.baseZNode, "testComplexMulti4");
|
||||
String path5 = ZKUtil.joinZNode(zkw.baseZNode, "testComplexMulti5");
|
||||
String path6 = ZKUtil.joinZNode(zkw.baseZNode, "testComplexMulti6");
|
||||
String path1 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti1");
|
||||
String path2 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti2");
|
||||
String path3 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti3");
|
||||
String path4 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti4");
|
||||
String path5 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti5");
|
||||
String path6 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti6");
|
||||
// create 4 nodes that we'll setData on or delete later
|
||||
LinkedList<ZKUtilOp> create4Nodes = new LinkedList<ZKUtilOp>();
|
||||
create4Nodes.add(ZKUtilOp.createAndFailSilent(path1, Bytes.toBytes(path1)));
|
||||
|
@ -154,7 +154,7 @@ public class TestZKMulti {
|
|||
public void testSingleFailure() throws Exception {
|
||||
// try to delete a node that doesn't exist
|
||||
boolean caughtNoNode = false;
|
||||
String path = ZKUtil.joinZNode(zkw.baseZNode, "testSingleFailureZ");
|
||||
String path = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureZ");
|
||||
LinkedList<ZKUtilOp> ops = new LinkedList<ZKUtilOp>();
|
||||
ops.add(ZKUtilOp.deleteNodeFailSilent(path));
|
||||
try {
|
||||
|
@ -191,9 +191,9 @@ public class TestZKMulti {
|
|||
@Test (timeout=60000)
|
||||
public void testSingleFailureInMulti() throws Exception {
|
||||
// try a multi where all but one operation succeeds
|
||||
String pathA = ZKUtil.joinZNode(zkw.baseZNode, "testSingleFailureInMultiA");
|
||||
String pathB = ZKUtil.joinZNode(zkw.baseZNode, "testSingleFailureInMultiB");
|
||||
String pathC = ZKUtil.joinZNode(zkw.baseZNode, "testSingleFailureInMultiC");
|
||||
String pathA = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiA");
|
||||
String pathB = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiB");
|
||||
String pathC = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiC");
|
||||
LinkedList<ZKUtilOp> ops = new LinkedList<ZKUtilOp>();
|
||||
ops.add(ZKUtilOp.createAndFailSilent(pathA, Bytes.toBytes(pathA)));
|
||||
ops.add(ZKUtilOp.createAndFailSilent(pathB, Bytes.toBytes(pathB)));
|
||||
|
@ -213,17 +213,17 @@ public class TestZKMulti {
|
|||
|
||||
@Test (timeout=60000)
|
||||
public void testMultiFailure() throws Exception {
|
||||
String pathX = ZKUtil.joinZNode(zkw.baseZNode, "testMultiFailureX");
|
||||
String pathY = ZKUtil.joinZNode(zkw.baseZNode, "testMultiFailureY");
|
||||
String pathZ = ZKUtil.joinZNode(zkw.baseZNode, "testMultiFailureZ");
|
||||
String pathX = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureX");
|
||||
String pathY = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureY");
|
||||
String pathZ = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureZ");
|
||||
// create X that we will use to fail create later
|
||||
LinkedList<ZKUtilOp> ops = new LinkedList<ZKUtilOp>();
|
||||
ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX)));
|
||||
ZKUtil.multiOrSequential(zkw, ops, false);
|
||||
|
||||
// fail one of each create ,setData, delete
|
||||
String pathV = ZKUtil.joinZNode(zkw.baseZNode, "testMultiFailureV");
|
||||
String pathW = ZKUtil.joinZNode(zkw.baseZNode, "testMultiFailureW");
|
||||
String pathV = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureV");
|
||||
String pathW = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureW");
|
||||
ops = new LinkedList<ZKUtilOp>();
|
||||
ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- already exists
|
||||
ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist
|
||||
|
@ -267,10 +267,10 @@ public class TestZKMulti {
|
|||
|
||||
@Test (timeout=60000)
|
||||
public void testRunSequentialOnMultiFailure() throws Exception {
|
||||
String path1 = ZKUtil.joinZNode(zkw.baseZNode, "runSequential1");
|
||||
String path2 = ZKUtil.joinZNode(zkw.baseZNode, "runSequential2");
|
||||
String path3 = ZKUtil.joinZNode(zkw.baseZNode, "runSequential3");
|
||||
String path4 = ZKUtil.joinZNode(zkw.baseZNode, "runSequential4");
|
||||
String path1 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "runSequential1");
|
||||
String path2 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "runSequential2");
|
||||
String path3 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "runSequential3");
|
||||
String path4 = ZKUtil.joinZNode(zkw.znodePaths.baseZNode, "runSequential4");
|
||||
|
||||
// create some nodes that we will use later
|
||||
LinkedList<ZKUtilOp> ops = new LinkedList<ZKUtilOp>();
|
||||
|
|
|
@ -97,10 +97,10 @@ public class TestZooKeeperNodeTracker {
|
|||
Abortable abortable = new StubAbortable();
|
||||
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||
"testNodeTracker", abortable);
|
||||
ZKUtil.createAndFailSilent(zk, zk.baseZNode);
|
||||
ZKUtil.createAndFailSilent(zk, zk.znodePaths.baseZNode);
|
||||
|
||||
final String node =
|
||||
ZKUtil.joinZNode(zk.baseZNode, new Long(rand.nextLong()).toString());
|
||||
ZKUtil.joinZNode(zk.znodePaths.baseZNode, new Long(rand.nextLong()).toString());
|
||||
|
||||
final byte [] dataOne = Bytes.toBytes("dataOne");
|
||||
final byte [] dataTwo = Bytes.toBytes("dataTwo");
|
||||
|
@ -326,7 +326,7 @@ public class TestZooKeeperNodeTracker {
|
|||
TEST_UTIL.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT,
|
||||
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT));
|
||||
|
||||
final String nodeName = zkw.getMasterAddressZNode();
|
||||
final String nodeName = zkw.znodePaths.masterAddressZNode;
|
||||
|
||||
// Check that we manage the case when there is no data
|
||||
ZKUtil.createAndFailSilent(zkw, nodeName);
|
||||
|
|
|
@ -80,7 +80,7 @@ public class TestZKInterProcessReadWriteLock {
|
|||
TEST_UTIL.startMiniZKCluster();
|
||||
conf.setInt(HConstants.ZK_SESSION_TIMEOUT, 1000);
|
||||
ZooKeeperWatcher zkw = getZooKeeperWatcher("setup");
|
||||
ZKUtil.createWithParents(zkw, zkw.tableLockZNode);
|
||||
ZKUtil.createWithParents(zkw, zkw.znodePaths.tableLockZNode);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -226,7 +226,7 @@ public class TestZKInterProcessReadWriteLock {
|
|||
}
|
||||
};
|
||||
ZooKeeperWatcher zkWatcher = getZooKeeperWatcher(testName);
|
||||
String znode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, testName);
|
||||
String znode = ZKUtil.joinZNode(zkWatcher.znodePaths.tableLockZNode, testName);
|
||||
|
||||
return new ZKInterProcessReadWriteLock(zkWatcher, znode, handler);
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ public class TestZKInterProcessReadWriteLock {
|
|||
ZooKeeperWatcher zkWatcher1 = new ZooKeeperWatcher(conf, "testMultipleClients-1", null);
|
||||
ZooKeeperWatcher zkWatcher2 = new ZooKeeperWatcher(conf, "testMultipleClients-2", null);
|
||||
|
||||
String znode = ZKUtil.joinZNode(zkWatcher1.tableLockZNode, testName);
|
||||
String znode = ZKUtil.joinZNode(zkWatcher1.znodePaths.tableLockZNode, testName);
|
||||
|
||||
ZKInterProcessReadWriteLock clientLock1
|
||||
= new ZKInterProcessReadWriteLock(zkWatcher1, znode, null);
|
||||
|
|
Loading…
Reference in New Issue