summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2022-05-19 13:28:02 +0000
committerGerrit Code Review <gerrit@onap.org>2022-05-19 13:28:02 +0000
commitb0623697898de50afce9a4d23085594d5e8d2ef7 (patch)
treeb8e4ef7193fd52c5cc7401def51d728e3479b46f /cps-ncmp-service/src/main/java
parent324eb16687756f1850ffa484f652e117878cf33f (diff)
parent09156406ac7201a7329663e8fedb29dc28547048 (diff)
Merge "Composite State to handle dmi-reg YANG updates"
Diffstat (limited to 'cps-ncmp-service/src/main/java')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleState.java18
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeState.java104
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java2
5 files changed, 116 insertions, 26 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
index 5680d54a48..d4c64eac90 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
@@ -34,7 +34,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.onap.cps.ncmp.api.impl.operations.RequiredDmiService;
-import org.onap.cps.ncmp.api.inventory.CmHandleState;
+import org.onap.cps.ncmp.api.inventory.CompositeState;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.utils.CpsValidator;
@@ -57,7 +57,7 @@ public class YangModelCmHandle {
private String dmiDataServiceName;
@JsonProperty("state")
- private CmHandleState cmHandleState;
+ private CompositeState compositeState;
@JsonProperty("dmi-model-service-name")
private String dmiModelServiceName;
@@ -70,8 +70,9 @@ public class YangModelCmHandle {
/**
* Create a yangModelCmHandle.
- * @param dmiServiceName dmi service name
- * @param dmiDataServiceName dmi data service name
+ *
+ * @param dmiServiceName dmi service name
+ * @param dmiDataServiceName dmi data service name
* @param dmiModelServiceName dmi model service name
* @param ncmpServiceCmHandle the cm handle
* @return instance of yangModelCmHandle
@@ -88,12 +89,13 @@ public class YangModelCmHandle {
yangModelCmHandle.setDmiModelServiceName(dmiModelServiceName);
yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getDmiProperties()));
yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(
- ncmpServiceCmHandle.getPublicProperties()));
+ ncmpServiceCmHandle.getPublicProperties()));
return yangModelCmHandle;
}
/**
* Resolve a dmi service name.
+ *
* @param requiredService indicates what typo of service is required
* @return dmi service name
*/
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleState.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleState.java
index 0fce1d1890..24fab32a5c 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleState.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleState.java
@@ -21,21 +21,5 @@
package org.onap.cps.ncmp.api.inventory;
public enum CmHandleState {
-
- ADVISED {
- @Override
- public CmHandleState ready() {
- return READY;
- }
- },
- READY {
- @Override
- public CmHandleState ready() {
- return this;
- }
-
- };
-
- public abstract CmHandleState ready();
-
+ ADVISED, READY;
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeState.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeState.java
new file mode 100644
index 0000000000..9ac49a6ceb
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeState.java
@@ -0,0 +1,104 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.api.inventory;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Builder;
+import lombok.Data;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * State Model to store state corresponding to the Yang resource dmi-registry model.
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CompositeState {
+
+ @JsonProperty("cm-handle-state")
+ private CmHandleState cmhandleState;
+
+ @JsonProperty("lock-reason")
+ private LockReason lockReason;
+
+ @JsonProperty("last-update-time")
+ private String lastUpdateTime;
+
+ @JsonProperty("data-sync-enabled")
+ private Boolean dataSyncEnabled;
+
+ @JsonProperty("datastores")
+ private DataStores dataStores;
+
+ @Data
+ @Builder
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class LockReason {
+
+ @JsonProperty("reason")
+ private String reason;
+
+ @JsonProperty("details")
+ private String details;
+
+ }
+
+ @Data
+ @Builder
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class DataStores {
+
+ @JsonProperty("operational")
+ private Operational operationalDataStore;
+
+ @JsonProperty("running")
+ private Running runningDataStore;
+ }
+
+ @Data
+ @Builder
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class Operational {
+
+ @JsonProperty("sync-state")
+ private String syncState;
+
+ @JsonProperty("last-sync-time")
+ private String lastSyncTime;
+ }
+
+ @Data
+ @Builder
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class Running {
+
+ @JsonProperty("sync-state")
+ private String syncState;
+
+ @JsonProperty("last-sync-time")
+ private String lastSyncTime;
+ }
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
index 9329b2fb7e..353db9d68d 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
@@ -43,11 +43,11 @@ public class ModuleSyncWatchdog {
public void executeAdvisedCmHandlePoll() {
YangModelCmHandle advisedCmHandle = syncUtils.getAnAdvisedCmHandle();
while (advisedCmHandle != null) {
- final CmHandleState cmHandleState = advisedCmHandle.getCmHandleState();
moduleSyncService.syncAndCreateSchemaSet(advisedCmHandle);
// ToDo Lock Cm Handle if module sync fails
- syncUtils.updateCmHandleState(advisedCmHandle, cmHandleState.ready());
- log.info("{} is now in {} state", advisedCmHandle.getId(), advisedCmHandle.getCmHandleState());
+ syncUtils.updateCmHandleState(advisedCmHandle, CmHandleState.READY);
+ log.info("{} is now in {} state", advisedCmHandle.getId(),
+ advisedCmHandle.getCompositeState().getCmhandleState());
advisedCmHandle = syncUtils.getAnAdvisedCmHandle();
}
log.debug("No Cm-Handles currently found in an ADVISED state");
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java
index 019ab08cab..3bc43c5665 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java
@@ -78,7 +78,7 @@ public class SyncUtils {
* @param cmHandleState cm handle state
*/
public void updateCmHandleState(final YangModelCmHandle yangModelCmHandle, final CmHandleState cmHandleState) {
- yangModelCmHandle.setCmHandleState(cmHandleState);
+ yangModelCmHandle.getCompositeState().setCmhandleState(cmHandleState);
final String cmHandleJsonData = String.format("{\"cm-handles\":[%s]}",
jsonObjectMapper.asJsonString(yangModelCmHandle));
cpsDataService.updateNodeLeaves(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT,