aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2022-06-03 16:09:46 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2022-06-09 07:53:50 +0000
commit32159795628720b76a8ed789f632f9fa68b41603 (patch)
tree30b57722b043b6b3305ef2484c82da5908a932b8
parent2664cee1d5f2f44713d89b0de2bfa391e0f54aa8 (diff)
Retry fetch assettoscatemplate in csar generation
Change-Id: I328e174d34b1c8fb688510b498d50130827b9608 Issue-ID: SDC-4032 Signed-off-by: MichaelMorris <michael.morris@est.tech>
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java9
2 files changed, 13 insertions, 5 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
index 9b0b25b250..81d9e5d077 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
@@ -432,6 +432,7 @@ public class CsarUtils {
boolean isInCertificationRequest) throws IOException {
ArtifactDefinition artifactDef = component.getToscaArtifacts().get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE);
Either<ToscaRepresentation, ResponseFormat> toscaRepresentation = fetchToscaRepresentation(component, getFromCS, artifactDef);
+
// This should not be done but in order to keep the refactoring small enough we stop here.
// TODO: Refactor the rest of this function
@@ -879,10 +880,10 @@ public class CsarUtils {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.TOSCA_SCHEMA_FILES_NOT_FOUND, firstThreeOctets, CONFORMANCE_LEVEL));
}
- private Either<byte[], ActionStatus> getFromCassandra(String cassandraId) {
- return artifactCassandraDao.getArtifact(cassandraId).right().map(cos -> {
- log.debug("Failed to fetch artifact from Cassandra by id {} error {} ", cassandraId, cos);
- StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(cos);
+ private Either<byte[], ActionStatus> getFromCassandra(String cassandraId) {
+ return artifactCassandraDao.getArtifact(cassandraId).right().map(operationstatus -> {
+ log.info("Failed to fetch artifact from Cassandra by id {} error {}.", cassandraId, operationstatus);
+ StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(operationstatus);
return componentsUtils.convertFromStorageResponse(storageStatus);
}).left().map(DAOArtifactData::getDataAsArray);
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
index 3bd318c7b8..998c8eacd1 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.SocketOptions;
import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
@@ -28,6 +29,7 @@ import com.datastax.driver.core.policies.DefaultRetryPolicy;
import com.datastax.driver.core.policies.LoadBalancingPolicy;
import com.datastax.driver.core.policies.TokenAwarePolicy;
import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Mapper.Option;
import com.datastax.driver.mapping.MappingManager;
import fj.data.Either;
import java.util.List;
@@ -167,9 +169,14 @@ public class CassandraClient {
return Either.right(CassandraOperationStatus.CLUSTER_NOT_CONNECTED);
}
try {
- Mapper<T> mapper = manager.mapper(clazz);
+ Mapper<T> mapper = manager.mapper(clazz);
T result = mapper.get(id);
if (result == null) {
+ logger.info("Failed to get by Id [{}], trying again with consistency level ALL", id);
+ result = mapper.get(id, Option.consistencyLevel(ConsistencyLevel.ALL));
+ }
+ if (result == null) {
+ logger.info("Failed to get by Id [{}] with consistency level ALL", id);
return Either.right(CassandraOperationStatus.NOT_FOUND);
}
return Either.left(result);