This is an automated email from the ASF dual-hosted git repository. hapylestat pushed a commit to branch branch-2.7 in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.7 by this push: new 9d53b5e AMBARI-25344. Provide graceful start/stop option for RegionServer (#3059) (virajjasani via dgrinenko) 9d53b5e is described below commit 9d53b5e84bee3894086720cdca6b53fc9dd08c3d Author: Viraj Jasani <virajjasani...@gmail.com> AuthorDate: Tue May 26 14:41:09 2020 +0530 AMBARI-25344. Provide graceful start/stop option for RegionServer (#3059) (virajjasani via dgrinenko) --- .../common-services/HBASE/0.96.0.2.0/metainfo.xml | 18 +++++++ .../package/scripts/hbase_decommission.py | 6 +-- .../package/scripts/hbase_regionserver.py | 55 ++++++++++++++++++++-- .../0.96.0.2.0/package/scripts/params_linux.py | 2 + .../python/stacks/2.0.6/HBASE/test_hbase_master.py | 14 +++--- 5 files changed, 81 insertions(+), 14 deletions(-) diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/metainfo.xml b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/metainfo.xml index 463ae31..49c26b9 100644 --- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/metainfo.xml +++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/metainfo.xml @@ -96,6 +96,24 @@ <primary>true</primary> </log> </logs> + <customCommands> + <customCommand> + <name>GRACEFUL_STOP</name> + <commandScript> + <script>scripts/hbase_regionserver.py</script> + <scriptType>PYTHON</scriptType> + <timeout>600</timeout> + </commandScript> + </customCommand> + <customCommand> + <name>GRACEFUL_START</name> + <commandScript> + <script>scripts/hbase_regionserver.py</script> + <scriptType>PYTHON</scriptType> + <timeout>600</timeout> + </commandScript> + </customCommand> + </customCommands> </component> <component> diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_decommission.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_decommission.py index 5853f75..1ce0b8c 100644 --- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_decommission.py +++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_decommission.py @@ -64,7 +64,7 @@ def hbase_decommission(env): for host in hosts: if host: regiondrainer_cmd = format( - "{kinit_cmd} HBASE_OPTS=\"$HBASE_OPTS {master_security_config}\" {hbase_cmd} --config {hbase_conf_dir} org.jruby.Main {region_drainer} remove {host}") + "{kinit_cmd} {hbase_cmd} --config {hbase_conf_dir} {client_security_config} org.jruby.Main {region_drainer} remove {host}") Execute(regiondrainer_cmd, user=params.hbase_user, logoutput=True @@ -76,9 +76,9 @@ def hbase_decommission(env): for host in hosts: if host: regiondrainer_cmd = format( - "{kinit_cmd} HBASE_OPTS=\"$HBASE_OPTS {master_security_config}\" {hbase_cmd} --config {hbase_conf_dir} org.jruby.Main {region_drainer} add {host}") + "{kinit_cmd} {hbase_cmd} --config {hbase_conf_dir} {client_security_config} org.jruby.Main {region_drainer} add {host}") regionmover_cmd = format( - "{kinit_cmd} HBASE_OPTS=\"$HBASE_OPTS {master_security_config}\" {hbase_cmd} --config {hbase_conf_dir} org.jruby.Main {region_mover} unload {host}") + "{kinit_cmd} {hbase_cmd} --config {hbase_conf_dir} {client_security_config} org.jruby.Main {region_mover} unload {host}") Execute(regiondrainer_cmd, user=params.hbase_user, diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py index 04f0e22..75083ac 100644 --- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py +++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py @@ -21,6 +21,7 @@ limitations under the License. import sys from resource_management.core import shell +from resource_management.core.resources.system import Execute from resource_management.libraries.script.script import Script from resource_management.libraries.functions.format import format from resource_management.libraries.functions.check_process_status import check_process_status @@ -29,12 +30,14 @@ from resource_management.libraries.functions.security_commons import build_expec FILE_TYPE_XML from ambari_commons import OSCheck, OSConst +from ambari_commons.constants import UPGRADE_TYPE_ROLLING from ambari_commons.os_family_impl import OsFamilyImpl from hbase import hbase from hbase_service import hbase_service import upgrade from setup_ranger_hbase import setup_ranger_hbase +from hbase_decommission import hbase_decommission class HbaseRegionServer(Script): @@ -51,6 +54,42 @@ class HbaseRegionServer(Script): def decommission(self, env): print "Decommission not yet implemented!" + def graceful_stop(self, env, upgrade_type=None): + import params + + # Mark Draining ZNode + params.hbase_drain_only = False + params.hbase_excluded_hosts = params.hostname + env.set_params(params) + hbase_decommission(env) + + # Stop RegionServer + hbase_service('regionserver', action='stop') + + # Remove from Draining ZNode to make host useable on restarting regionserver + params.hbase_drain_only = True + env.set_params(params) + hbase_decommission(env) + + def graceful_start(self, env, upgrade_type=None): + import params + env.set_params(params) + + #Start RegionServer + hbase_service('regionserver', action='start') + + # Load Regions back + kinit_cmd = params.kinit_cmd_master + host = params.hostname + + regionmover_cmd = format( + "{kinit_cmd} {hbase_cmd} --config {hbase_conf_dir} {client_security_config} org.jruby.Main {region_mover} load {host}") + + Execute(regionmover_cmd, + user=params.hbase_user, + logoutput=True + ) + @OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY) @@ -90,15 +129,23 @@ class HbaseRegionServerDefault(HbaseRegionServer): self.configure(env) # for security setup_ranger_hbase(upgrade_type=upgrade_type, service_name="hbase-regionserver") - hbase_service('regionserver', action='start') + if upgrade_type == UPGRADE_TYPE_ROLLING and len(params.rs_hosts) > 5: + self.graceful_start(env) + else: + hbase_service('regionserver', + action='start' + ) def stop(self, env, upgrade_type=None): import params env.set_params(params) - hbase_service( 'regionserver', - action = 'stop' - ) + if upgrade_type == UPGRADE_TYPE_ROLLING and len(params.rs_hosts) > 5: + self.graceful_stop(env) + else: + hbase_service('regionserver', + action='stop' + ) def status(self, env): import status_params diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_linux.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_linux.py index 292fdf2..d2216e4 100644 --- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_linux.py +++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_linux.py @@ -234,10 +234,12 @@ if security_enabled: kinit_cmd = format("{kinit_path_local} -kt {hbase_user_keytab} {hbase_principal_name};") kinit_cmd_master = format("{kinit_path_local} -kt {master_keytab_path} {master_jaas_princ};") master_security_config = format("-Djava.security.auth.login.config={hbase_conf_dir}/hbase_master_jaas.conf") + client_security_config = format("-Djava.security.auth.login.config={hbase_conf_dir}/hbase_client_jaas.conf") else: kinit_cmd = "" kinit_cmd_master = "" master_security_config = "" + client_security_config = "" #log4j.properties # HBase log4j settings diff --git a/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py b/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py index 5162193..39c5b2f 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py @@ -192,19 +192,19 @@ class TestHBaseMaster(RMFTestCase): content = StaticFile('draining_servers.rb'), mode = 0755, ) - self.assertResourceCalled('Execute', ' HBASE_OPTS="$HBASE_OPTS " /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb add host1', + self.assertResourceCalled('Execute', ' /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb add host1', logoutput = True, user = 'hbase', ) - self.assertResourceCalled('Execute', ' HBASE_OPTS="$HBASE_OPTS " /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/region_mover.rb unload host1', + self.assertResourceCalled('Execute', ' /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/region_mover.rb unload host1', logoutput = True, user = 'hbase', ) - self.assertResourceCalled('Execute', ' HBASE_OPTS="$HBASE_OPTS " /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb add host2', + self.assertResourceCalled('Execute', ' /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb add host2', logoutput = True, user = 'hbase', ) - self.assertResourceCalled('Execute', ' HBASE_OPTS="$HBASE_OPTS " /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/region_mover.rb unload host2', + self.assertResourceCalled('Execute', ' /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/region_mover.rb unload host2', logoutput = True, user = 'hbase', ) @@ -223,7 +223,7 @@ class TestHBaseMaster(RMFTestCase): content = StaticFile('draining_servers.rb'), mode = 0755, ) - self.assertResourceCalled('Execute', ' HBASE_OPTS="$HBASE_OPTS " /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb remove host1', + self.assertResourceCalled('Execute', ' /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb remove host1', logoutput = True, user = 'hbase', ) @@ -291,11 +291,11 @@ class TestHBaseMaster(RMFTestCase): content = StaticFile('draining_servers.rb'), mode = 0755, ) - self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hbase.service.keytab hbase/c6401.ambari.apache....@example.com; HBASE_OPTS="$HBASE_OPTS -Djava.security.auth.login.config=/etc/hbase/conf/hbase_master_jaas.conf" /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb add host1', + self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hbase.service.keytab hbase/c6401.ambari.apache....@example.com; /usr/lib/hbase/bin/hbase --config /etc/hbase/conf -Djava.security.auth.login.config=/etc/hbase/conf/hbase_client_jaas.conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb add host1', logoutput = True, user = 'hbase', ) - self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hbase.service.keytab hbase/c6401.ambari.apache....@example.com; HBASE_OPTS="$HBASE_OPTS -Djava.security.auth.login.config=/etc/hbase/conf/hbase_master_jaas.conf" /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/region_mover.rb unload host1', + self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hbase.service.keytab hbase/c6401.ambari.apache....@example.com; /usr/lib/hbase/bin/hbase --config /etc/hbase/conf -Djava.security.auth.login.config=/etc/hbase/conf/hbase_client_jaas.conf org.jruby.Main /usr/lib/hbase/bin/region_mover.rb unload host1', logoutput = True, user = 'hbase', )