Fix scheduler shutdown config function. 23/100423/1
authorBrinda Santh <bs2796@att.com>
Fri, 17 Jan 2020 20:08:46 +0000 (15:08 -0500)
committerBrinda Santh <bs2796@att.com>
Fri, 17 Jan 2020 20:08:46 +0000 (15:08 -0500)
Optimize application name accessing in Docker Compose.

Issue-ID: CCSDK-1917
Signed-off-by: Brinda Santh <bs2796@att.com>
Change-Id: I6b055de7ef5a8ac4a0c103499997ed272bd74ac6

ms/blueprintsprocessor/application/src/main/dc/docker-compose-cluster.yaml
ms/blueprintsprocessor/application/src/main/dc/docker-compose.yaml
ms/blueprintsprocessor/application/src/main/docker/startService.sh
ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationSchedulerService.kt
ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
ms/blueprintsprocessor/modules/commons/nats-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/service/TokenAuthNatsService.kt

index 7159534..d53b85f 100644 (file)
@@ -62,8 +62,7 @@ services:
       CLUSTER_STORAGE_PATH: /opt/app/onap/config/cluster
       #CLUSTER_CONFIG_FILE: /opt/app/onap/config/atomix/atomix-multicast.conf
       NATS_CLUSTER_ID: cds-cluster
-      NATS_HOSTS: nats://nats:4222
-      APPLICATIONNAME: cds-controller
+      APP_NAME: cds-controller
       BUNDLEVERSION: 1.0.0
       APP_CONFIG_HOME: /opt/app/onap/config
       STICKYSELECTORKEY:
@@ -96,8 +95,7 @@ services:
       CLUSTER_STORAGE_PATH: /opt/app/onap/config/cluster
       #CLUSTER_CONFIG_FILE: /opt/app/onap/config/atomix/atomix-multicast.conf
       NATS_CLUSTER_ID: cds-cluster
-      NATS_HOSTS: nats://nats:4222
-      APPLICATIONNAME: resource-resolution
+      APP_NAME: resource-resolution
       BUNDLEVERSION: 1.0.0
       APP_CONFIG_HOME: /opt/app/onap/config
       STICKYSELECTORKEY:
@@ -123,8 +121,7 @@ services:
       CLUSTER_NODE_ID: py-executor-0
       CLUSTER_MEMBERS: cds-controller-0,resource-resolution-0,py-executor-0
       NATS_CLUSTER_ID: cds-cluster
-      NATS_HOSTS: nats://nats:4222
-      APPLICATIONNAME: py-executor
+      APP_NAME: py-executor
       BUNDLEVERSION: 1.0.0
       APP_CONFIG_HOME: /opt/app/onap/config
       STICKYSELECTORKEY:
index 8f2a786..9f2a65d 100755 (executable)
@@ -36,6 +36,7 @@ services:
   cds-controller-default:
     depends_on:
       - db
+      - nats
     image: onap/ccsdk-blueprintsprocessor:latest
     container_name: cds-controller-default
     hostname: cds-controller-default
@@ -53,7 +54,7 @@ services:
         type: volume
         source: controller-config
     environment:
-      APPLICATIONNAME: cds-controller
+      APP_NAME: cds-controller
       BUNDLEVERSION: 1.0.0
       APP_CONFIG_HOME: /opt/app/onap/config
       STICKYSELECTORKEY:
@@ -75,6 +76,7 @@ services:
   py-executor-default:
     depends_on:
       - db
+      - nats
     image: onap/ccsdk-py-executor
     container_name: py-executor-default
     hostname: py-executor-default
@@ -88,7 +90,7 @@ services:
         type: volume
         source: blueprints-deploy
     environment:
-      APPLICATIONNAME: py-executor
+      APP_NAME: py-executor
       BUNDLEVERSION: 1.0.0
       APP_CONFIG_HOME: /opt/app/onap/config
       STICKYSELECTORKEY:
index f516a3c..a9d3992 100644 (file)
@@ -8,7 +8,7 @@ export APP_HOME=/opt/app/onap
 keytool -import -noprompt -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -alias ONAP -import -file $APP_CONFIG_HOME/ONAP_RootCA.cer
 
 exec java -classpath "/etc:${APP_HOME}/lib/*:/lib/*:/src:/schema:/generated-sources:${APP_CONFIG_HOME}:${APP_HOME}" \
