diff options
author | Joseph Keenan <joseph.keenan@est.tech> | 2022-07-07 15:32:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-07-07 15:32:12 +0000 |
commit | 5365c2d0a0de7ad820effbd1bc6106f420bb6223 (patch) | |
tree | 57f39b9fb30d4f1cba71b796dc8ce33be8863928 /cps-ncmp-service/src/main/java/org | |
parent | a88cee11a28900cf1e39fd01ffb700ea87b2af16 (diff) | |
parent | 520dc2cf66a6355217ee0cff7505f6bfd3621d44 (diff) |
Merge "Define Initial Data Sync Enabled Flag and state"
Diffstat (limited to 'cps-ncmp-service/src/main/java/org')
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java | 17 |
1 files changed, 13 insertions, 4 deletions
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 0330991fd6..f18d843f81 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 @@ -31,6 +31,7 @@ import org.onap.cps.ncmp.api.inventory.CompositeState; import org.onap.cps.ncmp.api.inventory.DataStoreSyncState; import org.onap.cps.ncmp.api.inventory.InventoryPersistence; import org.onap.cps.ncmp.api.inventory.LockReasonCategory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -45,6 +46,9 @@ public class ModuleSyncWatchdog { private final ModuleSyncService moduleSyncService; + @Value("${data-sync.cache.enabled:false}") + private boolean isGlobalDataSyncCacheEnabled; + /** * Execute Cm Handle poll which changes the cm handle state from 'ADVISED' to 'READY'. */ @@ -96,11 +100,9 @@ public class ModuleSyncWatchdog { private Consumer<CompositeState> setCompositeStateToReadyWithInitialDataStoreSyncState() { return compositeState -> { + compositeState.setDataSyncEnabled(isGlobalDataSyncCacheEnabled); compositeState.setCmHandleState(CmHandleState.READY); - final CompositeState.Operational operational = CompositeState.Operational.builder() - .dataStoreSyncState(DataStoreSyncState.UNSYNCHRONIZED) - .lastSyncTime(CompositeState.nowInSyncTimeFormat()) - .build(); + final CompositeState.Operational operational = getDataStoreSyncState(compositeState.getDataSyncEnabled()); final CompositeState.DataStores dataStores = CompositeState.DataStores.builder() .operationalDataStore(operational) .build(); @@ -116,4 +118,11 @@ public class ModuleSyncWatchdog { .details(oldLockReasonDetails).build(); compositeState.setLockReason(lockReason); } + + private CompositeState.Operational getDataStoreSyncState(final boolean dataSyncEnabled) { + final DataStoreSyncState dataStoreSyncState = dataSyncEnabled + ? DataStoreSyncState.UNSYNCHRONIZED : DataStoreSyncState.NONE_REQUESTED; + return CompositeState.Operational.builder().dataStoreSyncState(dataStoreSyncState).build(); + } + } |