summaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'asdctool/src/main/java')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java81
1 files changed, 48 insertions, 33 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java
index cba562750a..af067403e7 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig1911/SdcDeploymentArtTimeOutMigration.java
@@ -73,7 +73,8 @@ public class SdcDeploymentArtTimeOutMigration extends InstanceMigrationBase impl
public MigrationResult migrate() {
StorageOperationStatus status = updateDeploymentArtifactTimeOut();
return status == StorageOperationStatus.OK ?
- MigrationResult.success() : MigrationResult.error("failed to update instance deployment artifact timeOut. Error : " + status);
+ MigrationResult.success()
+ : MigrationResult.error("failed to update instance deployment artifact timeOut. Error : " + status);
}
protected StorageOperationStatus updateDeploymentArtifactTimeOut() {
@@ -81,7 +82,9 @@ public class SdcDeploymentArtTimeOutMigration extends InstanceMigrationBase impl
propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
- Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+ Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao
+ .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch,
+ JsonParseFlagEnum.ParseAll);
return byCriteria.either(this::proceed, this::handleError);
}
@@ -89,48 +92,60 @@ public class SdcDeploymentArtTimeOutMigration extends InstanceMigrationBase impl
protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
StorageOperationStatus status = StorageOperationStatus.NOT_FOUND;
GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
- try {
- Either<GraphVertex, JanusGraphOperationStatus> childVertex = janusGraphDao.getChildVertex(containerV, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, JsonParseFlagEnum.ParseAll);
- GraphVertex instDeployArt = childVertex.left().value();
- Collection<MapArtifactDataDefinition> values = (Collection<MapArtifactDataDefinition>) instDeployArt.getJson().values();
- List<ArtifactDataDefinition> artifactDataDefinitionsList = values.stream().map(f -> f.getMapToscaDataDefinition().values()).flatMap(f -> f.stream().filter(isRelevantArtifact())).collect(Collectors.toList());
- artifactDataDefinitionsList.forEach(t -> t.setTimeout(defaultTimeOut));
- status = updateVertexAndCommit(instDeployArt);
- } catch (NullPointerException e) {
- log.error("Null Pointer Exception occurred - this mean we have zombie vertex, migration task will continue anyway", e);
- status = StorageOperationStatus.OK;
- }
- catch (Exception e) {
- //it is happy flow as well
- log.error("Exception occurred:", e);
- log.error("Migration task will continue anyway, please find below vertex details related to this exception", e);
- if (containerV != null){
+ if (containerV == null) {
+ log.error("Unexpected null value for `containerV`");
+ } else {
+ try {
+ Either<GraphVertex, JanusGraphOperationStatus> childVertex = janusGraphDao
+ .getChildVertex(containerV, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, JsonParseFlagEnum.ParseAll);
+ GraphVertex instDeployArt = childVertex.left().value();
+ Collection<MapArtifactDataDefinition> values = (Collection<MapArtifactDataDefinition>) instDeployArt
+ .getJson().values();
+ List<ArtifactDataDefinition> artifactDataDefinitionsList = values.stream()
+ .map(f -> f.getMapToscaDataDefinition().values())
+ .flatMap(f -> f.stream().filter(isRelevantArtifact()))
+ .collect(Collectors.toList());
+ artifactDataDefinitionsList.forEach(t -> t.setTimeout(defaultTimeOut));
+ status = updateVertexAndCommit(instDeployArt);
+
+ } catch (NullPointerException e) {
+ log.error(
+ "Null Pointer Exception occurred - this mean we have zombie vertex, migration task will continue anyway",
+ e);
+ status = StorageOperationStatus.OK;
+ } catch (Exception e) {
+ //it is happy flow as well
+ log.error("Exception occurred:", e);
+ log.error(
+ "Migration task will continue anyway, please find below vertex details related to this exception",
+ e);
log.error("containerV.getUniqueId() {} ---> ", containerV.getUniqueId());
- }
- status = StorageOperationStatus.OK;
- } finally {
- if (status != StorageOperationStatus.OK) {
- janusGraphDao.rollback();
- log.info("failed to update vertex ID {} ", containerV.getUniqueId());
- if (status == StorageOperationStatus.NOT_FOUND) {
- //it is happy flow as well
- status = StorageOperationStatus.OK;
+ status = StorageOperationStatus.OK;
+ } finally {
+ if (status != StorageOperationStatus.OK) {
+ janusGraphDao.rollback();
+ log.info("failed to update vertex ID {} ", containerV.getUniqueId());
+ if (status == StorageOperationStatus.NOT_FOUND) {
+ //it is happy flow as well
+ status = StorageOperationStatus.OK;
+ }
+ } else {
+ log.info("vertex ID {} successfully updated", containerV.getUniqueId());
}
}
- else{
- log.info("vertex ID {} successfully updated", containerV.getUniqueId());
- }
-
}
+
return status;
}
private static Predicate<ArtifactDataDefinition> isRelevantArtifact() {
- return p -> ((p.getArtifactType().equals(ArtifactTypeEnum.HEAT.getType()) || p.getArtifactType().equals(ArtifactTypeEnum.HEAT_VOL.getType()) || p.getArtifactType().equals(ArtifactTypeEnum.HEAT_NET.getType()))
- && p.getTimeout() != defaultTimeOut);
+ return p -> ((p.getArtifactType().equals(ArtifactTypeEnum.HEAT.getType()) || p.getArtifactType()
+ .equals(ArtifactTypeEnum.HEAT_VOL.getType()) || p.getArtifactType()
+ .equals(ArtifactTypeEnum.HEAT_NET.getType()))
+ && p.getTimeout() != defaultTimeOut);
}