Index: conf/hive-default.xml
===================================================================
--- conf/hive-default.xml (revision 997553)
+++ conf/hive-default.xml (working copy)
@@ -649,6 +649,12 @@
+ hive.zookeeper.namespace
+ hive_zookeeper_namespace
+ The parent node under which all zookeeper nodes are created.
+
+
+
fs.har.impl
org.apache.hadoop.hive.shims.HiveHarFileSystem
The implementation for accessing Hadoop Archives. Note that this won't be applicable to Hadoop vers less than 0.20
Index: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
===================================================================
--- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (revision 997553)
+++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (working copy)
@@ -275,6 +275,7 @@
HIVE_ZOOKEEPER_QUORUM("hive.zookeeper.quorum", ""),
HIVE_ZOOKEEPER_CLIENT_PORT("hive.zookeeper.client.port", ""),
HIVE_ZOOKEEPER_SESSION_TIMEOUT("hive.zookeeper.session.timeout", 600*1000),
+ HIVE_ZOOKEEPER_NAMESPACE("hive.zookeeper.namespace", "hive_zookeeper_namespace"),
// For HBase storage handler
HIVE_HBASE_WAL_ENABLED("hive.hbase.wal.enabled", true),
Index: ql/src/test/templates/TestParse.vm
===================================================================
--- ql/src/test/templates/TestParse.vm (revision 997553)
+++ ql/src/test/templates/TestParse.vm (working copy)
@@ -51,9 +51,10 @@
@Override
protected void tearDown() {
try {
- qt.clearPostTestEffects();
if (getName().equals("testParse_shutdown"))
qt.shutdown();
+ else
+ qt.clearPostTestEffects();
}
catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
Index: ql/src/test/templates/TestParseNegative.vm
===================================================================
--- ql/src/test/templates/TestParseNegative.vm (revision 997553)
+++ ql/src/test/templates/TestParseNegative.vm (working copy)
@@ -51,9 +51,11 @@
@Override
protected void tearDown() {
try {
- qt.clearPostTestEffects();
+
if (getName().equals("testParseNegative_shutdown"))
qt.shutdown();
+ else
+ qt.clearPostTestEffects();
}
catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
Index: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/zookeeper/ZooKeeperHiveLockManager.java
===================================================================
--- ql/src/java/org/apache/hadoop/hive/ql/lockmgr/zookeeper/ZooKeeperHiveLockManager.java (revision 997553)
+++ ql/src/java/org/apache/hadoop/hive/ql/lockmgr/zookeeper/ZooKeeperHiveLockManager.java (working copy)
@@ -34,6 +34,7 @@
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.zookeeper.KeeperException;
import org.apache.hadoop.hive.ql.parse.ErrorMsg;
import org.apache.hadoop.hive.ql.lockmgr.HiveLockManager;
@@ -58,6 +59,9 @@
private ZooKeeper zooKeeper;
+ // All the locks are created under this parent
+ private String parent;
+
public ZooKeeperHiveLockManager() {
}
@@ -88,6 +92,15 @@
}
zooKeeper = new ZooKeeper(quorumServers, sessionTimeout, new DummyWatcher());
+ parent = conf.getVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_NAMESPACE);
+
+ try {
+ String par = zooKeeper.create("/" + parent, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+ } catch (KeeperException e) {
+ // ignore if the parent already exists
+ }
+
+
} catch (Exception e) {
LOG.error("Failed to create ZooKeeper object: " + e);
throw new LockException(ErrorMsg.ZOOKEEPER_CLIENT_COULD_NOT_BE_INITIALIZED.getMsg());
@@ -99,7 +112,9 @@
* replace "/" by a dummy name to ensure a single hierarchy.
**/
private String getObjectName(HiveLockObject key, HiveLockMode mode) {
- return "/" + key.getName().replaceAll("/", ctx.getConf().getVar(HiveConf.ConfVars.DEFAULT_ZOOKEEPER_PARTITION_NAME)) + "-" + mode + "-";
+ return "/" + parent + "/" +
+ key.getName().replaceAll("/", ctx.getConf().getVar(HiveConf.ConfVars.DEFAULT_ZOOKEEPER_PARTITION_NAME)) +
+ "-" + mode + "-";
}
/**
@@ -127,13 +142,13 @@
return null;
}
- List children = zooKeeper.getChildren("/", false);
+ List children = zooKeeper.getChildren("/" + parent, false);
String exLock = getObjectName(key, HiveLockMode.EXCLUSIVE);
String shLock = getObjectName(key, HiveLockMode.SHARED);
for (String child : children) {
- child = "/" + child;
+ child = "/" + parent + "/" + child;
// Is there a conflicting lock on the same object with a lower sequence number
int childSeq = seqNo;
@@ -181,7 +196,9 @@
int sessionTimeout = conf.getIntVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_SESSION_TIMEOUT);
String quorumServers = getQuorumServers(conf);
ZooKeeper zkpClient = new ZooKeeper(quorumServers, sessionTimeout, new DummyWatcher());
- List locks = getLocks(conf, zkpClient, null);
+ String parent = conf.getVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_NAMESPACE);
+ List locks = getLocks(conf, zkpClient, null, parent);
+
if (locks != null) {
for (HiveLock lock : locks) {
unlock(conf, zkpClient, lock);
@@ -198,12 +215,12 @@
/* Get all locks */
public List getLocks() throws LockException {
- return getLocks(ctx.getConf(), zooKeeper, null);
+ return getLocks(ctx.getConf(), zooKeeper, null, parent);
}
/* Get all locks for a particular object */
public List getLocks(HiveLockObject key) throws LockException {
- return getLocks(ctx.getConf(), zooKeeper, key);
+ return getLocks(ctx.getConf(), zooKeeper, key, parent);
}
/**
@@ -211,19 +228,20 @@
* @param zkpClient The ZooKeeper client
* @param key The object to be compared against - if key is null, then get all locks
**/
- private static List getLocks(HiveConf conf, ZooKeeper zkpClient, HiveLockObject key) throws LockException {
+ private static List getLocks(HiveConf conf, ZooKeeper zkpClient,
+ HiveLockObject key, String parent) throws LockException {
List locks = new ArrayList();
List children;
try {
- children = zkpClient.getChildren("/", false);
+ children = zkpClient.getChildren("/" + parent, false);
} catch (Exception e) {
LOG.error("Failed to get ZooKeeper children: " + e);
throw new LockException(e);
}
for (String child : children) {
- child = "/" + child;
+ child = "/" + parent + "/" + child;
HiveLockMode mode = getLockMode(conf, child);
if (mode == null) {
@@ -231,7 +249,8 @@
}
HiveLockObject obj = getLockObject(conf, child, mode);
- if ((key == null) || (obj.getName().equals(key.getName()))) {
+ if ((key == null) ||
+ (obj.getName().equals(key.getName()))) {
HiveLock lck = (HiveLock)(new ZooKeeperHiveLock(child, obj, mode));
locks.add(lck);
}
@@ -276,8 +295,8 @@
Hive db = Hive.get(conf);
int indx = path.lastIndexOf(mode.toString());
String objName = path.substring(1, indx-1);
+ String[] names = objName.split("/")[1].split("@");
- String[] names = objName.split("@");
Table tab = db.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME,
names[1], false); // do not throw exception if table does not exist
assert (tab != null);
@@ -303,7 +322,7 @@
if (partn == null) {
return new HiveLockObject(new DummyPartition(
- objName.replaceAll(conf.getVar(HiveConf.ConfVars.DEFAULT_ZOOKEEPER_PARTITION_NAME), "/")));
+ objName.split("/")[1].replaceAll(conf.getVar(HiveConf.ConfVars.DEFAULT_ZOOKEEPER_PARTITION_NAME), "/")));
}
return new HiveLockObject(partn);