aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2019-07-31 15:49:27 -0400
committerBrinda Santh Muthuramalingam <brindasanth@in.ibm.com>2019-07-31 22:23:14 +0000
commitdd710215139505f26f052a7dbdcdb5bf7f2e0532 (patch)
tree9238c43fbd0539194b5c4f4f818dae06ec405431 /ms
parent82a22313f1d87f32417c5a878ffb7e20cfd464fe (diff)
Fix compiler cache to hold for next transaction.
Change-Id: Ibede4a378980717d49708f7665ab295534a092a0 Issue-ID: CCSDK-1046 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt14
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerProxy.kt3
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt2
4 files changed, 19 insertions, 6 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index 094fb68da..a81d35eac 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -30,6 +30,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfigur
import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.slf4j.LoggerFactory
import org.springframework.http.codec.multipart.FilePart
@@ -63,6 +65,10 @@ class ExecutionServiceHandler(private val bluePrintPathConfiguration: BluePrintP
throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
"Error in Upload CBA: ${e.message}", e)
} finally {
+ // Clean blueprint script cache
+ val cacheKey = BluePrintFileUtils
+ .compileCacheKey(normalizedPathName(bluePrintPathConfiguration.blueprintWorkingPath,saveId))
+ BluePrintCompileCache.cleanClassLoader(cacheKey)
deleteNBDir(blueprintArchive)
deleteNBDir(blueprintWorking)
}
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<String, URLClassLoader> = 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<String, URLClassLoader>() {
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<String, URLClassLoader>() {
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<BluePrintDefinitions>(normalizedBasePath, toscaMetaData.templateName!!,
- toscaMetaData.templateVersion!!, definitionClassName, true)
+ toscaMetaData.templateVersion!!, definitionClassName, false)
// Get the Service Template
val serviceTemplate = bluePrintDefinitions.serviceTemplate()