aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/scripts/VESConfigPoller.sh
diff options
context:
space:
mode:
authorVijay VK <vv770d@att.com>2018-02-27 18:12:41 +0000
committerVENKATESH KUMAR <vv770d@att.com>2018-02-27 13:13:40 -0500
commite6cb4531f2dfd8c5e4e3b90c69891cca686142ee (patch)
tree1ece3a2d8124bc0d9df31f9a1c78a5b9ee651034 /src/main/scripts/VESConfigPoller.sh
parent8ead72e4a6b7b92e370d89fa2590ea21c2764428 (diff)
Misc updates to collector
Change-Id: I7a3b52c454442d6a9f93331142b78bf671ffcd0a Signed-off-by: VENKATESH KUMAR <vv770d@att.com> Issue-ID: DCAEGEN2-373
Diffstat (limited to 'src/main/scripts/VESConfigPoller.sh')
-rw-r--r--src/main/scripts/VESConfigPoller.sh125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/main/scripts/VESConfigPoller.sh b/src/main/scripts/VESConfigPoller.sh
new file mode 100644
index 00000000..75c2b585
--- /dev/null
+++ b/src/main/scripts/VESConfigPoller.sh
@@ -0,0 +1,125 @@
+#!/bin/sh -x
+###
+# ============LICENSE_START=======================================================
+# PROJECT
+# ================================================================================
+# Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed 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.
+# ============LICENSE_END=========================================================
+###
+# redirect stdout/stderr to a file
+#exec &> /opt/app/VESCollector/logs/console.txt
+
+usage() {
+ echo "VESConfigPoller.sh"
+}
+
+
+## Remove singel execution logic (loop 0)
+## On configupdate function, remove LoadDynamicConfig and invoke VESrestfulCollector stop/start
+
+BASEDIR=/opt/app/VESCollector/
+CONFIGFILENAME=/opt/app/KV-Configuration.json
+
+
+collector_configupdate() {
+
+ echo `date +"%Y%m%d.%H%M%S%3N"` - VESConfigPoller.sh:collector_configupdate
+ if [ -z "$CONSUL_HOST" ] || [ -z "$CONFIG_BINDING_SERVICE" ] || [ -z "$HOSTNAME" ]; then
+ echo "INFO: USING STANDARD CONTROLLER CONFIGURATION"
+ else
+ # move into base directory
+ cd $BASEDIR
+
+ CONFIG_FETCH=org.onap.dcae.controller.FetchDynamicConfig
+ $JAVA -cp "etc${PATHSEP}lib/*" $CONFIG_FETCH $*
+ if [ $? -ne 0 ]; then
+ echo "ERROR: Failed to fetch dynamic configuration from consul into container $CONFIGFILENAME"
+ else
+ echo "INFO: Dynamic config fetched successfully"
+ fi
+ sleep 10s
+ FLAG=0
+
+ if [ -f $CONFIGFILENAME ]; then
+ if [[ $(find $CONFIGFILENAME -mmin -$CBSPOLLTIMER -print) ]]; then
+ echo "File $CONFIGFILENAME is updated under $CBSPOLLTIMER minutes; Loader to be invoked"
+ FLAG=1
+ else
+ echo "File $CONFIGFILENAME NOT updated in last $CBSPOLLTIMER minutes; no configuration update!"
+ FLAG=0
+ fi
+
+ if [ $FLAG -eq 1 ]; then
+ echo "INFO: CONFIGFILE updated; triggering restart"
+ /opt/app/VESCollector/bin/VESrestfulCollector.sh stop
+ /opt/app/VESCollector/bin/VESrestfulCollector.sh start &
+ else
+ echo "INFO: CONFIGFILE load skipped"
+ fi
+ else
+ echo "ERROR: Configuration file $CONFIGFILENAME missing"
+ fi
+ fi
+}
+
+
+
+if [ -z "$CBSPOLLTIMER" ]; then
+ echo "CBSPOLLTIMER not set; set this to polling frequency in minutes"
+ exit 1
+fi
+
+
+## Pre-setting
+
+# use JAVA_HOME if provided
+if [ -z "$JAVA_HOME" ]; then
+ echo "ERROR: JAVA_HOME not setup"
+ echo "Startup Aborted!!"
+ exit 1
+ #JAVA=java
+else
+ JAVA=$JAVA_HOME/bin/java
+fi
+
+
+
+# determine a path separator that works for this platform
+PATHSEP=":"
+case "$(uname -s)" in
+
+ Darwin)
+ ;;
+
+ Linux)
+ ;;
+
+ CYGWIN*|MINGW32*|MSYS*)
+ PATHSEP=";"
+ ;;
+
+ *)
+ ;;
+esac
+
+
+
+##Run in loop the config pull and check
+while true
+do
+ sleep $(echo $CBSPOLLTIMER)m
+ collector_configupdate | tee -a ${BASEDIR}/logs/console.txt
+done
+