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
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);
}
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;
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;
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);