summaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main/java/org
diff options
context:
space:
mode:
authorTomasz Golabek <tomasz.golabek@nokia.com>2019-06-25 14:30:23 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-07-14 11:55:00 +0000
commit5bb0a3b09bfe2c7f12af05af83223501c29a3f76 (patch)
tree9e7f3acdc5ad70111289b5c81baa4d9ffc86c222 /catalog-dao/src/main/java/org
parentff5db76f909826b332bcf294752646ed65ffaae5 (diff)
ComponentCache & ComponentCassandraDao removal
Also removed all classes uses these two. Change-Id: I6793c3c935ae61c5c65f70d3541c542edf188ab4 Issue-ID: SDC-2389 Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'catalog-dao/src/main/java/org')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java47
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java254
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java1
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java97
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java153
5 files changed, 0 insertions, 552 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java
deleted file mode 100644
index dcdd390485..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.cassandra;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Param;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.sdc.be.resources.data.ComponentCacheData;
-
-import java.util.List;
-
-@Accessor
-public interface ComponentCacheAccessor {
-
- @Query("SELECT * FROM sdccomponent.componentcache WHERE id IN :ids ALLOW FILTERING")
- Result<ComponentCacheData> getComponents(@Param("ids") List<String> ids);
-
- @Query("SELECT * FROM sdccomponent.componentcache WHERE id = :id ALLOW FILTERING")
- Result<ComponentCacheData> getComponent(@Param("id") String id);
-
- @Query("SELECT id,modification_time,type FROM sdccomponent.componentcache ALLOW FILTERING")
- Result<ComponentCacheData> getAllComponentIdTimeAndType();
-
- // @Query("SELECT * FROM sdcartifact.resources LIMIT 2000")
- // Result<ESArtifactData> getListOfResources();
-
- // Result<ESArtifactData> getListOfResources(List<String> dids);
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java
deleted file mode 100644
index 7b23a9db41..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCassandraDao.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.cassandra;
-
-import com.datastax.driver.core.Session;
-import com.datastax.driver.mapping.MappingManager;
-import com.datastax.driver.mapping.Result;
-import fj.data.Either;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.config.BeEcompErrorManager;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.resources.data.ComponentCacheData;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import java.util.*;
-import java.util.stream.Collectors;
-
-@Component("component-cassandra-dao")
-public class ComponentCassandraDao extends CassandraDao {
-
- private static Logger logger = Logger.getLogger(ComponentCassandraDao.class.getName());
-
- public final static Integer DEFAULT_FETCH_SIZE = 500;
-
- private ComponentCacheAccessor componentCacheAccessor;
-
-
- @Autowired
- public ComponentCassandraDao(CassandraClient cassandraClient) {
- super(cassandraClient);
- }
-
- @PostConstruct
- public void init() {
- String keyspace = AuditingTypesConstants.COMPONENT_KEYSPACE;
- if (client.isConnected()) {
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
- if (result.isLeft()) {
- session = result.left().value().left;
- manager = result.left().value().right;
- componentCacheAccessor = manager.createAccessor(ComponentCacheAccessor.class);
- logger.info("** ComponentCassandraDao created");
- } else {
- logger.info("** ComponentCassandraDao failed");
- throw new RuntimeException("Artifact keyspace [" + keyspace + "] failed to connect with error : "
- + result.right().value());
- }
- } else {
- logger.info("** Cassandra client isn't connected");
- logger.info("** ComponentCassandraDao created, but not connected");
- }
- }
-
- /**
- *
- * @param ids
- * - list of components unique id
- * @return
- */
- public Either<List<ComponentCacheData>, ActionStatus> getComponents(List<String> ids) {
-
- List<ComponentCacheData> components = new ArrayList<>();
- if (ids == null || ids.isEmpty()) {
- return Either.left(components);
- }
-
- try {
-
- Result<ComponentCacheData> events = componentCacheAccessor.getComponents(ids);
- if (events == null) {
- logger.trace("not found component for ids list of in size {}", ids.size());
- return Either.left(components);
- }
- events.all().forEach(event -> {
- components.add(event);
- logger.trace("Fetch component uid = {} isDirty = {}", event.getId(), event.getIsDirty());
- });
-
- logger.debug("Number of components to fetch was {}. Actually, {} components fetched", ids.size(),
- components.size());
-
- return Either.left(components);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("GetComponentsFromCache");
-
- logger.debug("failed to get components from cache", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<ComponentCacheData>, ActionStatus> getAllComponentIdTimeAndType() {
- try {
- List<ComponentCacheData> components = new ArrayList<>();
- Result<ComponentCacheData> events = componentCacheAccessor.getAllComponentIdTimeAndType();
- if (events == null) {
- logger.trace("no component found ");
- return Either.left(components);
- }
- events.all().forEach(event -> {
- components.add(event);
- logger.trace("Fetch component uid = {} isDirty = {}", event.getId(), event.getIsDirty());
- });
-
- logger.debug("Number of components fetched was {}.", components.size());
-
- return Either.left(components);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("GetComponentsFromCache");
-
- logger.debug("failed to get components from cache", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- /**
- *
- * @param id
- * - component unique id
- * @return
- */
- public Either<ComponentCacheData, ActionStatus> getComponent(String id) {
-
- if (id == null) {
- return Either.right(ActionStatus.INVALID_CONTENT);
- }
-
- try {
-
- Result<ComponentCacheData> events = componentCacheAccessor.getComponent(id);
- if (events == null) {
- logger.trace("not found component for id {}", id);
- return Either.right(ActionStatus.RESOURCE_NOT_FOUND);
- }
-
- ComponentCacheData componentCacheData = events.one();
- if (componentCacheData != null) {
- logger.debug("Component with id {} was found. isDirty={}.", componentCacheData.getId(),
- componentCacheData.getIsDirty());
- } else {
- return Either.right(ActionStatus.RESOURCE_NOT_FOUND);
- }
- return Either.left(componentCacheData);
-
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("GetComponentFromCache");
-
- logger.trace("Failed to get component from cache", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public CassandraOperationStatus saveComponent(ComponentCacheData componentCacheData) {
- return client.save(componentCacheData, ComponentCacheData.class, manager);
- }
-
- /**
- * the method checks if the given table is empty in the artifact keyspace
- *
- * @param tableName
- * the name of the table we want to check
- * @return true if the table is empty
- */
- public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
- return super.isTableEmpty(tableName);
- }
-
- /**
- *
- * @param idToTimestampMap
- * - list of components unique id
- * @return
- */
- public Either<ImmutablePair<List<ComponentCacheData>, Set<String>>, ActionStatus> getComponents(
- Map<String, Long> idToTimestampMap) {
-
- List<ComponentCacheData> components = new ArrayList<>();
- Set<String> notFetchedFromCache = new HashSet<>();
- ImmutablePair<List<ComponentCacheData>, Set<String>> result = new ImmutablePair<>(
- components, notFetchedFromCache);
-
- if (idToTimestampMap == null || idToTimestampMap.isEmpty()) {
- return Either.left(result);
- }
-
- try {
-
- Set<String> keySet = idToTimestampMap.keySet();
- List<String> ids = new ArrayList<>();
- ids.addAll(keySet);
- Result<ComponentCacheData> events = componentCacheAccessor.getComponents(ids);
- if (events == null) {
- logger.trace("not found component for ids list of in size {}", ids.size());
- notFetchedFromCache.addAll(idToTimestampMap.keySet());
- return Either.left(result);
- }
- events.all().forEach(event -> {
- long timeFromCache = event.getModificationTime().getTime();
- long timeRequested = idToTimestampMap.get(event.getId());
- if (timeFromCache == timeRequested) {
- logger.trace("Fetch component uid = {} from cache", event.getId());
- components.add(event);
- } else {
- logger.trace(
- "Fetch and ignore component uid = {} from cache. Time requested is {} while timestamp in cache is {}",
- event.getId(), timeRequested, timeFromCache);
- }
- });
-
- logger.debug("Number of components to fetch was {}. Actually, {} components fetched", ids.size(),
- components.size());
- List<String> foundComponents = components.stream().map(ComponentCacheData::getId).collect(Collectors.toList());
- // fetch all ids which was not found in cache/found in cache and not
- // updated.
- Set<String> notFoundComponents = idToTimestampMap.keySet().stream()
- .filter(p -> !foundComponents.contains(p)).collect(Collectors.toSet());
-
- notFetchedFromCache.addAll(notFoundComponents);
-
- return Either.left(result);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("GetComponentsFromCache");
-
- logger.debug("failed to get components from cache", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public CassandraOperationStatus deleteComponent(String id) {
- return client.delete(id, ComponentCacheData.class, manager);
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
index 2e4a6329aa..b0209d2a13 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
@@ -40,7 +40,6 @@ public enum Table {
GET_USERS_LIST_EVENT(new GetUsersListEventTableDesc()),
GET_CATEGORY_HIERARCHY_EVENT(new GetCatHierEventTableDesc()),
EXTERNAL_API_EVENT(new ExternalApiEventTableDesc()),
- COMPONENT_CACHE(new ComponentCacheTableDescription()),
SDC_SCHEMA_FILES(new SdcSchemaFilesTableDescription()),
SDC_REPO(new MigrationTasksTableDescription()),
SDC_OPERATIONAL_ENVIRONMENT(new OperationalEnvironmentsTableDescription()),
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java
deleted file mode 100644
index cb13e0ea15..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ComponentCacheTableDescription.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.cassandra.schema.tables;
-
-import com.datastax.driver.core.DataType;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ComponentCacheTableDescription implements ITableDescription {
-
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(ID_FIELD, DataType.varchar()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- for (PartialComponentFieldsDescription field : PartialComponentFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.COMPONENT_KEYSPACE;
- }
-
- @Override
- public String getTableName() {
- return "componentcache";
- }
-
- enum PartialComponentFieldsDescription {
- DATA("data", DataType.blob(), false),
- MODIFICATION_TIME("modification_time", DataType.timestamp(), false),
- TYPE("type", DataType.varchar(), false),
- IS_DIRTY("is_dirty", DataType.cboolean(), false),
- IS_ZIPPED("is_zipped", DataType.cboolean(), false),;
-
- private String name;
- private DataType type;
- private boolean indexed;
-
- PartialComponentFieldsDescription(String name, DataType type, boolean indexed) {
- this.name = name;
- this.type = type;
- this.indexed = indexed;
- }
-
- public String getName() {
- return name;
- }
-
- public DataType getType() {
- return type;
- }
-
- public boolean isIndexed() {
- return indexed;
- }
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- return null;
- }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java
deleted file mode 100644
index cb7af866be..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.resources.data;
-
-import com.datastax.driver.mapping.annotations.Column;
-import com.datastax.driver.mapping.annotations.PartitionKey;
-import com.datastax.driver.mapping.annotations.Table;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-
-@Table(keyspace = "sdccomponent", name = "componentcache")
-public class ComponentCacheData {
- public final static String RRESOURCE_ID_FIELD = "resourceId";
-
- public final static String SERVICE_NAME_FIELD = "serviceName";
- public final static String SERVICE_VERSION_FIELD = "serviceVersion";
- public final static String ARTIFACT_NAME_FIELD = "artifactName";
-
- public final static String delim = ":";
-
- @PartitionKey
- @Column(name = "id")
- private String id;
-
- @Column
- private ByteBuffer data;
-
- @Column(name = "modification_time")
- private Date modificationTime;
-
- @Column
- private String type;
-
- @Column(name = "is_dirty")
- private boolean isDirty;
-
- @Column(name = "is_zipped")
- private boolean isZipped;
-
- public ComponentCacheData() {
-
- }
-
- public ComponentCacheData(String id, byte[] data, Date modificationTime, String type, boolean isDirty,
- boolean isZipped) {
- super();
- this.id = id;
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- }
- this.modificationTime = modificationTime;
- this.type = type;
- this.isDirty = isDirty;
- this.isZipped = isZipped;
- }
-
- public ComponentCacheData(String id) {
-
- this.id = id;
- }
-
- public ComponentCacheData(String artifactId, byte[] data) {
- super();
- this.id = artifactId;
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- // this.data = data.clone();
- }
- }
-
- public byte[] getDataAsArray() {
- if (data != null) {
- return data.array();
- }
- return null;
- }
-
- public void setDataAsArray(byte[] data) {
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- }
- }
-
- public ByteBuffer getData() {
- return data;
- }
-
- public void setData(ByteBuffer data) {
- if (data != null) {
- this.data = data.duplicate();
- }
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Date getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Date modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public boolean getIsDirty() {
- return isDirty;
- }
-
- public void setIsDirty(boolean isDirty) {
- this.isDirty = isDirty;
- }
-
- public boolean getIsZipped() {
- return isZipped;
- }
-
- public void setIsZipped(boolean isZipped) {
- this.isZipped = isZipped;
- }
-
-}