You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mi...@apache.org on 2016/04/14 02:03:20 UTC
ambari git commit: AMBARI-15849: Activate HAWQ standby wizard fails
to delete previous hawq standby master (bhuvnesh2703 via mithmatt)
Repository: ambari
Updated Branches:
refs/heads/trunk bd526e4ff -> bb5322e70
AMBARI-15849: Activate HAWQ standby wizard fails to delete previous hawq standby master (bhuvnesh2703 via mithmatt)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bb5322e7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bb5322e7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bb5322e7
Branch: refs/heads/trunk
Commit: bb5322e70df533440ccf8e1df4d4882d75e15754
Parents: bd526e4
Author: Matt <mm...@pivotal.io>
Authored: Wed Apr 13 17:02:15 2016 -0700
Committer: Matt <mm...@pivotal.io>
Committed: Wed Apr 13 17:02:15 2016 -0700
----------------------------------------------------------------------
.../HAWQ/2.0.0/package/scripts/hawqmaster.py | 6 +-
.../HAWQ/2.0.0/package/scripts/hawqsegment.py | 9 +--
.../HAWQ/2.0.0/package/scripts/hawqstandby.py | 7 +--
.../HAWQ/2.0.0/package/scripts/hawqstatus.py | 64 ++++++++------------
4 files changed, 34 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/bb5322e7/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py
index 98dedf1..a2f9c33 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py
@@ -16,10 +16,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
+
from resource_management import Script
from resource_management.core.resources.system import Execute
from resource_management.core.logger import Logger
-from resource_management.libraries.functions.check_process_status import check_process_status
from resource_management.libraries.functions.default import default
from resource_management.core.source import InlineTemplate
from resource_management.libraries.functions import stack_select
@@ -61,8 +61,8 @@ class HawqMaster(Script):
common.stop_component(hawq_constants.MASTER, params.hawq_master_address_port, hawq_constants.FAST)
def status(self, env):
- from hawqstatus import get_pid_file
- check_process_status(get_pid_file())
+ from hawqstatus import assert_component_running
+ assert_component_running(hawq_constants.MASTER)
def immediate_stop_hawq_service(self, env):
import params
http://git-wip-us.apache.org/repos/asf/ambari/blob/bb5322e7/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqsegment.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqsegment.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqsegment.py
index 8a5ad16..18a52af 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqsegment.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqsegment.py
@@ -16,11 +16,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
-import os
+
from resource_management import Script
-from resource_management.libraries.functions.check_process_status import check_process_status
-import utils
import common
import hawq_constants
@@ -55,12 +53,11 @@ class HawqSegment(Script):
common.stop_component(hawq_constants.SEGMENT, params.hawq_segment_address_port, mode)
def status(self, env):
- from hawqstatus import get_pid_file
- check_process_status(get_pid_file())
+ from hawqstatus import assert_component_running
+ assert_component_running(hawq_constants.SEGMENT)
def immediate_stop_hawq_segment(self, env):
self.stop(env, hawq_constants.IMMEDIATE)
-
if __name__ == "__main__":
HawqSegment().execute()
http://git-wip-us.apache.org/repos/asf/ambari/blob/bb5322e7/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py
index fb677ee..ad2a13d 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py
@@ -19,7 +19,6 @@ limitations under the License.
from resource_management import Script
from resource_management.core.logger import Logger
-from resource_management.libraries.functions.check_process_status import check_process_status
import common
import hawq_constants
@@ -52,8 +51,8 @@ class HawqStandby(Script):
common.stop_component(hawq_constants.STANDBY, params.hawq_master_address_port, hawq_constants.FAST)
def status(self, env):
- from hawqstatus import get_pid_file
- check_process_status(get_pid_file())
+ from hawqstatus import assert_component_running
+ assert_component_running(hawq_constants.STANDBY)
def activate_hawq_standby(self, env):
import utils
@@ -61,4 +60,4 @@ class HawqStandby(Script):
utils.exec_hawq_operation(hawq_constants.ACTIVATE, "{0} -a -M {1} -v --ignore-bad-hosts".format(hawq_constants.STANDBY, hawq_constants.FAST))
if __name__ == "__main__":
- HawqStandby().execute()
+ HawqStandby().execute()
http://git-wip-us.apache.org/repos/asf/ambari/blob/bb5322e7/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstatus.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstatus.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstatus.py
index a1b6dd9..92ac0af 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstatus.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstatus.py
@@ -16,49 +16,35 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
-import os
+from resource_management.core.shell import call
+from resource_management.core.exceptions import ComponentIsNotRunning
-from resource_management import Script
-from resource_management.core.resources.system import File
-from resource_management.core.exceptions import Fail
-
-import utils
import common
import hawq_constants
-
-def get_pid_file():
+PROCESS_INFO = {
+ hawq_constants.MASTER: {
+ 'port_property': 'hawq_master_address_port',
+ 'process_name': 'postgres'
+ },
+ hawq_constants.STANDBY: {
+ 'port_property': 'hawq_master_address_port',
+ 'process_name': 'gpsyncmaster'
+ },
+ hawq_constants.SEGMENT: {
+ 'port_property': 'hawq_segment_address_port',
+ 'process_name': 'postgres'
+ }
+}
+
+def assert_component_running(component):
"""
- Fetches the pid file, which will be used to get the status of the HAWQ Master, Standby
- or Segments
+ Based on the port and process identifies the status of the component
"""
+ port = common.get_local_hawq_site_property(PROCESS_INFO[component]['port_property'])
+ process = PROCESS_INFO[component]['process_name']
- config = Script.get_config()
-
- component_name = config['componentName']
- component = "master" if component_name in ["HAWQMASTER", "HAWQSTANDBY"] else "segment"
- hawq_pid_file = os.path.join(hawq_constants.hawq_pid_dir, "hawq-{0}.pid".format(component))
-
- File(hawq_pid_file, action='delete')
- utils.create_dir_as_hawq_user(hawq_constants.hawq_pid_dir)
-
- #Get hawq_master_directory or hawq_segment_directory value from hawq-site.xml depending
- #on the component
- hawq_site_directory_property = "hawq_{0}_directory".format(component)
-
- #hawq-site content from Ambari server will not be available when the
- #command type is STATUS_COMMAND. Hence, reading it directly from the local file
- postmaster_pid_file = os.path.join(common.get_local_hawq_site_property(
- hawq_site_directory_property), hawq_constants.postmaster_pid_filename)
-
- pid = ""
- if os.path.exists(postmaster_pid_file):
- with open(postmaster_pid_file, 'r') as fh:
- pid = fh.readline().strip()
-
- if not pid:
- raise Fail("Failed to fetch pid from {0}".format(postmaster_pid_file))
-
- File(hawq_pid_file, content=pid, owner=hawq_constants.hawq_user, group=hawq_constants.hawq_user)
-
- return hawq_pid_file
+ netstat_cmd = "netstat -tupln | egrep ':{0}\s' | egrep {1}".format(port, process)
+ return_code, _ = call(netstat_cmd)
+ if return_code:
+ raise ComponentIsNotRunning()
\ No newline at end of file