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;
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'.
*/
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();
.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();
+ }
+
}