aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main/java
diff options
context:
space:
mode:
authortalio <talio@amdocs.com>2020-06-17 15:57:06 +0300
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-06-21 07:13:29 +0000
commita098edad859459ab116d4587af8262877f2b522a (patch)
treed5ac83bf0ef79e0d0b7de4c28ba2953acf238b9d /catalog-dao/src/main/java
parentb0140364e491df1009cf00e50c0207d2e9ca3453 (diff)
Toggle
Add toggling mechanism to catalog side. The first toggleable feature is healing - this was added to healing flow, in healJanusGraphDao Issue-ID: SDC-2874 Signed-off-by: talio <talio@amdocs.com> Change-Id: If386651cab8304ebaf13497ded3a7a50bd60e477 Signed-off-by: talio <talio@amdocs.com>
Diffstat (limited to 'catalog-dao/src/main/java')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java20
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java1
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/ToggleableFeature.java43
3 files changed, 14 insertions, 50 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
index e74556ab14..c0a066346d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
@@ -28,6 +28,7 @@ import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.togglz.ToggleableFeature;
public class HealJanusGraphDao implements HealGraphDao<JanusGraphVertex, GraphEdgeLabels> {
@@ -41,18 +42,23 @@ public class HealJanusGraphDao implements HealGraphDao<JanusGraphVertex, GraphEd
public JanusGraphVertex performGraphReadHealing(JanusGraphVertex childVertex, GraphEdgeLabels graphEdgeLabels) {
final Integer healingVersionInt = (Integer) childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty()).orElse(HealConstants.DEFAULT_HEAL_VERSION);
HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
- healingPipelineDao.getHealersForVertex(graphEdgeLabels.name(), healingVersion).forEach(heal -> healGraphVertex(childVertex, heal));
- childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), healingPipelineDao.getCurrentHealVersion().getVersion());
+ healingPipelineDao.getHealersForVertex(graphEdgeLabels.name(), healingVersion)
+ .forEach(heal -> healGraphVertex(childVertex, heal));
+ childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(),
+ healingPipelineDao.getCurrentHealVersion().getVersion());
+
return childVertex;
}
private JanusGraphVertex healGraphVertex(JanusGraphVertex childVertex, Heal<JanusGraphVertex> heal) {
- heal.healData(childVertex);
- final HealVersion<Integer> healVersion = heal.fromVersion();
- HealVersion newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
- childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), newerVersion);
- heal.healData(childVertex);
+ if(ToggleableFeature.HEALING.isActive()) {
+ heal.healData(childVertex);
+ final HealVersion<Integer> healVersion = heal.fromVersion();
+ HealVersion<Integer> newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
+ childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), newerVersion);
+ heal.healData(childVertex);
+ }
return childVertex;
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java
index 501b421bd5..ed5a5a0b37 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java
@@ -26,6 +26,7 @@ import com.datastax.driver.mapping.annotations.Table;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
+import org.openecomp.sdc.be.togglz.ToggleableFeature;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.togglz.core.Feature;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/ToggleableFeature.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/ToggleableFeature.java
deleted file mode 100644
index 2fd2c80b02..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/ToggleableFeature.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2020 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.togglz;
-
-import org.togglz.core.Feature;
-import org.togglz.core.annotation.Label;
-import org.togglz.core.context.FeatureContext;
-
-import java.util.Arrays;
-
-public enum ToggleableFeature implements Feature{
- @Label("Default feature")
- DEFAULT_FEATURE;
-
- public static Feature getFeatureByName(String featureName) {
- return Arrays.stream(values()).
- filter(e -> e.name().equals(featureName))
- .findFirst()
- .orElse(null);
- }
-
- public boolean isActive() {
- return FeatureContext.getFeatureManager().isActive(this);
- }
-}