aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/job/command
diff options
context:
space:
mode:
authorPATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>2020-08-13 12:35:01 -0400
committerPATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>2020-08-31 15:06:10 -0400
commit62c72edd91b2d5485683274298b8249670663519 (patch)
treef9534a62c76fbdc85dc7fbf86c9a9f71b7863d29 /vid-app-common/src/main/java/org/onap/vid/job/command
parentbc25167f4ef0aabdcc55d1d286081808e1e47ae9 (diff)
Pause Upon VF Module Failure
Issue-ID: VID-862 Currently in VID, once a failure is received from SO on the instantiation of a VF Module, it is assumed that other VF Modules may continue with the execution without stopping. However, in most of the cases, it is a good idea to stop further requests to SO if one of the VF Module instantiation returns an error. This user story, makes sure this functionality is achieved. Change-Id: I07c51b81111f805b61c8b3714a65171d7cbaa254 Signed-off-by: PATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/job/command')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt26
1 files changed, 22 insertions, 4 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
index 502d8344d..09357e519 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
@@ -25,9 +25,11 @@ import org.onap.portalsdk.core.service.DataAccessService
import org.onap.vid.job.Job
import org.onap.vid.job.Job.JobStatus.*
import org.onap.vid.job.impl.JobDaoImpl
+import org.onap.vid.properties.Features
import org.onap.vid.utils.DaoUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
+import org.togglz.core.manager.FeatureManager
import java.util.*
import java.util.stream.Collectors
import java.util.stream.Stream
@@ -35,7 +37,7 @@ import java.util.stream.Stream
@Service
class WatchChildrenJobsBL @Autowired
-constructor(private val dataAccessService: DataAccessService) {
+constructor(private val dataAccessService: DataAccessService, private val featureManager: FeatureManager) {
fun retrieveChildrenJobsStatus(childrenJobsIds: List<String>): Job.JobStatus {
val jobs = getAllChildrenJobs(childrenJobsIds)
@@ -47,14 +49,16 @@ constructor(private val dataAccessService: DataAccessService) {
else -> it.status
}}
- return cumulateJobStatus(jobsStatuses)
+ return if(featureManager.isActive(Features.FLAG_2008_PAUSE_VFMODULE_INSTANTIATION_FAILURE))
+ cumulateJobStatusWithPauseOnFailure(jobsStatuses) else cumulateJobStatus(jobsStatuses)
}
fun cumulateJobStatus(childrenComulatedStatus: Job.JobStatus, fatherJobStatus: Job.JobStatus): Job.JobStatus {
- return cumulateJobStatus(Stream.of(childrenComulatedStatus, fatherJobStatus))
+ return if(featureManager.isActive(Features.FLAG_2008_PAUSE_VFMODULE_INSTANTIATION_FAILURE))
+ cumulateJobStatusWithPauseOnFailure(Stream.of(childrenComulatedStatus, fatherJobStatus))
+ else cumulateJobStatus(Stream.of(childrenComulatedStatus, fatherJobStatus))
}
-
private fun cumulateJobStatus(jobsStatuses: Stream<Job.JobStatus>): Job.JobStatus {
return jobsStatuses.reduce{ a, b ->
@@ -70,7 +74,21 @@ constructor(private val dataAccessService: DataAccessService) {
}
} .orElse(COMPLETED_WITH_NO_ACTION)
}
+ private fun cumulateJobStatusWithPauseOnFailure(jobsStatuses: Stream<Job.JobStatus>): Job.JobStatus {
+ return jobsStatuses.reduce{ a, b ->
+ when {
+ a == FAILED_AND_PAUSED || b == FAILED_AND_PAUSED-> FAILED_AND_PAUSED
+ a == COMPLETED && b.isFailure -> FAILED_AND_PAUSED
+ b == COMPLETED && a.isFailure -> FAILED_AND_PAUSED
+ !a.isFinal || !b.isFinal -> IN_PROGRESS
+ a == COMPLETED_AND_PAUSED || b == COMPLETED_AND_PAUSED -> COMPLETED_AND_PAUSED
+ a == COMPLETED || b == COMPLETED -> COMPLETED
+ a.isFailure || b.isFailure -> FAILED
+ else -> COMPLETED_WITH_NO_ACTION
+ }
+ } .orElse(COMPLETED_WITH_NO_ACTION)
+ }
private fun getAllChildrenJobs(childrenJobsIds: List<String>): Map<UUID, JobDaoImpl> {
val jobs:MutableList<JobDaoImpl> = dataAccessService.getList(JobDaoImpl::class.java, filterByJobIds(childrenJobsIds), null, DaoUtils.getPropsMap()) as MutableList<JobDaoImpl>
return jobs.stream().collect(Collectors.toMap( { it.uuid }, { it }))