ambarizip archive怎么打开.zip什么时候生成的

git commit: AMBARI-7955 - Alerts: Expose the Ability to Create Host-Only Alerts (jonathanhurley)
ambari-commits mailing list archives
Message view
jonathanhur...@apache.org
git commit: AMBARI-7955 - Alerts: Expose the Ability to Create Host-Only Alerts (jonathanhurley)
Repository: ambari
Updated Branches:
refs/heads/trunk 54989df2a -& 17b05b236
AMBARI-7955 - Alerts: Expose the Ability to Create Host-Only Alerts (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/17b05b23
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/17b05b23
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/17b05b23
Branch: refs/heads/trunk
Commit: 17b05b5de4b619a1c98ae4145716f
Parents: 54989df
Author: Jonathan Hurley &&
Authored: Fri Oct 24 14:01:29
Committer: Jonathan Hurley &&
Committed: Fri Oct 24 16:55:20
----------------------------------------------------------------------
ambari-agent/pom.xml
.../ambari_agent/AlertSchedulerHandler.py
.../src/main/python/ambari_agent/Controller.py
.../ambari_agent/CustomServiceOrchestrator.py
.../src/main/python/ambari_agent/FileCache.py
.../python/ambari_agent/alerts/script_alert.py
.../src/test/python/ambari_agent/TestAlerts.py
.../TestCustomServiceOrchestrator.py
ambari-server/pom.xml
| 602 ++++++++++---------
.../server/api/services/AmbariMetaInfo.java
.../server/metadata/AgentAlertDefinitions.java
.../state/alert/AlertDefinitionFactory.java
ambari-server/src/main/python/ambari-server.py
.../python/ambari_server/resourceFilesKeeper.py |
ambari-server/src/main/resources/alerts.json
.../resources/host_scripts/alert_disk_space.py
.../server/api/services/AmbariMetaInfoTest.java |
.../metadata/AgentAlertDefinitionsTest.java
.../src/test/python/TestResourceFilesKeeper.py
19 files changed, 750 insertions(+), 325 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-agent/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-agent/pom.xml b/ambari-agent/pom.xml
index a00dad 100644
--- a/ambari-agent/pom.xml
+++ b/ambari-agent/pom.xml
@@ -586,6 +586,7 @@
&include&stacks/stack_advisor.py&/include&
&include&stacks/${stack.distribution}/**/*&/include&
&include&custom_actions/**/*&/include&
&include&host_scripts/**/*&/include&
&/includes&
&filtering&false&/filtering&
&/resource&
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-agent/src/main/python/ambari_agent/AlertSchedulerHandler.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/AlertSchedulerHandler.py b/ambari-agent/src/main/python/ambari_agent/AlertSchedulerHandler.py
index a8de9f6..19c1ee0 100644
--- a/ambari-agent/src/main/python/ambari_agent/AlertSchedulerHandler.py
+++ b/ambari-agent/src/main/python/ambari_agent/AlertSchedulerHandler.py
@@ -53,9 +53,10 @@ class AlertSchedulerHandler():
def __init__(self, cachedir, stacks_dir, in_minutes=True):
def __init__(self, cachedir, stacks_dir, host_scripts_dir, in_minutes=True):
self.cachedir = cachedir
self.stacks_dir = stacks_dir
self.host_scripts_dir = host_scripts_dir
if not os.path.exists(cachedir) and AlertSchedulerHandler.make_cachedir:
@@ -222,7 +223,8 @@ class AlertSchedulerHandler():
elif source_type == AlertSchedulerHandler.TYPE_PORT:
alert = PortAlert(json_definition, source)
elif source_type == AlertSchedulerHandler.TYPE_SCRIPT:
source['stacks_dir'] = self.stacks_dir
source['stacks_directory'] = self.stacks_dir
source['host_scripts_directory'] = self.host_scripts_dir
alert = ScriptAlert(json_definition, source)
elif source_type == AlertSchedulerHandler.TYPE_WEB:
alert = WebAlert(json_definition, source)
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-agent/src/main/python/ambari_agent/Controller.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Controller.py b/ambari-agent/src/main/python/ambari_agent/Controller.py
index 1f9471d..dc3a1cf 100644
--- a/ambari-agent/src/main/python/ambari_agent/Controller.py
+++ b/ambari-agent/src/main/python/ambari_agent/Controller.py
@@ -81,8 +81,11 @@ class Controller(threading.Thread):
cache_dir = '/var/lib/ambari-agent/cache'
stacks_cache_dir = os.path.join(cache_dir, FileCache.STACKS_CACHE_DIRECTORY)
host_scripts_cache_dir = os.path.join(cache_dir, FileCache.HOST_SCRIPTS_CACHE_DIRECTORY)
alerts_cache_dir = os.path.join(cache_dir, 'alerts')
self.alert_scheduler_handler = AlertSchedulerHandler(alerts_cache_dir, stacks_cache_dir)
self.alert_scheduler_handler = AlertSchedulerHandler(alerts_cache_dir,
stacks_cache_dir, host_scripts_cache_dir)
def __del__(self):
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
index 94aa87e..e0c5a28 100644
--- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
+++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
@@ -106,7 +106,9 @@ class CustomServiceOrchestrator():
server_url_prefix = command['hostLevelParams']['jdk_location']
server_url_prefix = command['commandParams']['jdk_location']
task_id = "status"
task_id = command['taskId']
command_name = command['roleCommand']
@@ -123,18 +125,24 @@ class CustomServiceOrchestrator():
if command_name == self.CUSTOM_COMMAND_COMMAND:
command_name = command['hostLevelParams']['custom_command']
# forces a hash challenge on the directories to keep them updated, even
# if the return type is not used
self.file_cache.get_host_scripts_base_dir(server_url_prefix)
hook_dir = self.file_cache.get_hook_base_dir(command, server_url_prefix)
base_dir = self.file_cache.get_service_base_dir(command, server_url_prefix)
script_path = self.resolve_script_path(base_dir, script, script_type)
script_tuple = (script_path, base_dir)
tmpstrucoutfile = os.path.join(self.tmp_dir,
"structured-out-{0}.json".format(task_id))
if script_type.upper() != self.SCRIPT_TYPE_PYTHON:
# We don't support anything else yet
if script_type.upper() != self.SCRIPT_TYPE_PYTHON:
message = "Unknown script type {0}".format(script_type)
raise AgentException(message)
# Execute command using proper interpreter
handle = None
if(command.has_key('__handle')):
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-agent/src/main/python/ambari_agent/FileCache.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/FileCache.py b/ambari-agent/src/main/python/ambari_agent/FileCache.py
index 91ec76a..67b14b2 100644
--- a/ambari-agent/src/main/python/ambari_agent/FileCache.py
+++ b/ambari-agent/src/main/python/ambari_agent/FileCache.py
@@ -39,6 +39,7 @@ class FileCache():
STACKS_CACHE_DIRECTORY="stacks"
CUSTOM_ACTIONS_CACHE_DIRECTORY="custom_actions"
HOST_SCRIPTS_CACHE_DIRECTORY="host_scripts"
HASH_SUM_FILE=".hash"
ARCHIVE_NAME="archive.zip"
@@ -92,6 +93,16 @@ class FileCache():
server_url_prefix)
def get_host_scripts_base_dir(self, server_url_prefix):
Returns a base directory for host scripts (host alerts, etc) which
are scripts that are not part of the main agent code
return self.provide_directory(self.cache_dir,
self.HOST_SCRIPTS_CACHE_DIRECTORY,
server_url_prefix)
def provide_directory(self, cache_path, subdirectory, server_url_prefix):
Ensures that directory at cache is up-to-date. Throws a CachingException
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-agent/src/main/python/ambari_agent/alerts/script_alert.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/alerts/script_alert.py b/ambari-agent/src/main/python/ambari_agent/alerts/script_alert.py
index a00b699..644
--- a/ambari-agent/src/main/python/ambari_agent/alerts/script_alert.py
+++ b/ambari-agent/src/main/python/ambari_agent/alerts/script_alert.py
@@ -40,11 +40,17 @@ class ScriptAlert(BaseAlert):
super(ScriptAlert, self).__init__(alert_meta, alert_source_meta)
self.path = None
self.stacks_dir = None
self.host_scripts_dir = None
if 'path' in alert_source_meta:
self.path = alert_source_meta['path']
if 'stacks_dir' in alert_source_meta:
self.stacks_dir = alert_source_meta['stacks_dir']
if 'stacks_directory' in alert_source_meta:
self.stacks_dir = alert_source_meta['stacks_directory']
if 'host_scripts_directory' in alert_source_meta:
self.host_scripts_dir = alert_source_meta['host_scripts_directory']
# execute the get_tokens() method so that this script correctly populates
# its list of keys
@@ -78,18 +84,25 @@ class ScriptAlert(BaseAlert):
def _load_source(self):
if self.path is None and self.stack_path is None:
if self.path is None and self.stack_path is None and self.host_scripts_dir is None:
raise Exception("The attribute 'path' must be specified")
paths = self.path.split('/')
path_to_script = self.path
if not os.path.exists(self.path) and self.stacks_dir is not None:
paths = self.path.split('/')
# if the path doesn't exist and stacks dir is defined, try that
if not os.path.exists(path_to_script) and self.stacks_dir is not None:
path_to_script = os.path.join(self.stacks_dir, *paths)
# if the path doesn't exist and the host script dir is defined, try that
if not os.path.exists(path_to_script) and self.host_scripts_dir is not None:
path_to_script = os.path.join(self.host_scripts_dir, *paths)
# if the path can't be evaluated, throw exception
if not os.path.exists(path_to_script) or not os.path.isfile(path_to_script):
raise Exception(
"Resolved script '{0}' does not appear to be a script".format(
path_to_script))
"Unable to find '{0}' as an absolute path or part of {1} or {2}".format(self.path,
self.stacks_dir, self.host_scripts_dir))
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Executing script check {0}".format(path_to_script))
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-agent/src/test/python/ambari_agent/TestAlerts.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestAlerts.py b/ambari-agent/src/test/python/ambari_agent/TestAlerts.py
index ef0caae..74d440f 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestAlerts.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestAlerts.py
@@ -47,8 +47,9 @@ class TestAlerts(TestCase):
def test_start(self, aps_add_interval_job_mock, aps_start_mock):
test_file_path = os.path.join('ambari_agent', 'dummy_files')
test_stack_path = os.path.join('ambari_agent', 'dummy_files')
test_host_scripts_path = os.path.join('ambari_agent', 'dummy_files')
ash = AlertSchedulerHandler(test_file_path, test_stack_path)
ash = AlertSchedulerHandler(test_file_path, test_stack_path, test_host_scripts_path)
ash.start()
self.assertTrue(aps_add_interval_job_mock.called)
@@ -136,13 +137,15 @@ class TestAlerts(TestCase):
# normally set by AlertSchedulerHandler
json['source']['stacks_dir'] = os.path.join('ambari_agent', 'dummy_files')
json['source']['stacks_directory'] = os.path.join('ambari_agent', 'dummy_files')
json['source']['host_scripts_directory'] = os.path.join('ambari_agent', 'host_scripts')
collector = AlertCollector()
sa = ScriptAlert(json, json['source'])
sa.set_helpers(collector, {'foo-site/bar': 'rendered-bar', 'foo-site/baz':'rendered-baz'} )
self.assertEquals(json['source']['path'], sa.path)
self.assertEquals(json['source']['stacks_dir'], sa.stacks_dir)
self.assertEquals(json['source']['stacks_directory'], sa.stacks_dir)
self.assertEquals(json['source']['host_scripts_directory'], sa.host_scripts_dir)
sa.collect()
@@ -369,8 +372,9 @@ class TestAlerts(TestCase):
def test_reschedule(self):
test_file_path = os.path.join('ambari_agent', 'dummy_files')
test_stack_path = os.path.join('ambari_agent', 'dummy_files')
ash = AlertSchedulerHandler(test_file_path, test_stack_path)
test_host_scripts_path = os.path.join('ambari_agent', 'dummy_files')
ash = AlertSchedulerHandler(test_file_path, test_stack_path, test_host_scripts_path)
ash.start()
self.assertEquals(1, ash.get_job_count())
@@ -420,8 +424,9 @@ class TestAlerts(TestCase):
def test_disabled_definitions(self):
test_file_path = os.path.join('ambari_agent', 'dummy_files')
test_stack_path = os.path.join('ambari_agent', 'dummy_files')
test_host_scripts_path = os.path.join('ambari_agent', 'dummy_files')
ash = AlertSchedulerHandler(test_file_path, test_stack_path)
ash = AlertSchedulerHandler(test_file_path, test_stack_path, test_host_scripts_path)
ash.start()
self.assertEquals(1, ash.get_job_count())
@@ -472,8 +477,9 @@ class TestAlerts(TestCase):
def test_immediate_alert(self):
test_file_path = os.path.join('ambari_agent', 'dummy_files')
test_stack_path = os.path.join('ambari_agent', 'dummy_files')
test_host_scripts_path = os.path.join('ambari_agent', 'dummy_files')
ash = AlertSchedulerHandler(test_file_path, test_stack_path)
ash = AlertSchedulerHandler(test_file_path, test_stack_path, test_host_scripts_path)
ash.start()
self.assertEquals(1, ash.get_job_count())
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
index 6a61c0d..5f426e6 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -156,6 +156,7 @@ class TestCustomServiceOrchestrator(TestCase):
@patch.object(CustomServiceOrchestrator, "resolve_script_path")
@patch.object(CustomServiceOrchestrator, "resolve_hook_script_path")
@patch.object(FileCache, "get_host_scripts_base_dir")
@patch.object(FileCache, "get_service_base_dir")
@patch.object(FileCache, "get_hook_base_dir")
@patch.object(CustomServiceOrchestrator, "dump_command_to_json")
@@ -163,8 +164,11 @@ class TestCustomServiceOrchestrator(TestCase):
@patch.object(FileCache, "__init__")
def test_runCommand(self, FileCache_mock,
run_file_mock, dump_command_to_json_mock,
get_hook_base_dir_mock, get_service_base_dir_mock,
resolve_hook_script_path_mock, resolve_script_path_mock):
get_hook_base_dir_mock, get_service_base_dir_mock,
get_host_scripts_base_dir_mock,
resolve_hook_script_path_mock,
resolve_script_path_mock):
FileCache_mock.return_value = None
command = {
'role' : 'REGION_SERVER',
@@ -182,6 +186,8 @@ class TestCustomServiceOrchestrator(TestCase):
'taskId' : '3',
'roleCommand': 'INSTALL'
get_host_scripts_base_dir_mock.return_value = "/host_scripts"
get_service_base_dir_mock.return_value = "/basedir/"
resolve_script_path_mock.return_value = "/basedir/scriptpath"
resolve_hook_script_path_mock.return_value = \
@@ -238,6 +244,7 @@ class TestCustomServiceOrchestrator(TestCase):
@patch("shell.kill_process_with_children")
@patch.object(CustomServiceOrchestrator, "resolve_script_path")
@patch.object(CustomServiceOrchestrator, "resolve_hook_script_path")
@patch.object(FileCache, "get_host_scripts_base_dir")
@patch.object(FileCache, "get_service_base_dir")
@patch.object(FileCache, "get_hook_base_dir")
@patch.object(CustomServiceOrchestrator, "dump_command_to_json")
@@ -246,6 +253,7 @@ class TestCustomServiceOrchestrator(TestCase):
def test_cancel_command(self, FileCache_mock,
run_file_mock, dump_command_to_json_mock,
get_hook_base_dir_mock, get_service_base_dir_mock,
get_host_scripts_base_dir_mock,
resolve_hook_script_path_mock, resolve_script_path_mock,
kill_process_with_children_mock):
FileCache_mock.return_value = None
@@ -265,6 +273,8 @@ class TestCustomServiceOrchestrator(TestCase):
'taskId' : '3',
'roleCommand': 'INSTALL'
get_host_scripts_base_dir_mock.return_value = "/host_scripts"
get_service_base_dir_mock.return_value = "/basedir/"
resolve_script_path_mock.return_value = "/basedir/scriptpath"
resolve_hook_script_path_mock.return_value = \
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index c66358e..65e
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -555,6 +555,17 @@
&/sources&
&/mapping&
&directory&/var/lib/ambari-server/resources/host_scripts&/directory&
&filemode&755&/filemode&
&username&root&/username&
&groupname&root&/groupname&
&location&src/main/resources/host_scripts&/location&
&/sources&
&/mapping&
&/mappings&
&/configuration&
@@ -647,296 +658,307 @@
&filemode&755&/filemode&
&src&conf/unix/ambari.properties&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/etc/ambari-server/conf&/prefix&
&src&conf/unix/log4j.properties&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/etc/ambari-server/conf&/prefix&
&src&conf/unix/krb5JAASLogin.conf&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/etc/ambari-server/conf&/prefix&
&!-- /q001 --&
&src&conf/unix/ambari-env.sh&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&700&/filemode&
&src&conf/unix/install-helper.sh&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&700&/filemode&
&src&src/main/resources/slider_resources/README.txt&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/apps/&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&conf/unix/ca.config&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/keys&/prefix&
&src&src/main/resources/db&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/keys/db&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&700&/filemode&
&src&target/classes/Ambari-DDL-Postgres-CREATE.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/Ambari-DDL-Postgres-DROP.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&target/classes/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/Ambari-DDL-Postgres-EMBEDDED-DROP.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&target/classes/Ambari-DDL-Oracle-CREATE.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&target/classes/Ambari-DDL-MySQL-CREATE.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/Ambari-DDL-Oracle-DROP.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/Ambari-DDL-MySQL-DROP.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&${project.build.directory}/DBConnectionVerification.jar&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/role_command_order.json&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/scripts&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/scripts&/prefix&
&filemode&755&/filemode&
&src&${ambari-admin-dir}/target&/src&
&type&directory&/type&
&includes&*.jar&/includes&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/views&/prefix&
&src&src/main/python/UpgradeHelper_HDP2.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/scripts&/prefix&
&filemode&755&/filemode&
&src&src/main/resources/upgrade/ddl&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/upgrade/ddl&/prefix&
&src&src/main/resources/upgrade/dml&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/upgrade/dml&/prefix&
&src&target/classes/stacks/${stack.distribution}&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/stacks/${stack.distribution}&/prefix&
&src&target/classes/stacks/stack_advisor.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/stacks&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/python/ambari_server&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/usr/lib/python2.6/site-packages/ambari_server&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/python/bootstrap.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/usr/lib/python2.6/site-packages/ambari_server&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/python/setupAgent.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/usr/lib/python2.6/site-packages/ambari_server&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/python/os_check_type.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/usr/lib/python2.6/site-packages/ambari_server&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&${basedir}/target/version&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/custom_action_definitions&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/custom_action_definitions&/prefix&
&src&src/main/resources/custom_actions&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/custom_actions&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&conf/unix/ambari.properties&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/etc/ambari-server/conf&/prefix&
&src&conf/unix/log4j.properties&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/etc/ambari-server/conf&/prefix&
&src&conf/unix/krb5JAASLogin.conf&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/etc/ambari-server/conf&/prefix&
&!-- /q001 --&
&src&conf/unix/ambari-env.sh&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&700&/filemode&
&src&conf/unix/install-helper.sh&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&700&/filemode&
&src&src/main/resources/slider_resources/README.txt&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/apps/&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&conf/unix/ca.config&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/keys&/prefix&
&src&src/main/resources/db&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/keys/db&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&700&/filemode&
&src&target/classes/Ambari-DDL-Postgres-CREATE.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/Ambari-DDL-Postgres-DROP.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&target/classes/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/Ambari-DDL-Postgres-EMBEDDED-DROP.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&target/classes/Ambari-DDL-Oracle-CREATE.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&target/classes/Ambari-DDL-MySQL-CREATE.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/Ambari-DDL-Oracle-DROP.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/Ambari-DDL-MySQL-DROP.sql&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&${project.build.directory}/DBConnectionVerification.jar&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/role_command_order.json&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/scripts&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/scripts&/prefix&
&filemode&755&/filemode&
&src&${ambari-admin-dir}/target&/src&
&type&directory&/type&
&includes&*.jar&/includes&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/views&/prefix&
&src&src/main/python/UpgradeHelper_HDP2.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/scripts&/prefix&
&filemode&755&/filemode&
&src&src/main/resources/upgrade/ddl&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/upgrade/ddl&/prefix&
&src&src/main/resources/upgrade/dml&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/upgrade/dml&/prefix&
&src&target/classes/stacks/${stack.distribution}&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/stacks/${stack.distribution}&/prefix&
&src&target/classes/stacks/stack_advisor.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/stacks&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/python/ambari_server&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/usr/lib/python2.6/site-packages/ambari_server&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/python/bootstrap.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/usr/lib/python2.6/site-packages/ambari_server&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/python/setupAgent.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/usr/lib/python2.6/site-packages/ambari_server&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/python/os_check_type.py&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/usr/lib/python2.6/site-packages/ambari_server&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&${basedir}/target/version&/src&
&type&file&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources&/prefix&
&src&src/main/resources/custom_action_definitions&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/custom_action_definitions&/prefix&
&src&src/main/resources/custom_actions&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/custom_actions&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
&src&src/main/resources/host_scripts&/src&
&type&directory&/type&
&type&perm&/type&
&prefix&/var/lib/ambari-server/resources/host_scripts&/prefix&
&user&root&/user&
&group&root&/group&
&filemode&755&/filemode&
${project.basedir}/../ambari-common/src/main/python/ambari_commons
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index 03cf208..3d67fe9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -48,6 +48,7 @@ import org.apache.ambari.server.customactions.ActionD
import org.apache.ambari.server.customactions.ActionDefinitionM
import org.apache.ambari.server.events.AlertDefinitionRegistrationE
import org.apache.ambari.server.events.publishers.AmbariEventP
+import org.apache.ambari.server.metadata.AgentAlertD
import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
import org.apache.ambari.server.orm.dao.MetainfoDAO;
import org.apache.ambari.server.orm.entities.AlertDefinitionE
@@ -68,10 +69,10 @@ import org.apache.ambari.server.state.alert.AlertD
import org.apache.ambari.server.state.alert.AlertDefinitionF
import org.apache.ambari.server.state.stack.LatestRepoC
import org.apache.ambari.server.state.stack.MetricD
+import org.apache.ambari.server.state.stack.OsF
import org.apache.ambari.server.state.stack.RepositoryX
import org.apache.ambari.server.state.stack.RepositoryXml.Os;
import org.apache.ambari.server.state.stack.RepositoryXml.R
-import org.apache.ambari.server.state.stack.OsF
import org.slf4j.L
import org.slf4j.LoggerF
@@ -157,6 +158,12 @@ public class AmbariMetaInfo {
private AlertDefinitionFactory alertDefinitionF
* All of the {@link AlertDefinition}s that are scoped for the agents.
private AgentAlertDefinitions agentAlertD
* Publishes the following events:
* &li&{@link AlertDefinitionRegistrationEvent} when new alerts are merged
@@ -211,6 +218,7 @@ public class AmbariMetaInfo {
alertDefinitionFactory = injector.getInstance(AlertDefinitionFactory.class);
alertDefinitionDao = injector.getInstance(AlertDefinitionDAO.class);
eventPublisher = injector.getInstance(AmbariEventPublisher.class);
agentAlertDefinitions = injector.getInstance(AgentAlertDefinitions.class);
@@ -28,10 @@ public class AmbariMetaInfo {
* database and merges any new or updated definitions. This method will first
* determine the services that are installed on each cluster to prevent alert
* definitions from undeployed services from being shown.
* This method will also detect "agent" alert definitions, which are
* definitions that should be run on agent hosts but are not associated with a
* service.
* @param clusters
* @throws AmbariException
@@ -19,18 @@ public class AmbariMetaInfo {
// host-only alert definitions
List&AlertDefinition& agentDefinitions = agentAlertDefinitions.getDefinitions();
for (AlertDefinition agentDefinition : agentDefinitions) {
AlertDefinitionEntity entity = mappedEntities.get(agentDefinition.getName());
// no enti create a new entity
if (null == entity) {
entity = alertDefinitionFactory.coerce(clusterId, agentDefinition);
persist.add(entity);
// persist any new or updated definition
for (AlertDefinitionEntity entity : persist) {
if (LOG.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/main/java/org/apache/ambari/server/metadata/AgentAlertDefinitions.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/metadata/AgentAlertDefinitions.java b/ambari-server/src/main/java/org/apache/ambari/server/metadata/AgentAlertDefinitions.java
new file mode 100644
index 0000000..af70a51
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/metadata/AgentAlertDefinitions.java
@@ -0,0 +1,93 @@
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.
See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.
The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+package org.apache.ambari.server.
+import java.io.InputS
+import java.io.InputStreamR
+import java.util.ArrayL
+import java.util.L
+import java.util.S
+import org.apache.ambari.server.
+import org.apache.ambari.server.state.alert.AlertD
+import org.apache.ambari.server.state.alert.AlertDefinitionF
+import org.slf4j.L
+import org.slf4j.LoggerF
+import com.google.inject.I
+import com.google.inject.S
+ * The {@link AgentAlertDefinitions} class is used to represent the alerts
+ * defined in {@code alerts.json} which are for {@link Components#AMBARI_AGENT}.
+ * These alerts are bound to the host and are not part of a cluster or hadoop
+ * service.
+@Singleton
+public class AgentAlertDefinitions {
private final static Logger LOG = LoggerFactory.getLogger(AgentAlertDefinitions.class);
* The agent host definitions.
private List&AlertDefinition& m_definitions =
* The factory that will load the definitions from the alerts.json file.
private AlertDefinitionFactory m_
* Gets all of the {@link AlertDefinition}s that exist on the path for all
* agent hosts.
* @return the alerts with {@link Components#AMBARI_AGENT} as the component
and {@code AMBARI} as the service.
public List&AlertDefinition& getDefinitions() {
if (null == m_definitions) {
m_definitions = new ArrayList&AlertDefinition&();
InputStream inputStream = ClassLoader.getSystemResourceAsStream("alerts.json");
InputStreamReader reader = new InputStreamReader(inputStream);
Set&AlertDefinition& definitions = m_factory.getAlertDefinitions(
reader, "AMBARI");
String agentComponent = Components.AMBARI_AGENT.name();
for (AlertDefinition definition : definitions) {
if (agentComponent.equals(definition.getComponentName())) {
m_definitions.add(definition);
} catch (Exception exception) {
LOG.error("Unable to load the Ambari alerts JSON file", exception);
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
index 5c9bd0a..cd937ef 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
@@ -19,6 +19,8 @@ package org.apache.ambari.server.state.
import java.io.F
import java.io.FileR
+import java.io.IOE
+import java.io.R
import java.lang.reflect.T
import java.util.HashS
import java.util.L
@@ -29,6 +31,7 @@ import java.util.UUID;
import org.apache.ambari.server.AmbariE
import org.apache.ambari.server.orm.entities.AlertDefinitionE
+import mons.io.IOU
import org.slf4j.L
import org.slf4j.LoggerF
@@ -91,18 +94,49 @@ public class AlertDefinitionFactory {
public Set&AlertDefinition& getAlertDefinitions(File alertDefinitionFile,
String serviceName) throws AmbariException {
FileReader fileReader = new FileReader(alertDefinitionFile);
return getAlertDefinitions(fileReader, serviceName);
} catch (IOException ioe) {
String message = "Could not read the alert definition file";
LOG.error(message, ioe);
throw new AmbariException(message, ioe);
* Gets a list of all of the alert definitions defined in the resource pointed
* to by the specified reader for the given service. There should have a
* mapping between the service and the alerts defined for that service. This
* is necessary since some services are combined in a single
* {@code metainfo.xml} and only have a single directory on the stack.
* The supplied reader is closed when this method completes.
* @param reader
the reader to read from (not {@code null}). This will be closed
after reading is done.
* @param serviceName
the name of the service to extract definitions for (not
{@code null}).
* @return the definitions for the specified service, or an empty set.
* @throws AmbariException
if there was a problem reading or parsing the JSON.
public Set&AlertDefinition& getAlertDefinitions(Reader reader,
String serviceName) throws AmbariException {
// { MAPR : {definitions}, YARN : {definitions} }
Map&String, Map&String, List&AlertDefinition&&& serviceDefinitionMap =
Type type = new TypeToken&Map&String, Map&String, List&AlertDefinition&&&&() {}.getType();
FileReader fileReader = new FileReader(alertDefinitionFile);
serviceDefinitionMap = m_gson.fromJson(fileReader, type);
serviceDefinitionMap = m_gson.fromJson(reader, type);
} catch (Exception e) {
LOG.error("Could not read the alert definition file", e);
throw new AmbariException("Could not read alert definition file", e);
LOG.error("Could not read the alert definitions", e);
throw new AmbariException("Could not read alert definitions", e);
} finally {
IOUtils.closeQuietly(reader);
Set&AlertDefinition& definitions = new HashSet&AlertDefinition&();
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py
index d066162..bd76a5e 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -555,6 +555,7 @@ NR_ADJUST_OWNERSHIP_LIST = [
("/var/lib/ambari-server/keys/.ssh", "700", "{0}", False),
("/var/lib/ambari-server/resources/stacks/", "755", "{0}", True),
("/var/lib/ambari-server/resources/custom_actions/", "755", "{0}", True),
("/var/lib/ambari-server/resources/host_scripts/", "755", "{0}", True),
("/etc/ambari-server/conf", "644", "{0}", True),
("/etc/ambari-server/conf", "755", "{0}", False),
("/etc/ambari-server/conf/password.dat", "640", "{0}", False),
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py b/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py
index 1e1bdb6..9d138a1 100644
--- a/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py
+++ b/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py
@@ -38,6 +38,7 @@ class ResourceFilesKeeper():
PACKAGE_DIR="package"
STACKS_DIR="stacks"
CUSTOM_ACTIONS_DIR="custom_actions"
HOST_SCRIPTS_DIR="host_scripts"
# For these directories archives are created
ARCHIVABLE_DIRS = [HOOKS_DIR, PACKAGE_DIR]
@@ -87,12 +88,19 @@ class ResourceFilesKeeper():
self.update_directory_archive(full_path)
custom_actions_root = os.path.join(self.resources_dir,
self.CUSTOM_ACTIONS_DIR)
self.dbg_out("Updating archive for custom_actions dir at {0}...".format(
custom_actions_root))
# custom actions
custom_actions_root = os.path.join(self.resources_dir,self.CUSTOM_ACTIONS_DIR)
self.dbg_out("Updating archive for {0} dir at {1}...".format(self.CUSTOM_ACTIONS_DIR,
custom_actions_root))
# agent host scripts
host_scripts_root = os.path.join(self.resources_dir,self.HOST_SCRIPTS_DIR)
self.dbg_out("Updating archive for {0} dir at {1}...".format(self.HOST_SCRIPTS_DIR,
host_scripts_root))
# update the directories so that the .hash is generated
self.update_directory_archive(custom_actions_root)
self.update_directory_archive(host_scripts_root)
def list_stacks(self, stacks_root):
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/main/resources/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/alerts.json b/ambari-server/src/main/resources/alerts.json
new file mode 100644
index 0000000..bea2c85
--- /dev/null
+++ b/ambari-server/src/main/resources/alerts.json
@@ -0,0 +1,19 @@
"AMBARI": {
"service": [
"AMBARI_AGENT" : [
"name": "ambari_agent_disk_usage",
"label": "Ambari Agent Disk Usage",
"interval": 1,
"scope": "HOST",
"enabled": true,
"source": {
"type": "SCRIPT",
"path": "alert_disk_space.py"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/main/resources/host_scripts/alert_disk_space.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/host_scripts/alert_disk_space.py b/ambari-server/src/main/resources/host_scripts/alert_disk_space.py
new file mode 100644
index c7a842
--- /dev/null
+++ b/ambari-server/src/main/resources/host_scripts/alert_disk_space.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.
See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.
The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+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 collections
+import os
+import platform
+def get_tokens():
return None
+def execute(parameters=None):
returns a tuple containing the result code and a pre-formatted result label
disk_usage = None
disk_usage = _get_disk_usage()
except NotImplementedError, platform_error:
return (('CRITICAL', [str(platform_error)]))
disk_usage = _get_disk_usage()
if disk_usage is None or disk_usage.total == 0:
return (('CRITICAL', ['Unable to determine the disk usage']))
result_code = 'OK'
percent = disk_usage.used / float(disk_usage.total) * 100
if percent & 50:
result_code = 'WARNING'
elif percent & 80:
result_code = 'CRTICAL'
label = 'Capacity Used: [{0:.2f}%, {1}], Capacity Total: [{2}]'.format(
percent, _get_formatted_size(disk_usage.used),
_get_formatted_size(disk_usage.total) )
return ((result_code, [label]))
+def _get_disk_usage(path='/'):
returns a named tuple that contains the total, used, and free disk space
if 'statvfs' in dir(os):
disk_stats = os.statvfs(path)
free = disk_stats.f_bavail * disk_stats.f_frsize
total = disk_stats.f_blocks * disk_stats.f_frsize
used = (disk_stats.f_blocks - disk_stats.f_bfree) * disk_stats.f_frsize
raise NotImplementedError("{0} is not a supported platform for this alert".format(platform.platform()))
DiskInfo = collections.namedtuple('DiskInfo', 'total used free')
return DiskInfo(total=total, used=used, free=free)
+def _get_formatted_size(bytes):
formats the supplied bytes
if bytes & 1000:
return '%i' % bytes + ' B'
elif 1000 &= bytes & 1000000:
return '%.1f' % (bytes/1000.0) + ' KB'
elif 1000000 &= bytes & :
return '%.1f' % (bytes / ) + ' MB'
&= bytes & 0:
return '%.1f' % (bytes/.0) + ' GB'
return '%.1f' % (bytes/0.0) + ' TB'
+if __name__ == '__main__':
print _get_disk_usage(os.getcwd())
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index ebad409..2b
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -58,20 @@ public class AmbariMetaInfoTest {
AlertDefinitionDAO dao = injector.getInstance(AlertDefinitionDAO.class);
List&AlertDefinitionEntity& definitions = dao.findAll();
assertEquals(5, definitions.size());
assertEquals(6, definitions.size());
// figure out how many of these alerts were merged into from the
// non-stack alerts.json
int hostAlertCount = 0;
for (AlertDefinitionEntity definition : definitions) {
if (definition.getServiceName().equals("AMBARI")
&& definition.getComponentName().equals("AMBARI_AGENT")) {
hostAlertCount++;
assertEquals(1, hostAlertCount);
assertEquals(5, definitions.size() - hostAlertCount);
for (AlertDefinitionEntity definition : definitions) {
definition.setScheduleInterval(28);
@@ -81,7 @@ public class AmbariMetaInfoTest {
metaInfo.reconcileAlertDefinitions(clusters);
definitions = dao.findAll();
assertEquals(5, definitions.size());
assertEquals(6, definitions.size());
for (AlertDefinitionEntity definition : definitions) {
assertEquals(28, definition.getScheduleInterval().intValue());
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
new file mode 100644
index a9830
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
@@ -0,0 +1,61 @@
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.
See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.
The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+package org.apache.ambari.server.
+import java.util.L
+import junit.framework.A
+import org.apache.ambari.server.
+import org.apache.ambari.server.orm.InMemoryDefaultTestM
+import org.apache.ambari.server.state.alert.AlertD
+import org.junit.B
+import org.junit.T
+import com.google.inject.G
+import com.google.inject.I
+ * Tets {@link AgentAlertDefinitions}.
+public class AgentAlertDefinitionsTest {
private Injector m_
public void before() {
m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
* Tests loading the agent alerts.
public void testLoadingAlerts() {
AgentAlertDefinitions agentAlerts = m_injector.getInstance(AgentAlertDefinitions.class);
List&AlertDefinition& definitions = agentAlerts.getDefinitions();
Assert.assertEquals(1, definitions.size());
for( AlertDefinition definition : definitions){
Assert.assertEquals(Components.AMBARI_AGENT.name(),
definition.getComponentName());
Assert.assertEquals("AMBARI", definition.getServiceName());
http://git-wip-us.apache.org/repos/asf/ambari/blob/17b05b23/ambari-server/src/test/python/TestResourceFilesKeeper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestResourceFilesKeeper.py b/ambari-server/src/test/python/TestResourceFilesKeeper.py
index afa57fd..d65f5ff 100644
--- a/ambari-server/src/test/python/TestResourceFilesKeeper.py
+++ b/ambari-server/src/test/python/TestResourceFilesKeeper.py
@@ -85,7 +85,8 @@ class TestResourceFilesKeeper(TestCase):
"dummy_stack/HIVE/package'),\n "
"call('../resources/TestAmbaryServer.samples/"
"dummy_stack/HIVE/package'),\n "
"call('../resources/stacks/custom_actions')]")
"call('../resources/stacks/custom_actions'),\n "
"call('../resources/stacks/host_scripts')]")
(inline, 7-Bit, 64206 bytes)

我要回帖

更多关于 zip archive怎么打开 的文章

 

随机推荐