diff options
author | Tal Gitelman <tg851x@intl.att.com> | 2018-06-10 18:05:18 +0300 |
---|---|---|
committer | Tal Gitelman <tg851x@intl.att.com> | 2018-06-10 18:06:21 +0300 |
commit | 907753f90f876574efdc4c4153ef7516e0bcf8b3 (patch) | |
tree | 639f855f78bfa6063bddf0f2606b682ea1efbde3 /catalog-model/src/main | |
parent | 3e20c00529a3208f32c8814cc6420b8a0f11bb66 (diff) |
new unit tests for sdc-model
Change-Id: I31489f5e9bc83aaa5b18ebf2e519a13216f49332
Issue-ID: SDC-1333
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-model/src/main')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java | 92 |
1 files changed, 13 insertions, 79 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java index eb33a50e0b..439b4346ef 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java @@ -74,7 +74,7 @@ public class ComponentCache { @Autowired ComponentCassandraDao componentCassandraDao; - + @Autowired ToscaOperationFacade toscaOperationFacade; @@ -157,64 +157,6 @@ public class ComponentCache { } /** - * get components for catalog - * - * @param components - * @param componentTypeEnum - * @return - */ - @Deprecated - public Either<ImmutableTriple<List<Component>, List<Component>, Set<String>>, ActionStatus> getComponentsForCatalog( - Set<String> components, ComponentTypeEnum componentTypeEnum) { - - if (false == isEnabled()) { - logger.debug("In getComponentsForCatalog for type {}. Cache is disabled.", - componentTypeEnum.name().toLowerCase()); - return Either.right(ActionStatus.NOT_ALLOWED); - } - logger.debug("In getComponentsForCatalog for type {}", componentTypeEnum.name().toLowerCase()); - - Function<List<Component>, List<Component>> filterFieldsFunc = x -> filterForCatalog(x); - - Set<String> leftComponentsForSearch = new HashSet<>(); - leftComponentsForSearch.addAll(components); - - // get components from inmemory cache - List<Component> componentsFromMemory = null; - if (true == catalogInMemoryEnabled) { - componentsFromMemory = getDataFromInMemoryCache(components, componentTypeEnum); - logger.debug("The number of components of type {} fetched from memory is {}", - componentTypeEnum.name().toLowerCase(), - componentsFromMemory == null ? 0 : componentsFromMemory.size()); - if (componentsFromMemory != null) { - componentsFromMemory.forEach(p -> leftComponentsForSearch.remove(p.getUniqueId())); - } - } else { - logger.debug("Catalog InMemory cache is disabled"); - } - - logger.debug("Number of components from type {} needed to fetch is {}", componentTypeEnum.name().toLowerCase(), - leftComponentsForSearch.size()); - - // get components from cassandra cache and filter each component - Either<ImmutableTriple<List<Component>, List<Component>, Set<String>>, ActionStatus> result = getComponents( - leftComponentsForSearch, filterFieldsFunc); - - if (result.isLeft()) { - // add inmemory components to the valid components(not dirty) - List<Component> foundComponents = result.left().value().getLeft(); - if (componentsFromMemory != null) { - foundComponents.addAll(componentsFromMemory); - } - if (true == catalogInMemoryEnabled) { - updateCatalogInMemoryCacheWithCertified(foundComponents, componentTypeEnum); - } - } - - return result; - } - - /** * @param foundComponents * @param componentTypeEnum */ @@ -267,13 +209,13 @@ public class ComponentCache { /** * - * get full components from cassandra. On each component apply filter - * function in order to remove unused members + * get full components from cassandra. On each component apply filter function + * in order to remove unused members * * @param components * @param filterFieldsFunc - * @return <found components, found dirty components, not found components - * list> or Error + * @return <found components, found dirty components, not found components list> + * or Error */ public Either<ImmutableTriple<List<Component>, List<Component>, Set<String>>, ActionStatus> getComponents( Set<String> components, Function<List<Component>, List<Component>> filterFieldsFunc) { @@ -466,8 +408,8 @@ public class ComponentCache { * * @param filteredResources * @return ImmutableTripple or ActionStatus. | |-- components |-- dirty - * components - components with dirty flag = true. |-- set of non - * cached components + * components - components with dirty flag = true. |-- set of non cached + * components * */ private Either<ImmutableTriple<List<Component>, List<Component>, Set<String>>, ActionStatus> getComponentsFull( @@ -546,11 +488,9 @@ public class ComponentCache { .collect(Collectors.toSet()); notFoundResources.addAll(notCachedResources); - if (logger.isDebugEnabled()) { - logger.debug("Number of components fetched is {}", foundResources.size()); - logger.debug("Number of components fetched dirty is {}", foundDirtyResources.size()); - logger.debug("Number of components non cached is {}", notCachedResources.size()); - } + logger.debug("Number of components fetched is {}", foundResources.size()); + logger.debug("Number of components fetched dirty is {}", foundDirtyResources.size()); + logger.debug("Number of components non cached is {}", notCachedResources.size()); return Either.left(result); } @@ -603,7 +543,6 @@ public class ComponentCache { public Either<Component, ActionStatus> getComponent(String componentUid) { return getComponent(componentUid, null, Function.identity()); - } public Either<Component, ActionStatus> getComponent(String componentUid, Long lastModificationTime) { @@ -663,9 +602,6 @@ public class ComponentCache { } catch (IOException e) { logger.debug("Failed to prepare component {} of type {} for cache", componentUid, nodeTypeEnum.name().toLowerCase()); - if (logger.isTraceEnabled()) { - logger.trace("Failed to prepare component {} of type {} for cache",componentUid,nodeTypeEnum.name().toLowerCase()); - } } } else { logger.debug("Failed to serialize component {} of type {} for cache", componentUid, @@ -768,10 +704,8 @@ public class ComponentCache { Set<String> notFoundInCache = immutablePair.getRight(); notFoundResources.addAll(notFoundInCache); - if (logger.isDebugEnabled()) { - logger.debug("Number of components fetched is {}", foundResources.size()); - logger.debug("Number of components non cached is {}", notFoundResources.size()); - } + logger.debug("Number of components fetched is {}", foundResources.size()); + logger.debug("Number of components non cached is {}", notFoundResources.size()); return Either.left(result); } @@ -955,7 +889,7 @@ public class ComponentCache { if (false == isEnabled()) { return ActionStatus.NOT_ALLOWED; } - CassandraOperationStatus status = this.componentCassandraDao.deleteComponent(id); + CassandraOperationStatus status = componentCassandraDao.deleteComponent(id); if (CassandraOperationStatus.OK.equals(status)) { return ActionStatus.OK; } else { |