hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1181911 - in /hbase/branches/0.89/bin: get-active-master.rb hbase-jruby
Date Tue, 11 Oct 2011 17:41:37 GMT
Author: nspiegelberg
Date: Tue Oct 11 17:41:37 2011
New Revision: 1181911

URL: http://svn.apache.org/viewvc?rev=1181911&view=rev
Log:
Determining the hostname of the active HBase master

Summary: This simple script reads the HBase master ZK node and outputs the
hostname of the active master. This is needed so that hadoopctl can decide where
the primary master should be running. I am also including a one-line hbase-jruby
script so we can make our jruby scripts proper UNIX executables.
Test Plan: Run it. Kill the master. Wait for znode to expire. Run again.
Reviewed By: liyintang
Reviewers: liyintang, nspiegelberg, pritam
CC: andrewr, , hbase@lists, liyintang
Revert Plan: OK
Differential Revision: 285941
Task ID: 613556

Added:
    hbase/branches/0.89/bin/get-active-master.rb   (with props)
    hbase/branches/0.89/bin/hbase-jruby   (with props)

Added: hbase/branches/0.89/bin/get-active-master.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/bin/get-active-master.rb?rev=1181911&view=auto
==============================================================================
--- hbase/branches/0.89/bin/get-active-master.rb (added)
+++ hbase/branches/0.89/bin/get-active-master.rb Tue Oct 11 17:41:37 2011
@@ -0,0 +1,28 @@
+#!/usr/bin/env hbase-jruby
+# Prints the hostname of the machine running the active master.
+
+include Java
+
+import org.apache.hadoop.hbase.HBaseConfiguration
+import org.apache.hadoop.hbase.HConstants
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper
+
+# disable debug/info logging on this script for clarity
+log_level = org.apache.log4j.Level::ERROR
+org.apache.log4j.Logger.getLogger('org.apache.zookeeper').setLevel(log_level)
+org.apache.log4j.Logger.getLogger('org.apache.hadoop.hbase').setLevel(log_level)
+
+config = HBaseConfiguration.create
+config.set 'fs.default.name', config.get(HConstants::HBASE_DIR)
+
+zk = ZooKeeperWrapper.createInstance(config, 'get_active_master')
+begin
+  master_address = zk.readMasterAddress(nil)
+  if master_address
+    puts master_address.getHostname()
+  else
+    puts 'Master not running'
+  end
+ensure
+  zk.close()
+end

Propchange: hbase/branches/0.89/bin/get-active-master.rb
------------------------------------------------------------------------------
    svn:executable = *

Added: hbase/branches/0.89/bin/hbase-jruby
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/bin/hbase-jruby?rev=1181911&view=auto
==============================================================================
--- hbase/branches/0.89/bin/hbase-jruby (added)
+++ hbase/branches/0.89/bin/hbase-jruby Tue Oct 11 17:41:37 2011
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+`dirname $0`/hbase org.jruby.Main $*

Propchange: hbase/branches/0.89/bin/hbase-jruby
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message