Files
impala/testdata/bin/wait-for-hbase-master.py
ishaan 9e043e862c Fix run-hbase.sh to correctly pick up the classpath.
We run wat-for-hbase-master.py after starting hbase to account for a race between
the master and region server. This script has not been working for some time. It caused
no ill effects sinc the said race was absent. However, the race has manifested itself
again, so the script needs to be fixed. Setting the correct classpath does so.

Change-Id: I783a7473cfd24a9cb66711f5428f7052ceb96282
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1756
Reviewed-by: Ishaan Joshi <ishaan@cloudera.com>
Tested-by: Ishaan Joshi <ishaan@cloudera.com>
2014-03-05 01:04:56 -08:00

31 lines
849 B
Python

# Copyright (c) Cloudera 2012.
from subprocess import Popen, PIPE
import time
now = time.time()
TIMEOUT_SECONDS = 30.0
while time.time() - now < TIMEOUT_SECONDS:
print "Polling /hbase/rs"
p = Popen(["java",
"org.apache.zookeeper.ZooKeeperMain",
"-server",
"localhost:2181",
"get",
"/hbase/rs"], stderr=PIPE, stdout=PIPE)
out, err = p.communicate()
if "Could not find the main class: org.apache.zookeeper.ZooKeeperMain" in err:
print """CLASSPATH does not contain org.apache.zookeeper.ZooKeeperMain.
Please check your CLASSPATH"""
exit(1)
if "numChildren" in err:
print "HBase master is up, found in %2.1fs" % (time.time() - now,)
exit(0)
time.sleep(0.5)
print "Hbase master did NOT write /hbase/rs in %2.1fs" % (time.time() - now,)
exit(1)