From dd710215139505f26f052a7dbdcdb5bf7f2e0532 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Wed, 31 Jul 2019 15:49:27 -0400 Subject: Fix compiler cache to hold for next transaction. Change-Id: Ibede4a378980717d49708f7665ab295534a092a0 Issue-ID: CCSDK-1046 Signed-off-by: Brinda Santh --- .../core/scripts/BluePrintCompilerCache.kt | 14 +++++++++----- .../core/scripts/BluePrintCompilerProxy.kt | 3 +++ .../core/utils/BluePrintMetadataUtils.kt | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'ms/controllerblueprints/modules/blueprint-core') diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt index db139eb59..fa6b0ab97 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt @@ -30,7 +30,7 @@ object BluePrintCompileCache { val log = logger(BluePrintCompileCache::class) private val classLoaderCache: LoadingCache = CacheBuilder.newBuilder() - .maximumSize(10) + .maximumSize(50) .build(BluePrintClassLoader) fun classLoader(key: String): URLClassLoader { @@ -38,8 +38,12 @@ object BluePrintCompileCache { } fun cleanClassLoader(key: String) { - classLoaderCache.invalidate(key) - log.info("Cleaned script cache($key)") + if(hasClassLoader(key)){ + classLoaderCache.invalidate(key) + log.info("Cleaned compiled cache($key)") + }else{ + log.warn("No compiled cache($key) present to clean.") + } } fun hasClassLoader(key: String): Boolean { @@ -52,7 +56,7 @@ object BluePrintClassLoader : CacheLoader() { val log = logger(BluePrintClassLoader::class) override fun load(key: String): URLClassLoader { - log.info("loading cache key($key)") + log.info("loading compiled cache($key)") val keyPath = normalizedFile(key) if (!keyPath.exists()) { throw BluePrintException("failed to load cache($key), missing files.") @@ -61,7 +65,7 @@ object BluePrintClassLoader : CacheLoader() { keyPath.walkTopDown() .filter { it.name.endsWith("cba-kts.jar") } .forEach { - log.debug("Adding (${it.absolutePath}) to cache key($key)") + log.debug("Adding (${it.absolutePath}) to cache($key)") urls.add(it.toURI().toURL()) } return URLClassLoader(urls.toTypedArray(), this.javaClass.classLoader) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerProxy.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerProxy.kt index e231f6d1c..546631240 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerProxy.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerProxy.kt @@ -63,6 +63,9 @@ open class BluePrintsCompilerProxy(private val hostConfiguration: ScriptingHostC /** Check cache is present for the blueprint scripts */ val hasCompiledCache = BluePrintCompileCache.hasClassLoader(blueprintSourceCode.cacheKey) + log.debug("Jar Exists : ${compiledJarFile.exists()}, Regenerate : ${blueprintSourceCode.regenerate}," + + " Compiled hash(${blueprintSourceCode.cacheKey}) : $hasCompiledCache") + if (!compiledJarFile.exists() || blueprintSourceCode.regenerate || !hasCompiledCache) { log.info("compiling for cache key(${blueprintSourceCode.cacheKey})") diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index 3a1edccc0..669ab3fef 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -186,7 +186,7 @@ class BluePrintMetadataUtils { val bluePrintScriptsService = BluePrintScriptsServiceImpl() val bluePrintDefinitions = bluePrintScriptsService .scriptInstance(normalizedBasePath, toscaMetaData.templateName!!, - toscaMetaData.templateVersion!!, definitionClassName, true) + toscaMetaData.templateVersion!!, definitionClassName, false) // Get the Service Template val serviceTemplate = bluePrintDefinitions.serviceTemplate() -- cgit 1.2.3-korg