diff options
author | PATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com> | 2020-08-13 12:35:01 -0400 |
---|---|---|
committer | PATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com> | 2020-08-31 15:06:10 -0400 |
commit | 62c72edd91b2d5485683274298b8249670663519 (patch) | |
tree | f9534a62c76fbdc85dc7fbf86c9a9f71b7863d29 /vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java | |
parent | bc25167f4ef0aabdcc55d1d286081808e1e47ae9 (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/impl/JobsBrokerServiceInDatabaseImpl.java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java index 51803891a..7391f41a9 100644 --- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java @@ -45,12 +45,14 @@ import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.exceptions.OperationNotAllowedException; import org.onap.vid.job.Job; import org.onap.vid.job.JobsBrokerService; +import org.onap.vid.properties.Features; import org.onap.vid.properties.VidProperties; import org.onap.vid.services.VersionService; import org.onap.vid.utils.DaoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.togglz.core.manager.FeatureManager; @Service public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService { @@ -64,19 +66,21 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService { private int pollingIntervalSeconds; private final VersionService versionService; - + private final FeatureManager featureManager; @Autowired public JobsBrokerServiceInDatabaseImpl(DataAccessService dataAccessService, SessionFactory sessionFactory, @Value("0") int maxOpenedInstantiationRequestsToMso, @Value("10") int pollingIntervalSeconds, - VersionService versionService) { + VersionService versionService, + FeatureManager featureManager) { // tha @Value will inject conservative defaults; overridden in @PostConstruct from configuration this.dataAccessService = dataAccessService; this.sessionFactory = sessionFactory; this.maxOpenedInstantiationRequestsToMso = maxOpenedInstantiationRequestsToMso; this.pollingIntervalSeconds = pollingIntervalSeconds; this.versionService = versionService; + this.featureManager = featureManager; } @PostConstruct @@ -199,7 +203,7 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService { "and TEMPLATE_Id not in \n" + "(select TEMPLATE_Id from vid_job where" + " TEMPLATE_Id IS NOT NULL and("+ - " (JOB_STATUS='FAILED' and DELETED_AT is null)" + // failed but not deleted + " (JOB_STATUS IN('FAILED','FAILED_AND_PAUSED') and DELETED_AT is null)" + // failed but not deleted " or JOB_STATUS='IN_PROGRESS'" + " or TAKEN_BY IS NOT NULL))" + " \n " + // prefer older jobs, but the earlier in each bulk @@ -232,13 +236,24 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService { " and in_progress_count is NULL \n" + //and that have valid templateId " and JOB.template_id is not NULL \n"+ - ")\n" + + + filterFailedStatusForPendingResource() + + + ")" + //INDEX_IN_BULK is for order them inside same templateId, //template_id - for order between different templateId (just to be deterministic) "order by INDEX_IN_BULK,JOB.template_id \n" + "limit 1;"; } - + private String filterFailedStatusForPendingResource() { + String sql = "and JOB.template_id not in \n" + + "(select TEMPLATE_Id from vid_job where" + + " TEMPLATE_Id IS NOT NULL and (JOB_STATUS IN('FAILED','FAILED_AND_PAUSED') " + + " AND JOB_TYPE NOT IN('NetworkInstantiation','InstanceGroup','InstanceGroupMember') and DELETED_AT is null)" + // failed but not deleted + " or TAKEN_BY IS NOT NULL)"; + return featureManager.isActive(Features.FLAG_2008_PAUSE_VFMODULE_INSTANTIATION_FAILURE) ? + sql : ""; + } @Override public void pushBack(Job job) { |