diff options
author | davsad <david.sadlier@est.tech> | 2021-07-16 09:44:22 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-08-05 07:35:41 +0000 |
commit | 95b22d8d074f294e997c27d79d369b0eb3bee9e2 (patch) | |
tree | b61e6c279d51b28f424fd56efdc11988dcb9e722 /catalog-model/src/main/java | |
parent | 0f7ce92646104b5bf310a66ee91a9ef2eee26b3d (diff) |
Disable locking during deployment
Issue-ID: SDC-3643
Signed-off-by: davsad <david.sadlier@est.tech>
Change-Id: I1a04c253d70bf5aebf33bba7b2b9f83bd559ae64
Diffstat (limited to 'catalog-model/src/main/java')
2 files changed, 17 insertions, 8 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IGraphLockOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IGraphLockOperation.java index 21288168b3..3e4152728d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IGraphLockOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IGraphLockOperation.java @@ -30,4 +30,6 @@ public interface IGraphLockOperation { StorageOperationStatus lockComponentByName(String name, NodeTypeEnum nodeType); StorageOperationStatus unlockComponentByName(String name, String componentId, NodeTypeEnum nodeType); + + boolean disableLocking(final boolean disable); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GraphLockOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GraphLockOperation.java index 0106cd3529..bc49c8aaec 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GraphLockOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GraphLockOperation.java @@ -27,17 +27,17 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.common.log.wrappers.Logger; import org.springframework.stereotype.Component; +import lombok.NoArgsConstructor; + @Component("graph-lock-operation") +@NoArgsConstructor public class GraphLockOperation implements IGraphLockOperation { private static final Logger log = Logger.getLogger(GraphLockOperation.class.getName()); + private boolean disable = false; @javax.annotation.Resource private JanusGraphGenericDao janusGraphGenericDao; - public GraphLockOperation() { - super(); - } - /* * (non-Javadoc) * @@ -48,7 +48,7 @@ public class GraphLockOperation implements IGraphLockOperation { log.info("lock resource with id {}", componentId); JanusGraphOperationStatus lockElementStatus = null; try { - lockElementStatus = janusGraphGenericDao.lockElement(componentId, nodeType); + lockElementStatus = disable ? JanusGraphOperationStatus.OK : janusGraphGenericDao.lockElement(componentId, nodeType); } catch (Exception e) { lockElementStatus = JanusGraphOperationStatus.ALREADY_LOCKED; } @@ -62,13 +62,13 @@ public class GraphLockOperation implements IGraphLockOperation { */ @Override public StorageOperationStatus unlockComponent(String componentId, NodeTypeEnum nodeType) { - JanusGraphOperationStatus lockElementStatus = janusGraphGenericDao.releaseElement(componentId, nodeType); + JanusGraphOperationStatus lockElementStatus = disable ? JanusGraphOperationStatus.OK : janusGraphGenericDao.releaseElement(componentId, nodeType); return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(lockElementStatus); } @Override public StorageOperationStatus unlockComponentByName(String name, String componentId, NodeTypeEnum nodeType) { - JanusGraphOperationStatus lockElementStatus = janusGraphGenericDao.releaseElement(name, nodeType); + JanusGraphOperationStatus lockElementStatus = disable ? JanusGraphOperationStatus.OK : janusGraphGenericDao.releaseElement(name, nodeType); return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(lockElementStatus); } @@ -77,10 +77,17 @@ public class GraphLockOperation implements IGraphLockOperation { log.info("lock resource with name {}", name); JanusGraphOperationStatus lockElementStatus = null; try { - lockElementStatus = janusGraphGenericDao.lockElement(name, nodeType); + lockElementStatus = disable ? JanusGraphOperationStatus.OK : janusGraphGenericDao.lockElement(name, nodeType); } catch (Exception e) { lockElementStatus = JanusGraphOperationStatus.ALREADY_LOCKED; } return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(lockElementStatus); } + + @Override + public boolean disableLocking(boolean disable) { + log.info("Toggling disable locking from {} to {}", this.disable, disable); + this.disable = disable; + return this.disable; + } } |