HBASE-1244 ZooKeeperWrapper constants cleanup
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@755720 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2aa378fba6
commit
351e1ad689
|
@ -98,6 +98,7 @@ Release 0.20.0 - Unreleased
|
|||
HBASE-1258,1259 ganglia metrics for 'requests' is confusing
|
||||
(Ryan Rawson via Stack)
|
||||
HBASE-1265 HLogEdit static constants should be final (Nitay Joffe via Stack)
|
||||
HBASE-1244 ZooKeeperWrapper constants cleanup (Nitay Joffe via Stack)
|
||||
|
||||
Release 0.19.0 - 01/21/2009
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -81,11 +81,6 @@ public interface HConstants {
|
|||
/** Name of ZooKeeper config file in conf/ directory. */
|
||||
static final String ZOOKEEPER_CONFIG_NAME = "zoo.cfg";
|
||||
|
||||
/** Parameter name for ZooKeeper session timeout (in milliseconds). */
|
||||
static final String ZOOKEEPER_SESSION_TIMEOUT = "zookeeper.session.timeout";
|
||||
/** Default ZooKeeper session timeout. In milliseconds. */
|
||||
static final int DEFAULT_ZOOKEEPER_SESSION_TIMEOUT = 10 * 1000;
|
||||
|
||||
/** Parameter name for number of times to retry writes to ZooKeeper. */
|
||||
static final String ZOOKEEPER_RETRIES = "zookeeper.retries";
|
||||
/** Default number of times to retry writes to ZooKeeper. */
|
||||
|
@ -96,26 +91,6 @@ public interface HConstants {
|
|||
/** Default ZooKeeper pause value. In milliseconds. */
|
||||
static final int DEFAULT_ZOOKEEPER_PAUSE = 2 * 1000;
|
||||
|
||||
/** Parameter name for HBase parent ZNode in ZooKeeper. */
|
||||
static final String ZOOKEEPER_PARENT_ZNODE = "zookeeper.znode.parent";
|
||||
/** Default HBase parent ZNode in ZooKeeper. */
|
||||
static final String DEFAULT_ZOOKEEPER_PARENT_ZNODE = "/hbase";
|
||||
|
||||
/** Parameter name for ZooKeeper ZNode storing root server location. */
|
||||
static final String ZOOKEEPER_ROOT_SERVER_ZNODE = "zookeeper.znode.rootserver";
|
||||
/** Default ZooKeeper ZNode storing root server location. */
|
||||
static final String DEFAULT_ZOOKEEPER_ROOT_SERVER_ZNODE = "root-region-server";
|
||||
|
||||
/** Parameter name for ZooKeeper ZNode storing safe mode. */
|
||||
static final String ZOOKEEPER_SAFE_MODE_ZNODE = "zookeeper.znode.safemode";
|
||||
/** Default ZooKeeper ZNode storing safe mode. */
|
||||
static final String DEFAULT_ZOOKEEPER_SAFE_MODE_ZNODE = "safe-mode";
|
||||
|
||||
/** Parameter name for ZooKeeper ZNode storing safe mode. */
|
||||
static final String ZOOKEEPER_RS_ZNODE = "zookeeper.znode.rs";
|
||||
/** Default ZooKeeper ZNode storing safe mode. */
|
||||
static final String DEFAULT_ZOOKEEPER_RS_ZNODE = "rs";
|
||||
|
||||
/** Parameter name for hbase.regionserver address. */
|
||||
static final String REGIONSERVER_ADDRESS = "hbase.regionserver";
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
protected static final Log LOG = LogFactory.getLog(ZooKeeperWrapper.class);
|
||||
|
||||
// TODO: Replace this with ZooKeeper constant when ZOOKEEPER-277 is resolved.
|
||||
private static final String ZNODE_PATH_SEPARATOR = "/";
|
||||
private static final char ZNODE_PATH_SEPARATOR = '/';
|
||||
|
||||
private static String quorumServers = null;
|
||||
static {
|
||||
|
@ -62,7 +62,6 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
private final ZooKeeper zooKeeper;
|
||||
private final WatcherWrapper watcher;
|
||||
|
||||
private final String parentZNode;
|
||||
private final String rootRegionZNode;
|
||||
private final String outOfSafeModeZNode;
|
||||
private final String rsZNode;
|
||||
|
@ -90,8 +89,7 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
ZOOKEEPER_CONFIG_NAME);
|
||||
}
|
||||
|
||||
int sessionTimeout = conf.getInt(ZOOKEEPER_SESSION_TIMEOUT,
|
||||
DEFAULT_ZOOKEEPER_SESSION_TIMEOUT);
|
||||
int sessionTimeout = conf.getInt("zookeeper.session.timeout", 10 * 1000);
|
||||
this.watcher = new WatcherWrapper(watcher);
|
||||
try {
|
||||
zooKeeper = new ZooKeeper(quorumServers, sessionTimeout, this.watcher);
|
||||
|
@ -100,19 +98,17 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
throw new IOException(e);
|
||||
}
|
||||
|
||||
parentZNode = conf.get(ZOOKEEPER_PARENT_ZNODE,
|
||||
DEFAULT_ZOOKEEPER_PARENT_ZNODE);
|
||||
String parentZNode = conf.get("zookeeper.znode.parent", "/hbase");
|
||||
|
||||
String rootServerZNodeName = conf.get(ZOOKEEPER_ROOT_SERVER_ZNODE,
|
||||
DEFAULT_ZOOKEEPER_ROOT_SERVER_ZNODE);
|
||||
String outOfSafeModeZNodeName = conf.get(ZOOKEEPER_SAFE_MODE_ZNODE,
|
||||
DEFAULT_ZOOKEEPER_SAFE_MODE_ZNODE);
|
||||
String rsZNodeName = conf.get(ZOOKEEPER_RS_ZNODE,
|
||||
DEFAULT_ZOOKEEPER_RS_ZNODE);
|
||||
String rootServerZNodeName = conf.get("zookeeper.znode.rootserver",
|
||||
"root-region-server");
|
||||
String outOfSafeModeZNodeName = conf.get("zookeeper.znode.safemode",
|
||||
"safe-mode");
|
||||
String rsZNodeName = conf.get("zookeeper.znode.rs", "rs");
|
||||
|
||||
rootRegionZNode = getZNode(rootServerZNodeName);
|
||||
outOfSafeModeZNode = getZNode(outOfSafeModeZNodeName);
|
||||
rsZNode = getZNode(rsZNodeName);
|
||||
rootRegionZNode = getZNode(parentZNode, rootServerZNodeName);
|
||||
outOfSafeModeZNode = getZNode(parentZNode, outOfSafeModeZNodeName);
|
||||
rsZNode = getZNode(parentZNode, rsZNodeName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,7 +360,7 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
public boolean writeRSLocation(HServerInfo info) {
|
||||
ensureExists(rsZNode);
|
||||
byte[] data = Bytes.toBytes(info.getServerAddress().getBindAddress());
|
||||
String znode = rsZNode + ZNODE_PATH_SEPARATOR + info.getStartCode();
|
||||
String znode = joinPath(rsZNode, Long.toString(info.getStartCode()));
|
||||
try {
|
||||
zooKeeper.create(znode, data, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
|
||||
LOG.debug("Created ZNode " + znode
|
||||
|
@ -427,9 +423,12 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
}
|
||||
}
|
||||
|
||||
private String getZNode(String znodeName) {
|
||||
return znodeName.startsWith(ZNODE_PATH_SEPARATOR) ?
|
||||
znodeName :
|
||||
parentZNode + ZNODE_PATH_SEPARATOR + znodeName;
|
||||
private String getZNode(String parentZNode, String znodeName) {
|
||||
return znodeName.charAt(0) == ZNODE_PATH_SEPARATOR ?
|
||||
znodeName : joinPath(parentZNode, znodeName);
|
||||
}
|
||||
|
||||
private String joinPath(String parent, String child) {
|
||||
return parent + ZNODE_PATH_SEPARATOR + child;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue