[ambari] 28/36: AMBARI-22437 : Create an 'AD Manager' component in Ambari Metrics Service stack side. (avijayan)
This is an automated email from the ASF dual-hosted git repository. avijayan pushed a commit to branch branch-feature-AMBARI-23212 in repository https://gitbox.apache.org/repos/asf/ambari.git commit a2aec07065986395e5bc05de8bdcd389409a0a95 Author: Aravindan Vijayan AuthorDate: Tue Nov 14 09:46:00 2017 -0800 AMBARI-22437 : Create an 'AD Manager' component in Ambari Metrics Service stack side. (avijayan) --- .../conf/unix/ambari-metrics-admanager.sh | 194 + .../conf/unix/log4j.properties | 31 .../pom.xml| 14 +- .../src/main/resources/config.yml | 6 +- .../adservice/app/AnomalyDetectionAppConfig.scala | 7 +- .../adservice/app/AnomalyDetectionAppModule.scala | 9 +- .../configuration/HBaseConfiguration.scala | 2 + .../MetricCollectorConfiguration.scala | 16 +- .../MetricDefinitionDBConfiguration.scala | 6 +- .../adservice/db/LevelDbStoreAccessor.scala| 56 ++ .../adservice/leveldb/LevelDBDatasource.scala | 17 +- .../adservice/metadata/ADMetadataProvider.scala| 17 +- .../metadata/MetricDefinitionServiceImpl.scala | 32 ++-- .../adservice/resource/AnomalyResource.scala | 2 +- .../resource/MetricDefinitionResource.scala| 24 ++- .../subsystem/trend/TrendAnomalyInstance.scala | 17 ++ .../app/AnomalyDetectionAppConfigTest.scala| 14 +- .../adservice/app/DefaultADResourceSpecTest.scala | 4 +- .../adservice/leveldb/LevelDBDataSourceTest.scala | 4 +- .../0.1.0/configuration/ams-admanager-config.xml | 51 ++ .../0.1.0/configuration/ams-admanager-env.xml | 12 +- .../0.1.0/configuration/ams-admanager-log4j.xml| 86 + .../AMBARI_METRICS/0.1.0/metainfo.xml | 1 + .../AMBARI_METRICS/0.1.0/package/scripts/ams.py| 23 ++- .../AMBARI_METRICS/0.1.0/package/scripts/params.py | 15 +- .../0.1.0/package/scripts/status_params.py | 2 +- .../package/templates/admanager_config.yaml.j2 | 20 +++ .../stacks/2.0.6/AMBARI_METRICS/test_admanager.py | 106 +++ .../test/python/stacks/2.0.6/configs/default.json | 13 ++ .../stacks/2.0.6/configs/default_ams_embedded.json | 13 ++ 30 files changed, 751 insertions(+), 63 deletions(-) diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/conf/unix/ambari-metrics-admanager.sh b/ambari-metrics/ambari-metrics-anomaly-detection-service/conf/unix/ambari-metrics-admanager.sh new file mode 100644 index 000..f1a1ae3 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/conf/unix/ambari-metrics-admanager.sh @@ -0,0 +1,194 @@ +#!/usr/bin/env bash + +# 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 + +PIDFILE=/var/run//var/run/ambari-metrics-anomaly-detection/ambari-metrics-admanager.pid +OUTFILE=/var/log/ambari-metrics-anomaly-detection/ambari-metrics-admanager.out + +CONF_DIR=/etc/ambari-metrics-anomaly-detection/conf +DAEMON_NAME=ams_admanager + +STOP_TIMEOUT=5 + +function write_pidfile +{ +local pidfile="$1" +echo $! > "${pidfile}" 2>/dev/null +if [[ $? -gt 0 ]]; then + echo "ERROR: Cannot write pid ${pidfile}." | tee -a $STARTUPFILE + exit 1; +fi +} + +function java_setup +{ + # Bail if we did not detect it + if [[ -z "${JAVA_HOME}" ]]; then +echo "ERROR: JAVA_HOME is not set and could not be found." +exit 1 + fi + + if [[ ! -d "${JAVA_HOME}" ]]; then +echo "ERROR: JAVA_HOME ${JAVA_HOME} does not exist." +exit 1 + fi + + JAVA="${JAVA_HOME}/bin/java" + + if [[ ! -x "$JAVA" ]]; then +echo "ERROR: $JAVA is not executable." +exit 1 + fi +} + +function daemon_status() +{ + # + # LSB 4.1.0 compatible status command (1) + # + # 0 = program is running + # 1 = dead, but still a pid (2) + # 2 = (not used by us) + # 3 = not running + # + # 1 - this is not an endorsement of the LSB + # + # 2 - technically, the specification says /var/run/pid, so + # we should never return this value, but we're giving + # them the benefit of a doubt and returning 1 even if + # our pid is not in in /var/run . + # + + local pidfile="$1" + shift + + local pid + + if [[ -f "${pidfile}" ]]; then +pid=$(cat "${pidfile}") +
[ambari] 28/36: AMBARI-22437 : Create an 'AD Manager' component in Ambari Metrics Service stack side. (avijayan)
This is an automated email from the ASF dual-hosted git repository. avijayan pushed a commit to branch branch-feature-AMBARI-23100 in repository https://gitbox.apache.org/repos/asf/ambari.git commit 6120fa158f2892ecd0f753b17709d0ab9e7cd82d Author: Aravindan Vijayan AuthorDate: Tue Nov 14 09:46:00 2017 -0800 AMBARI-22437 : Create an 'AD Manager' component in Ambari Metrics Service stack side. (avijayan) --- .../conf/unix/ambari-metrics-admanager.sh | 194 + .../conf/unix/log4j.properties | 31 .../pom.xml| 14 +- .../src/main/resources/config.yml | 6 +- .../adservice/app/AnomalyDetectionAppConfig.scala | 7 +- .../adservice/app/AnomalyDetectionAppModule.scala | 9 +- .../configuration/HBaseConfiguration.scala | 2 + .../MetricCollectorConfiguration.scala | 16 +- .../MetricDefinitionDBConfiguration.scala | 6 +- .../adservice/db/LevelDbStoreAccessor.scala| 56 ++ .../adservice/leveldb/LevelDBDatasource.scala | 17 +- .../adservice/metadata/ADMetadataProvider.scala| 17 +- .../metadata/MetricDefinitionServiceImpl.scala | 32 ++-- .../adservice/resource/AnomalyResource.scala | 2 +- .../resource/MetricDefinitionResource.scala| 24 ++- .../subsystem/trend/TrendAnomalyInstance.scala | 17 ++ .../app/AnomalyDetectionAppConfigTest.scala| 14 +- .../adservice/app/DefaultADResourceSpecTest.scala | 4 +- .../adservice/leveldb/LevelDBDataSourceTest.scala | 4 +- .../0.1.0/configuration/ams-admanager-config.xml | 51 ++ .../0.1.0/configuration/ams-admanager-env.xml | 12 +- .../0.1.0/configuration/ams-admanager-log4j.xml| 86 + .../AMBARI_METRICS/0.1.0/metainfo.xml | 1 + .../AMBARI_METRICS/0.1.0/package/scripts/ams.py| 23 ++- .../AMBARI_METRICS/0.1.0/package/scripts/params.py | 15 +- .../0.1.0/package/scripts/status_params.py | 2 +- .../package/templates/admanager_config.yaml.j2 | 20 +++ .../stacks/2.0.6/AMBARI_METRICS/test_admanager.py | 106 +++ .../test/python/stacks/2.0.6/configs/default.json | 13 ++ .../stacks/2.0.6/configs/default_ams_embedded.json | 13 ++ 30 files changed, 751 insertions(+), 63 deletions(-) diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/conf/unix/ambari-metrics-admanager.sh b/ambari-metrics/ambari-metrics-anomaly-detection-service/conf/unix/ambari-metrics-admanager.sh new file mode 100644 index 000..f1a1ae3 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/conf/unix/ambari-metrics-admanager.sh @@ -0,0 +1,194 @@ +#!/usr/bin/env bash + +# 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 + +PIDFILE=/var/run//var/run/ambari-metrics-anomaly-detection/ambari-metrics-admanager.pid +OUTFILE=/var/log/ambari-metrics-anomaly-detection/ambari-metrics-admanager.out + +CONF_DIR=/etc/ambari-metrics-anomaly-detection/conf +DAEMON_NAME=ams_admanager + +STOP_TIMEOUT=5 + +function write_pidfile +{ +local pidfile="$1" +echo $! > "${pidfile}" 2>/dev/null +if [[ $? -gt 0 ]]; then + echo "ERROR: Cannot write pid ${pidfile}." | tee -a $STARTUPFILE + exit 1; +fi +} + +function java_setup +{ + # Bail if we did not detect it + if [[ -z "${JAVA_HOME}" ]]; then +echo "ERROR: JAVA_HOME is not set and could not be found." +exit 1 + fi + + if [[ ! -d "${JAVA_HOME}" ]]; then +echo "ERROR: JAVA_HOME ${JAVA_HOME} does not exist." +exit 1 + fi + + JAVA="${JAVA_HOME}/bin/java" + + if [[ ! -x "$JAVA" ]]; then +echo "ERROR: $JAVA is not executable." +exit 1 + fi +} + +function daemon_status() +{ + # + # LSB 4.1.0 compatible status command (1) + # + # 0 = program is running + # 1 = dead, but still a pid (2) + # 2 = (not used by us) + # 3 = not running + # + # 1 - this is not an endorsement of the LSB + # + # 2 - technically, the specification says /var/run/pid, so + # we should never return this value, but we're giving + # them the benefit of a doubt and returning 1 even if + # our pid is not in in /var/run . + # + + local pidfile="$1" + shift + + local pid + + if [[ -f "${pidfile}" ]]; then +pid=$(cat "${pidfile}") +