--DappName=${APPLICATIONNAME} -DappVersion=${BUNDLEVERSION} \
+-DappName=${APP_NAME} -DappVersion=${BUNDLEVERSION} \
 -DrouteOffer=${ROUTEOFFER} \
 -DVERSION_ROUTEOFFER_ENVCONTEXT=${BUNDLEVERSION}/${STICKYSELECTORKEY}/${ENVCONTEXT} \
 -DSecurityFilePath=/etc \
@@ -16,6 +16,6 @@ exec java -classpath "/etc:${APP_HOME}/lib/*:/lib/*:/src:/schema:/generated-sour
 -Dms_name=org.onap.ccsdk.cds.blueprintsprocessor \
 -Dlogging.config=${APP_CONFIG_HOME}/logback.xml \
 -Djava.security.egd=file:/dev/./urandom \
--DAPPNAME=${APPLICATIONNAME} -DAPPENV=${APP_ENV} -DAPPVERSION=${APP_VERSION} -DNAMESPACE=${NAMESPACE} \
+-DAPPNAME=${APP_NAME} -DAPPENV=${APP_ENV} -DAPPVERSION=${APP_VERSION} -DNAMESPACE=${NAMESPACE} \
 -Dspring.config.location=${APP_CONFIG_HOME}/ \
 org.onap.ccsdk.cds.blueprintsprocessor.BlueprintProcessorApplicationKt
index 2f08c1c..aaefcc7 100644 (file)
@@ -38,10 +38,10 @@ open class MessagePrioritizationSchedulerService(
     /** This is sample scheduler implementation used during starting application with configuration.
     @EventListener(ApplicationReadyEvent::class)
     open fun init() = runBlocking {
-        log.info("Starting PrioritizationListeners...")
-        startScheduling(MessagePrioritizationSample.samplePrioritizationConfiguration())
+    log.info("Starting PrioritizationListeners...")
+    startScheduling(MessagePrioritizationSample.samplePrioritizationConfiguration())
     }
-    */
+     */
 
     open suspend fun startScheduling() {
         val prioritizationConfiguration = messagePrioritizationService.getConfiguration()
@@ -55,8 +55,9 @@ open class MessagePrioritizationSchedulerService(
         }
     }
 
-    open suspend fun shutdownScheduling(prioritizationConfiguration: PrioritizationConfiguration) {
+    open suspend fun shutdownScheduling() {
         keepGoing = false
+        val prioritizationConfiguration = messagePrioritizationService.getConfiguration()
         delay(prioritizationConfiguration.shutDownConfiguration.waitMill)
     }
 
index 7f150f5..35bc494 100644 (file)
@@ -207,7 +207,7 @@ open class MessagePrioritizationConsumerTest {
             launch {
                 /** To debug increase the delay time */
                 delay(20)
-                messagePrioritizationSchedulerService.shutdownScheduling(configuration)
+                messagePrioritizationSchedulerService.shutdownScheduling()
             }
         }
     }
index d1254b2..50cc442 100644 (file)
@@ -24,9 +24,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core
  */
 object BluePrintConstants {
 
-    val APP_NAME = System.getProperty("APPLICATION_NAME")
-        ?: System.getProperty("APP_NAME")
-        ?: System.getProperty("APPNAME")
+    val APP_NAME = System.getenv("APP_NAME")
         ?: "cds-controller"
 
     const val DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
index 43a43bc..7c24b70 100644 (file)
@@ -35,7 +35,7 @@ open class TokenAuthNatsService(private val natsConnectionProperties: TokenAuthN
         if (!::streamingConnection.isInitialized) {
             log.info(
                 "NATS connection requesting for cluster(${natsConnectionProperties.clusterId}) with" +
-                    "clientId($natsConnectionProperties.clientId)"
+                    "clientId(${natsConnectionProperties.clientId})"
             )
 
             val serverList = natsConnectionProperties.host.splitCommaAsList()