You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by te...@apache.org on 2015/02/09 22:58:16 UTC
incubator-slider git commit: SLIDER-734 add support for TTL,
use proper method to get temp dir on Windows
Repository: incubator-slider
Updated Branches:
refs/heads/develop 861c6116b -> c4a21ad11
SLIDER-734 add support for TTL, use proper method to get temp dir on Windows
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/c4a21ad1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/c4a21ad1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/c4a21ad1
Branch: refs/heads/develop
Commit: c4a21ad115fb2bcb426036bdaa8a313b53e34ad8
Parents: 861c611
Author: tedyu <yu...@gmail.com>
Authored: Mon Feb 9 13:58:08 2015 -0800
Committer: tedyu <yu...@gmail.com>
Committed: Mon Feb 9 13:58:08 2015 -0800
----------------------------------------------------------------------
app-packages/hbase/hbase-slider.py | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/c4a21ad1/app-packages/hbase/hbase-slider.py
----------------------------------------------------------------------
diff --git a/app-packages/hbase/hbase-slider.py b/app-packages/hbase/hbase-slider.py
index aaa5639..38cea31 100644
--- a/app-packages/hbase/hbase-slider.py
+++ b/app-packages/hbase/hbase-slider.py
@@ -151,6 +151,8 @@ if len(sys.argv) < 2:
print " --appconf=<dir>"
print "optionally you can specify the (existing) directory for hbase conf files (as template) using:"
print " --hbaseconf=<dir>"
+ print "optionally you can specify the age in number of hours beyond which hbase-site.xml would be retrieved from slider cluster"
+ print " --ttl=<age of hbase-site.xml>"
print "the name of cluster instance is required as the first parameter following options"
print "the second parameter can be:"
print " shell (default) - activates hbase shell based on retrieved hbase-site.xml"
@@ -158,7 +160,7 @@ if len(sys.argv) < 2:
sys.exit(1)
try:
- opts, args = getopt.getopt(sys.argv[1:], "", ["appconf=", "hbaseconf="])
+ opts, args = getopt.getopt(sys.argv[1:], "", ["appconf=", "hbaseconf=", "ttl="])
except getopt.GetoptError as err:
# print help information and exit:
print str(err)
@@ -166,11 +168,14 @@ except getopt.GetoptError as err:
local_conf_dir=os.path.join(home, cluster_instance, 'conf')
hbase_conf_dir="/etc/hbase/conf"
+ttl=0
for o, a in opts:
if o == "--appconf":
local_conf_dir = a
elif o == "--hbaseconf":
hbase_conf_dir = a
+ elif o == "--ttl":
+ ttl = a
cluster_instance=args[0]
if len(args) > 1:
@@ -178,14 +183,24 @@ if len(args) > 1:
quicklinks(cluster_instance)
sys.exit(0)
+needToRetrieve=True
+HBaseConfFile=os.path.join(local_conf_dir, "hbase-site.xml")
if not exists(local_conf_dir):
shutil.copytree(hbase_conf_dir, local_conf_dir)
-tmpHBaseConfFile=os.path.join('/tmp', "hbase-site.xml")
-
-call([SLIDER_CMD, "registry", "--getconf", "hbase-site", "--user", "hbase", "--format", "xml", "--dest", tmpHBaseConfFile, "--name", cluster_instance])
-HBaseConfFile=os.path.join(local_conf_dir, "hbase-site.xml")
-propertyMap = {'hbase.tmp.dir' : '/tmp/hbase-tmp', "instance" : cluster_instance}
-writePropertiesToConfigXMLFile(tmpHBaseConfFile, HBaseConfFile, propertyMap)
-print "hbase configuration is saved in " + HBaseConfFile
+else:
+ if exists(HBaseConfFile):
+ diff = os.path.getmtime(HBaseConfFile)-int(time.time())
+ diff = diff / 60 / 60
+ print HBaseConfFile + " is " + str(diff) + " hours old"
+ if diff < ttl:
+ needToRetrieve=False
+
+if needToRetrieve:
+ tmpHBaseConfFile=os.path.join(tempfile.gettempdir(), "hbase-site.xml")
+
+ call([SLIDER_CMD, "registry", "--getconf", "hbase-site", "--user", "hbase", "--format", "xml", "--dest", tmpHBaseConfFile, "--name", cluster_instance])
+ propertyMap = {'hbase.tmp.dir' : '/tmp/hbase-tmp', "instance" : cluster_instance}
+ writePropertiesToConfigXMLFile(tmpHBaseConfFile, HBaseConfFile, propertyMap)
+ print "hbase configuration is saved in " + HBaseConfFile
call(["hbase", "--config", local_conf_dir, "shell"])