From 55e4780ba5f1de52060eaf76608a588b5be7c788 Mon Sep 17 00:00:00 2001 From: Julien Fontaine Date: Wed, 2 Dec 2020 16:25:08 -0500 Subject: Fixed NoClassDefFoundError when USE_SCRIPT_COMPILE_CACHE is set to false USE_SCRIPT_COMPILE_CACHE set to false cleans the Class Loader cache after each kotlin script execution. When several kotlin script are executed in parallel (ie no dependency between them) and USE_SCRIPT_COMPILE_CACHE=false then the class loader from the cache may be deleted before one of those executed kotlin script get the time to finish which to the NoClassDefFoundError. Removed cleanupInstance method for kotlin script executors that where causing the class loader to be removed prematurely. Now the behaviour is to remove the class loader from the cache only when we publish a new CBA which was already the case when CDS run with a single instance. In cluster mode, a topic has been added to hazelcast to allow the instance publishing the updated CBA to communicate to the other instances by sending a message to clean the class loader for this CBA from their cache. Added mutex on kotlin script compilation to fix race condition. For concurrent kotlin script execution each process wanted to compile an executable but it was causing a race condition if a process tries to execute while another still compile. Mutex on the execution path prevent this behaviour Issue-ID: CCSDK-3052 Signed-off-by: Julien Fontaine Signed-off-by: Jozsef Csongvai Change-Id: I6ab002352b3272898ad0b183341ee664652c8ae3 --- .../resolution/capabilities/IpAssignResolutionCapabilityTest.kt | 4 ---- .../resolution/capabilities/NamingResolutionCapabilityTest.kt | 6 ++---- .../processor/CapabilityResourceResolutionProcessorTest.kt | 8 -------- 3 files changed, 2 insertions(+), 16 deletions(-) (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapabilityTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapabilityTest.kt index 8a954c130..4ce5df18f 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapabilityTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapabilityTest.kt @@ -86,10 +86,6 @@ class IpAssignResolutionCapabilityTest { .scriptInstance(any(), any(), any()) } returns IpAssignResolutionCapability() - coEvery { - componentFunctionScriptingService.cleanupInstance(any(), any()) - } returns mockk() - val raRuntimeService = mockk() every { raRuntimeService.bluePrintContext() } returns mockk() every { raRuntimeService.getInputValue("fixed_ipv4_Address_01") } returns NullNode.getInstance() diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapabilityTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapabilityTest.kt index 449845f7f..8c0aca49e 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapabilityTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapabilityTest.kt @@ -32,6 +32,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.util import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType @@ -87,11 +88,8 @@ class NamingResolutionCapabilityTest { .scriptInstance(any(), any(), any()) } returns NamingResolutionCapability() - coEvery { - componentFunctionScriptingService.cleanupInstance(any(), any()) - } returns mockk() - val raRuntimeService = mockk() + every { raRuntimeService.getBluePrintError() } returns BluePrintError() every { raRuntimeService.bluePrintContext() } returns mockk() every { raRuntimeService.getInputValue("vf-module-name") } returns NullNode.getInstance() every { raRuntimeService.getInputValue("vnfc-name") } returns NullNode.getInstance() diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt index f618b41db..1b0058b90 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt @@ -52,10 +52,6 @@ class CapabilityResourceResolutionProcessorTest { .scriptInstance(any(), any(), any()) } returns MockCapabilityScriptRA() - coEvery { - componentFunctionScriptingService.cleanupInstance(any(), any()) - } returns mockk() - val raRuntimeService = mockk() every { raRuntimeService.bluePrintContext() } returns mockk() every { raRuntimeService.getInputValue("test-property") } returns NullNode.getInstance() @@ -100,10 +96,6 @@ class CapabilityResourceResolutionProcessorTest { .scriptInstance(any(), BluePrintConstants.SCRIPT_JYTHON, any()) } returns MockCapabilityScriptRA() - coEvery { - componentFunctionScriptingService.cleanupInstance(any(), any()) - } returns mockk() - val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext) val capabilityResourceResolutionProcessor = -- cgit 1.2.3-korg