You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/02/18 14:33:43 UTC
[24/33] ambari git commit: AMBARI-15019: Refactor HAWQ common.py
after moving config substitution to UI (lavjain via jaoki)
AMBARI-15019: Refactor HAWQ common.py after moving config substitution to UI (lavjain via jaoki)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b15c0f3d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b15c0f3d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b15c0f3d
Branch: refs/heads/branch-dev-patch-upgrade
Commit: b15c0f3d7432dbd6b6ce6c678b6cc2884a73c68b
Parents: f11d76d
Author: Jun Aoki <ja...@apache.org>
Authored: Wed Feb 17 14:46:58 2016 -0800
Committer: Jun Aoki <ja...@apache.org>
Committed: Wed Feb 17 14:46:58 2016 -0800
----------------------------------------------------------------------
.../HAWQ/2.0.0/package/scripts/common.py | 63 ++++----------------
.../HAWQ/2.0.0/package/scripts/params.py | 19 ++++--
2 files changed, 26 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/b15c0f3d/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
index 23342f5..b5353e8 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
@@ -20,9 +20,7 @@ import os
import time
import crypt
import filecmp
-from resource_management.libraries.resources.xml_config import XmlConfig
from resource_management.core.resources.system import Execute, Directory, File
-from resource_management.libraries.script.config_dictionary import ConfigDictionary
from resource_management.core.logger import Logger
from resource_management.core.system import System
from resource_management.core.exceptions import Fail
@@ -67,58 +65,23 @@ def setup_common_configurations():
"""
Sets up the config files common to master, standby and segment nodes.
"""
- __update_hdfs_client()
- __update_yarn_client()
- __update_hawq_site()
- __set_osparams()
-
-def __update_hdfs_client():
- """
- Writes hdfs-client.xml on the local filesystem on hawq nodes.
- If hdfs ha is enabled, appends related parameters to hdfs-client.xml
- """
- import params
-
- hdfs_client_dict = params.hdfs_client.copy()
-
- XmlConfig("hdfs-client.xml",
- conf_dir=hawq_constants.hawq_config_dir,
- configurations=ConfigDictionary(hdfs_client_dict),
- configuration_attributes=params.config['configuration_attributes']['hdfs-client'],
- owner=hawq_constants.hawq_user,
- group=hawq_constants.hawq_group,
- mode=0644)
-
-
-def __update_yarn_client():
- """
- Writes yarn-client.xml on the local filesystem on hawq nodes.
- If yarn ha is enabled, appends related parameters to yarn-client.xml
- """
import params
- XmlConfig("yarn-client.xml",
- conf_dir=hawq_constants.hawq_config_dir,
- configurations=params.yarn_client,
- configuration_attributes=params.config['configuration_attributes']['yarn-client'],
- owner=hawq_constants.hawq_user,
- group=hawq_constants.hawq_group,
- mode=0644)
+ # Write hdfs-client.xml on the local filesystem. If hdfs HA is enabled, append related parameters
+ params.XmlConfig(filename="hdfs-client.xml",
+ configurations=params.hdfs_client,
+ configuration_attributes=params.config_attrs['hdfs-client'])
+ # Write yarn-client.xml on the local filesystem. If yarn HA is enabled, append related parameters
+ params.XmlConfig(filename="yarn-client.xml",
+ configurations=params.yarn_client,
+ configuration_attributes=params.config_attrs['yarn-client'])
-def __update_hawq_site():
- """
- Sets up hawq-site.xml
- """
- import params
-
- XmlConfig("hawq-site.xml",
- conf_dir=hawq_constants.hawq_config_dir,
- configurations=ConfigDictionary(params.hawq_site),
- configuration_attributes=params.config['configuration_attributes']['hawq-site'],
- owner=hawq_constants.hawq_user,
- group=hawq_constants.hawq_group,
- mode=0644)
+ # Write hawq-site.xml on the local filesystem.
+ params.XmlConfig(filename="hawq-site.xml",
+ configurations=params.hawq_site,
+ configuration_attributes=params.config_attrs['hawq-site'])
+ __set_osparams()
def __set_osparams():
http://git-wip-us.apache.org/repos/asf/ambari/blob/b15c0f3d/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py
index 48b933e..74c9813 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py
@@ -16,16 +16,16 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
-import os
import functools
-from hawq_constants import PXF_PORT, pxf_hdfs_test_dir
+import hawq_constants
from resource_management import Script
from resource_management.libraries.functions.default import default
from resource_management.libraries.resources.hdfs_resource import HdfsResource
+from resource_management.libraries.resources.xml_config import XmlConfig
from resource_management.libraries.functions import get_kinit_path
config = Script.get_config()
-
+config_attrs = config['configuration_attributes']
def __get_component_host(component):
"""
@@ -76,9 +76,16 @@ HdfsResource = functools.partial(HdfsResource,
default_fs=default_fs)
+# XMLConfig partial function
+XmlConfig = functools.partial(XmlConfig,
+ conf_dir=hawq_constants.hawq_config_dir,
+ owner=hawq_constants.hawq_user,
+ group=hawq_constants.hawq_group,
+ mode=0644)
+
# For service Check
is_pxf_installed = __get_component_host("pxf_hosts") is not None
-namenode_path = "{0}:{1}".format(__get_component_host("namenode_host"), PXF_PORT) if dfs_nameservice is None else dfs_nameservice
+namenode_path = "{0}:{1}".format(__get_component_host("namenode_host"), hawq_constants.PXF_PORT) if dfs_nameservice is None else dfs_nameservice
table_definition = {
"HAWQ": {
"name": "ambari_hawq_test",
@@ -90,13 +97,13 @@ table_definition = {
"name": "ambari_hawq_pxf_hdfs_readable_test",
"create_type": "READABLE EXTERNAL",
"drop_type": "EXTERNAL",
- "description": "(col1 int) LOCATION ('pxf://{0}{1}?PROFILE=HdfsTextSimple') FORMAT 'TEXT'".format(namenode_path, pxf_hdfs_test_dir)
+ "description": "(col1 int) LOCATION ('pxf://{0}{1}?PROFILE=HdfsTextSimple') FORMAT 'TEXT'".format(namenode_path, hawq_constants.pxf_hdfs_test_dir)
},
"EXTERNAL_HDFS_WRITABLE": {
"name": "ambari_hawq_pxf_hdfs_writable_test",
"create_type": "WRITABLE EXTERNAL",
"drop_type": "EXTERNAL",
- "description": "(col1 int) LOCATION ('pxf://{0}{1}?PROFILE=HdfsTextSimple') FORMAT 'TEXT'".format(namenode_path, pxf_hdfs_test_dir)
+ "description": "(col1 int) LOCATION ('pxf://{0}{1}?PROFILE=HdfsTextSimple') FORMAT 'TEXT'".format(namenode_path, hawq_constants.pxf_hdfs_test_dir)
}
}