summaryrefslogtreecommitdiffstats
path: root/src/main/scripts/VESConfigPoller.sh
diff options
context:
space:
mode:
authorPawelSzalapski <pawel.szalapski@nokia.com>2018-08-02 10:31:56 +0200
committerPawelSzalapski <pawel.szalapski@nokia.com>2018-08-06 09:43:32 +0200
commit7752c2d818e6d19e4d805c2fd6760b4a13d601bc (patch)
tree053cbc5afd76a8b9644ec62298053aad8cf5e2a8 /src/main/scripts/VESConfigPoller.sh
parent654ebdff4c9ec2487b819d2b76273732759de4c7 (diff)
Implement second part of dynamic DMaaP config
VESCollector app can now fetch CBS configuration and rebuilt the part regarding sending events dynamically, without restarting application. Application will still be restarted by a .sh script, if there were changes regarding collector.properties file. The decision of whether dynamic configuration should be triggered is now based on existence of env vars CONSUL_HOST, CONFIG_BINDING_SERVICE, HOSTNAME, not as previously on CBSPOLLTIME. Frequency at which the config check should happen is now exposed via property from collector.properties Change-Id: I98ff160fa51d08d84a23c716d90ceaacbe17ada6 Signed-off-by: PawelSzalapski <pawel.szalapski@nokia.com> Issue-ID: DCAEGEN2-519
Diffstat (limited to 'src/main/scripts/VESConfigPoller.sh')
-rw-r--r--src/main/scripts/VESConfigPoller.sh125
1 files changed, 0 insertions, 125 deletions
diff --git a/src/main/scripts/VESConfigPoller.sh b/src/main/scripts/VESConfigPoller.sh
deleted file mode 100644
index 75c2b585..00000000
--- a/src/main/scripts/VESConfigPoller.sh
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/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
-